* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-dark: #0a0f1a;
  --bg-panel: #111827;
  --bg-surface: #1f2937;
  --border: #374151;
  --text: #e5e7eb;
  --text-dim: #9ca3af;
  --accent: #3b82f6;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --cyan: #06b6d4;
  --purple: #8b5cf6;
}

body {
  font-family: 'Segoe UI', -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
.header {
  background: linear-gradient(180deg, #1e3a5f 0%, #0f2744 100%);
  border-bottom: 2px solid var(--accent);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header .back-link {
  color: var(--cyan);
  text-decoration: none;
  font-size: 0.9rem;
}

.header .back-link:hover { text-decoration: underline; }

/* Main */
.main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.tab {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: all 0.15s;
}

.tab:hover { color: var(--text); background: var(--bg-surface); }
.tab.active { color: var(--accent); background: var(--bg-panel); border-bottom: 2px solid var(--accent); }

/* Panels */
.panel { display: none; }
.panel.active { display: block; }

/* Form */
.form-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}

.form-header {
  margin-bottom: 1.5rem;
}

.form-header h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.form-header p {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
}

.form-group label .required {
  color: var(--red);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.form-group textarea {
  min-height: 150px;
  resize: vertical;
}

.form-group select {
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

/* Category cards */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.category-card {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.category-card:hover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
}

.category-card.selected {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.15);
}

.category-card .icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.category-card h3 {
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.category-card p {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Submit button */
.submit-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 1rem 2rem;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: background 0.15s;
}

.submit-btn:hover { background: #2563eb; }

.submit-note {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.submit-note a { color: var(--cyan); }

/* Ticket list */
.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ticket-item {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.15s;
}

.ticket-item:hover {
  border-color: var(--accent);
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.ticket-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.ticket-number {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: monospace;
}

.ticket-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.ticket-label {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}

.label-roads { background: #f59e0b33; color: #f59e0b; }
.label-budget { background: #22c55e33; color: #22c55e; }
.label-services { background: #3b82f633; color: #3b82f6; }
.label-other { background: #8b5cf633; color: #8b5cf6; }

.ticket-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-open { background: #22c55e33; color: #22c55e; }
.status-progress { background: #f59e0b33; color: #f59e0b; }
.status-closed { background: #6b728033; color: #9ca3af; }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  font-family: monospace;
}

.stat-card .label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.stat-card.green .value { color: var(--green); }
.stat-card.yellow .value { color: var(--yellow); }
.stat-card.blue .value { color: var(--accent); }

/* Loading */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-dim);
}

.loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Preview modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.active { display: flex; }

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h3 { font-size: 1.25rem; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
}

.preview-section {
  margin-bottom: 1rem;
}

.preview-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.preview-value {
  background: var(--bg-surface);
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.modal-actions button {
  flex: 1;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-primary {
  background: var(--green);
  border: none;
  color: #000;
}

.btn-primary:hover { background: #16a34a; }

@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
