:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #0d9488;
  --bg: #e8ecef;
  --surface: #ffffff;
  --input-bg: #f8f9fa;
  --text: #212529;
  --text-muted: #6c757d;
  --border: #dee2e6;
  --border-focus: #86b7fe;
  --danger: #dc3545;
  --warning: #fd7e14;
  --success: #198754;
  --shadow: 0 8px 24px rgba(33, 37, 41, 0.08);
  --shadow-lg: 0 16px 40px rgba(33, 37, 41, 0.12);
  --radius: 14px;
  --sidebar-width: 260px;
}

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

html {
  font-size: 16px;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a {
  color: var(--primary-dark);
  text-decoration: none;
}

.container {
  width: min(960px, 92%);
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.app-header {
  text-align: center;
  margin-bottom: 2rem;
}

.app-header h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.app-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.glass-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.screen {
  display: none;
  animation: fadeIn 0.35s ease;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

.form-control {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  background: var(--input-bg);
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.form-control::placeholder {
  color: #adb5bd;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, opacity 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary-dark);
}

.btn-block {
  width: 100%;
}

.phone-prefix {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.phone-prefix span {
  padding: 0.85rem 1rem;
  background: var(--primary-light);
  border-radius: 12px;
  font-weight: 600;
  color: var(--primary-dark);
  white-space: nowrap;
}

.phone-prefix .form-control {
  flex: 1;
}

/* Voice recorder */
.recorder-area {
  text-align: center;
  padding: 1rem 0 1.5rem;
}

.wave-container {
  position: relative;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

#waveCanvas {
  width: 100%;
  max-width: 400px;
  height: 100px;
  border-radius: 12px;
  background: linear-gradient(180deg, #f0fdfa 0%, #ecfeff 100%);
}

.mic-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(13, 148, 136, 0.35);
  transition: transform 0.15s, box-shadow 0.2s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.mic-btn.recording {
  animation: pulse 1.2s infinite;
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5);
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
  70% { box-shadow: 0 0 0 16px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.mic-hint {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.transcript-box {
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 1rem;
  min-height: 80px;
  margin: 1rem 0;
  text-align: left;
  font-size: 0.95rem;
}

.transcript-box.empty {
  color: var(--text-muted);
  font-style: italic;
}

.department-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary-dark);
  margin-top: 0.5rem;
}

.success-box {
  text-align: center;
  padding: 1.5rem;
}

.success-box i {
  font-size: 3rem;
  color: var(--success);
  margin-bottom: 1rem;
}

.uuid-display {
  background: #f1f5f9;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-family: monospace;
  font-size: 0.85rem;
  word-break: break-all;
  margin: 1rem 0;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-links a:hover {
  background: var(--primary-light);
}

/* Specialist cabinet */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(420px, 100%);
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  text-align: center;
}

.stat-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-dark);
}

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

.filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-btn {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 2px solid #d1fae5;
  background: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.complaint-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.complaint-item {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  transition: transform 0.15s, box-shadow 0.15s;
  color: inherit;
}

.complaint-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.complaint-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.status-badge {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-yangi { background: #dbeafe; color: #1d4ed8; }
.status-korib_chiqilmoqda { background: #fef3c7; color: #b45309; }
.status-korib_chiqildi { background: #d1fae5; color: #047857; }

.complaint-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.meta-item {
  background: #f8fafc;
  padding: 0.85rem;
  border-radius: 10px;
}

.meta-item .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.meta-item .value {
  font-weight: 600;
  margin-top: 0.25rem;
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.result-card {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 14px;
  padding: 1.25rem;
  margin-top: 1rem;
}

.result-card h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.loading {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

@media (max-width: 600px) {
  .container {
    padding: 1.25rem 0 2rem;
  }

  .card {
    padding: 1.25rem;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .letter-grid {
    grid-template-columns: 1fr;
  }
}

/* === Enhanced UI === */
body {
  position: relative;
  overflow-x: hidden;
}

.bg-shapes {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-shapes .shape {
  display: none;
}

.shape-1 {
  width: 320px;
  height: 320px;
  background: #5eead4;
  top: -80px;
  left: -60px;
}

.shape-2 {
  width: 280px;
  height: 280px;
  background: #93c5fd;
  bottom: 10%;
  right: -40px;
  animation-delay: -4s;
}

.shape-3 {
  width: 220px;
  height: 220px;
  background: #a7f3d0;
  top: 40%;
  right: 20%;
  animation-delay: -7s;
}

@keyframes floatShape {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -15px) scale(1.05); }
}

.container,
.auth-layout .auth-card {
  position: relative;
  z-index: 1;
}

.glass-card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(153, 246, 228, 0.7);
}

.animate-in {
  animation: fadeIn 0.5s ease both;
}

.pop-in {
  animation: popIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.logo-badge {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 12px 30px rgba(13, 148, 136, 0.35);
  animation: popIn 0.6s ease both;
}

.screen-title {
  margin-bottom: 1rem;
  font-size: 1.15rem;
}

.btn-glow {
  box-shadow: 0 8px 24px rgba(13, 148, 136, 0.28);
}

.btn-glow:hover:not(:disabled) {
  box-shadow: 0 12px 28px rgba(13, 148, 136, 0.38);
  transform: translateY(-1px);
}

.ai-result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #f0fdfa 0%, #eff6ff 100%);
  border: 1px solid #99f6e4;
  text-align: center;
}

.ai-result-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.department-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}

.dept-pediatr { background: #dbeafe; color: #1d4ed8; }
.dept-jarroh { background: #fee2e2; color: #b91c1c; }
.dept-stomatolog { background: #fef3c7; color: #b45309; }

.success-icon-wrap {
  width: 80px;
  height: 80px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2.5rem;
  color: var(--success);
  background: #ecfdf5;
  animation: popIn 0.5s ease both;
}

.ref-number {
  font-family: 'Courier New', monospace;
  letter-spacing: 0.04em;
  color: var(--primary-dark);
  font-weight: 700;
}

.mono {
  font-family: monospace;
  font-size: 0.8rem;
  word-break: break-all;
}

.phone-value {
  color: var(--primary-dark);
  font-size: 1.05rem;
}

.stat-card {
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.complaint-item {
  animation: fadeIn 0.4s ease both;
}

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

.finalize-panel {
  margin-top: 1rem;
  padding: 1.25rem;
  border-radius: 16px;
  background: linear-gradient(180deg, #f8fafc 0%, #f0fdfa 100%);
  border: 1px solid #d1fae5;
}

.finalize-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.phone-highlight {
  padding: 0.65rem 1rem;
  border-radius: 12px;
  background: #fff;
  border: 2px solid var(--primary);
  text-align: right;
}

.phone-highlight span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.phone-highlight strong {
  font-size: 1.1rem;
  color: var(--primary-dark);
}

.phone-full {
  font-weight: 600;
  color: #0f766e;
  letter-spacing: 0.02em;
}

.letter-preview-wrap {
  margin-top: 1.5rem;
}

.gov-letter {
  background: #fff;
  color: #111;
  font-family: 'Times New Roman', Times, serif;
  font-size: 13px;
  line-height: 1.55;
  padding: 2rem 2.25rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  max-width: 210mm;
  margin: 0 auto;
}

.gov-letter-header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.gov-org-line {
  margin: 0;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.gov-org-main {
  font-size: 13px;
}

.gov-org-sub {
  font-size: 13px;
  margin-top: 0.15rem;
}

.gov-org-contact {
  margin: 0.5rem 0 0;
  font-size: 11.5px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.45;
}

.gov-meta-block {
  margin: 1rem 0 1.25rem;
  font-size: 12.5px;
}

.gov-meta-block p {
  margin: 0.2rem 0;
}

.gov-title {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 1.25rem 0 1rem;
  text-transform: uppercase;
}

.gov-details {
  margin-bottom: 1rem;
  font-size: 12.5px;
}

.gov-details h2 {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.gov-details p {
  margin: 0.25rem 0;
}

.gov-greeting {
  font-weight: 700;
  margin: 1rem 0 0.75rem;
}

.gov-body p {
  margin: 0 0 0.75rem;
  text-align: justify;
}

.gov-list {
  margin: 0 0 0.75rem 1.1rem;
  padding: 0;
}

.gov-list li {
  margin-bottom: 0.5rem;
  text-align: justify;
}

.gov-signature {
  margin-top: 2rem;
  text-align: right;
  max-width: 55%;
  margin-left: auto;
}

.gov-signature-dept {
  margin: 0 0 0.75rem;
  font-size: 12.5px;
  line-height: 1.4;
}

.gov-signature-name {
  margin: 0;
  font-weight: 700;
  font-size: 13px;
}

.gov-footer-note {
  margin-top: 2rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
  font-size: 11px;
  color: #4b5563;
  text-align: center;
}

body.letter-fullscreen-open,
body.result-fullscreen-open {
  overflow: hidden;
}

.letter-fullscreen,
.result-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #eef2f6;
  display: flex;
  flex-direction: column;
}

.letter-fullscreen-topbar,
.result-fullscreen-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
}

.letter-fullscreen-topbar h2,
.result-fullscreen-topbar h2 {
  margin: 0;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}

.letter-fullscreen-back,
.letter-fullscreen-download,
.result-fullscreen-back,
.result-fullscreen-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 42px;
  padding: 0.55rem 0.9rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #1e293b;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.letter-fullscreen-download,
.result-fullscreen-action {
  width: 42px;
  padding: 0;
}

.result-fullscreen-action.is-hidden {
  visibility: hidden;
  pointer-events: none;
}

.letter-fullscreen-body,
.result-fullscreen-body {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  -webkit-overflow-scrolling: touch;
}

.letter-fullscreen-scroll,
.result-fullscreen-scroll {
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.letter-fullscreen-preview .gov-letter {
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

.check-result-modal-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 22px;
  padding: 1.75rem 1.35rem;
  text-align: center;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  max-width: 420px;
  margin: 0 auto;
}

.check-result-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 1rem;
  font-size: 2rem;
}

.check-result-icon.status-yangi {
  background: #dbeafe;
  color: #1d4ed8;
}

.check-result-icon.status-korib_chiqilmoqda {
  background: #fef3c7;
  color: #b45309;
}

.check-result-modal-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  color: #1e293b;
}

.check-result-subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: #64748b;
}

.check-result-code {
  margin: 0.85rem 0 1.1rem;
  justify-content: center;
}

.check-result-meta {
  text-align: left;
  margin-bottom: 1rem;
}

.check-result-message {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #475569;
  background: #f8fafc;
  border-radius: 14px;
  padding: 0.85rem 1rem;
}

.check-result-summary {
  text-align: center;
  padding: 0.85rem;
}

@media (min-width: 768px) {
  .result-fullscreen-body {
    padding: 1.5rem 2rem 2rem;
  }

  .check-result-modal-card {
    padding: 2rem 1.75rem;
  }
}

.letter-ready-card {
  text-align: center;
  padding: 1.25rem;
}

.letter-ready-card h3 {
  margin-bottom: 0.75rem;
}

.letter-ready-card .btn-yellow {
  margin-top: 0.75rem;
}

.official-letter {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

.letter-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1rem;
  border-bottom: 2px solid #0d9488;
  margin-bottom: 1.25rem;
}

.letter-brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.letter-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0d9488, #2563eb);
  color: #fff;
  font-size: 1.4rem;
}

.letter-brand h2 {
  font-size: 1rem;
  margin-bottom: 0.15rem;
}

.letter-brand p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.letter-ref-block {
  text-align: right;
}

.letter-ref-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.letter-ref-no {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  color: var(--primary-dark);
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.letter-field {
  background: #f8fafc;
  border-radius: 10px;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
}

.letter-field span {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.letter-field strong {
  font-size: 0.92rem;
  word-break: break-word;
}

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

.letter-section h3 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--primary-dark);
}

.letter-section p {
  font-size: 0.92rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.letter-response {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 1rem;
}

.letter-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed #cbd5e1;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.result-actions {
  margin-bottom: 1rem;
}

.loading-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--input-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.alert-success {
  background: #d1e7dd;
  color: #0f5132;
  border: 1px solid #badbcc;
}

/* Digit cells */
.digit-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.digit-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.digit-prefix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 52px;
  padding: 0 0.75rem;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.digit-cell {
  width: 44px;
  height: 52px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  text-align: center;
  font-family: 'Poppins', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  transition: all 0.2s ease;
  caret-color: var(--primary);
}

.digit-cell:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  transform: translateY(-2px);
}

.digit-cell.filled {
  border-color: var(--primary);
  background: #fff;
}

.code-cell {
  width: 46px;
  height: 54px;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.code-display {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin: 1rem 0;
}

.code-display span {
  width: 42px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 1.2rem;
  border: 1px solid #bfd7ff;
}

/* Admin layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  width: var(--sidebar-width);
  background: #1e293b;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand h2 {
  font-size: 1rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-brand p {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 0.25rem;
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  color: #cbd5e1;
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  transition: all 0.2s;
  border: none;
  background: transparent;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: rgba(37, 99, 235, 0.2);
  color: #fff;
}

.sidebar-footer {
  padding: 1rem 0.75rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 1.5rem 1.75rem 2rem;
  min-width: 0;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.admin-topbar h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 420px;
  min-width: 200px;
}

.search-box i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 2.75rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-family: inherit;
  font-size: 0.95rem;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.15rem;
  text-align: left;
  position: relative;
}

.stat-card .value {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text);
}

.complaint-item {
  background: var(--surface);
  border: 1px solid var(--border);
}

.complaint-item .item-code {
  font-family: 'Courier New', monospace;
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary-dark);
  letter-spacing: 0.08em;
}

.complaint-item .item-phone {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.88rem;
}

.complaint-card-grid {
  display: grid;
  gap: 0.75rem;
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .admin-main {
    margin-left: 0;
    padding: 1rem;
  }

  .menu-toggle {
    display: inline-flex !important;
  }

  .digit-cell {
    width: 38px;
    height: 46px;
    font-size: 1rem;
  }

  .code-cell {
    width: 38px;
    height: 46px;
  }
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-size: 1.2rem;
}
