/* ============================================================
   Mimico Cong Letter Writing Territory — Global Stylesheet
   ============================================================ */

/* --- Reset & Base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Eliminate 300ms tap delay on mobile for interactive elements */
a, button, [role="button"], input, select, textarea, label {
  touch-action: manipulation;
}

:root {
  --navy:        #0f172a;
  --navy-light:  #1e293b;
  --navy-muted:  #334155;
  --gold:        #10b981;
  --gold-light:  #34d399;
  --gold-dim:    rgba(16,185,129,.18);
  --accent:      #10b981;
  --accent-dark: #059669;
  --accent-soft: rgba(16,185,129,.08);
  --bg:          #f1f5f9;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --border:      #e2e8f0;
  --border-soft: #f1f5f9;
  --text:        #0f172a;
  --muted:       #64748b;
  --muted-light: #94a3b8;
  --success:     #10b981;
  --success-soft:rgba(16,185,129,.10);
  --warning:     #f59e0b;
  --warning-soft:rgba(245,158,11,.10);
  --danger:      #ef4444;
  --danger-soft: rgba(239,68,68,.10);
  --info:        #3b82f6;
  --info-soft:   rgba(59,130,246,.10);
  --radius-xs:   3px;
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --shadow-xs:   0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:   0 1px 4px rgba(0,0,0,.08);
  --shadow:      0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.14);
  --shadow-xl:   0 16px 48px rgba(0,0,0,.18);
  --transition:  all .18s ease;
  --transition-slow: all .3s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   SITE HEADER
   ============================================================ */
.site-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 60%, #1e3a5f 100%);
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 4px 24px rgba(0,0,0,.28);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* Brand / logo area */
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo-mark {
  font-size: 22px;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(201,168,76,.4);
  flex-shrink: 0;
}

.header-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.header-org {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .01em;
}

.header-sub {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--gold-light);
  letter-spacing: .07em;
  text-transform: uppercase;
}

/* Navigation */
.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  color: rgba(255,255,255,.78);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
}

.nav-link:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

.nav-link.active {
  background: rgba(255,255,255,.16);
  color: #fff;
  font-weight: 600;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--gold-light);
  border-radius: 2px;
}

.nav-sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,.16);
  margin: 0 6px;
  flex-shrink: 0;
}

.nav-user-info {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
}

.nav-user-name {
  font-size: 13px;
  color: rgba(255,255,255,.80);
  font-weight: 500;
}

.nav-role-badge {
  background: var(--gold-dim);
  color: var(--gold-light);
  border: 1px solid rgba(201,168,76,.35);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
}

.nav-logout {
  background: rgba(220,38,38,.16);
  color: #fca5a5;
  border: 1px solid rgba(220,38,38,.24);
  margin-left: 2px;
}

.nav-logout:hover {
  background: rgba(220,38,38,.30);
  color: #fff;
  border-color: rgba(220,38,38,.45);
}

/* Mobile hamburger */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  box-shadow: none;
}

.nav-toggle:hover { background: rgba(255,255,255,.12); box-shadow: none; transform: none; }
.nav-toggle svg { display: block; }

/* ============================================================
   PAGE CONTENT WRAPPER
   ============================================================ */
.page-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 28px 56px;
}

.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 19px;
  font-weight: 600;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -.01em;
}

.page-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 22px;
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-light) 100%);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ============================================================
   STAT CARDS (Dashboard KPIs)
   ============================================================ */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

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

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.total  { background: var(--accent-soft); }
.stat-icon.avail  { background: var(--success-soft); }
.stat-icon.out    { background: var(--warning-soft); }
.stat-icon.over   { background: var(--danger-soft); }

.stat-body {}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  letter-spacing: -.02em;
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 3px;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-search {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.filter-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-light);
  pointer-events: none;
  font-size: 15px;
}

.filter-search input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: var(--transition);
  outline: none;
}

.filter-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-count {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.filter-per-page {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.filter-per-page label {
  margin-bottom: 0 !important;
  font-weight: 500 !important;
  color: var(--muted) !important;
  font-size: 12.5px !important;
}

.per-page-select {
  padding: 6px 28px 6px 10px !important;
  margin-top: 0 !important;
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  font-size: 12.5px !important;
  font-family: inherit !important;
  color: var(--text) !important;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 8px center !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  width: auto !important;
  display: inline-block !important;
}

.per-page-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-soft) !important;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #0f1f45 50%, #1e3a5f 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(201,168,76,.12) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(37,99,235,.14) 0%, transparent 50%);
  pointer-events: none;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-xl);
  border-top: 4px solid var(--gold);
  position: relative;
  z-index: 1;
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 14px;
  box-shadow: 0 4px 16px rgba(201,168,76,.35);
}

.login-brand h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 4px;
  letter-spacing: .01em;
}

.login-brand p {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 500;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 32px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
}

.form-section h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 20px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -.005em;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 5px;
  letter-spacing: .005em;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

/* Legacy form styles (for inline label+input on existing pages) */
form label {
  display: block;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="date"],
form input[type="file"],
form select,
form textarea {
  display: block;
  width: 100%;
  padding: 9px 13px;
  margin-top: 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  transition: var(--transition);
  outline: none;
}

form input:focus,
form select:focus,
form textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

form textarea { resize: vertical; }

/* Password wrapper */
.pw-wrapper {
  position: relative;
  margin-top: 6px;
}

.pw-wrapper input {
  margin-top: 0 !important;
  padding-right: 42px !important;
}

.pw-toggle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 40px;
  background: none;
  border: none;
  box-shadow: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: var(--transition);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.pw-toggle:hover {
  color: var(--accent);
  background: none;
  box-shadow: none;
  transform: none;
}

/* Checkbox row */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 16px;
}

.checkbox-row input[type="checkbox"] {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* Login fields panel */
.login-fields-panel {
  border-left: 3px solid var(--gold);
  padding: 16px 16px 2px;
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 16px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: .01em;
  transition: var(--transition);
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(37,99,235,.22);
  text-decoration: none;
}

button:hover, .btn:hover {
  filter: brightness(1.09);
  box-shadow: 0 4px 14px rgba(37,99,235,.30);
  transform: translateY(-1px);
}

button:active, .btn:active {
  transform: translateY(0);
  filter: brightness(1);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12.5px;
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #b91c1c 100%);
  box-shadow: 0 2px 6px rgba(220,38,38,.20);
}

.btn-danger:hover { box-shadow: 0 4px 14px rgba(220,38,38,.30); }

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #15803d 100%);
  box-shadow: 0 2px 6px rgba(22,163,74,.20);
}

.btn-success:hover { box-shadow: 0 4px 14px rgba(22,163,74,.30); }

.btn-warning {
  background: linear-gradient(135deg, var(--warning) 0%, #b45309 100%);
  box-shadow: 0 2px 6px rgba(217,119,6,.20);
}

.btn-warning:hover { box-shadow: 0 4px 14px rgba(217,119,6,.30); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: #c8cdd9;
  box-shadow: var(--shadow-sm);
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 11px 18px;
}

/* ============================================================
   FLASH MESSAGES & ALERTS
   ============================================================ */
.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 20px;
  padding: 13px 16px;
  background: #dbeafe;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  color: #1e3a8a;
  font-size: 14px;
  font-weight: 500;
  animation: flashIn .25s ease;
}

.flash-icon { font-size: 16px; flex-shrink: 0; line-height: 1.4; }

.flash > span:nth-child(2) { flex: 1; }

/* Dismiss (✕) button inside flash messages */
.flash-close {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0 2px;
  margin-left: auto;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: currentColor;
  opacity: .5;
  flex-shrink: 0;
  align-self: center;
  transition: opacity .15s ease;
}
.flash-close:hover { opacity: 1; background: none; box-shadow: none; transform: none; }

.flash-success {
  background: #dcfce7;
  border-color: var(--success);
  color: #14532d;
}

.flash-error {
  background: #fee2e2;
  border-color: var(--danger);
  color: #7f1d1d;
}

.flash-warning {
  background: #fef3c7;
  border-color: var(--warning);
  color: #78350f;
}

@keyframes flashIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   DATA TABLE
   ============================================================ */
.table-wrapper {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  overflow-x: auto;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
}

.doc-table thead tr {
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-light) 100%);
}

.doc-table th {
  padding: 12px 15px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.80);
  white-space: nowrap;
}

.doc-table td {
  padding: 11px 15px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  vertical-align: middle;
}

.doc-table tbody tr:last-child td { border-bottom: none; }

.doc-table tbody tr {
  transition: background .12s ease;
}

.doc-table tbody tr:hover { background: #f5f8ff; }

.doc-table tbody tr.hidden-row { display: none; }

.doc-table td a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.doc-table td a:hover { text-decoration: underline; }

.td-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* Pagination Footer */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 1px solid var(--border-soft);
  border-radius: 0 0 var(--radius) var(--radius);
  margin-top: -1px;
  gap: 12px;
  flex-wrap: wrap;
}

/* Match table rounded corners when pagination is appended right after wrapper */
.table-wrapper {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.pagination-info {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: none;
  user-select: none;
}

.pg-btn:hover:not(.disabled):not(.active) {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--accent);
  transform: none;
  box-shadow: none;
}

.pg-btn.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(37,99,235,.22);
}

.pg-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--surface-2);
  border-color: var(--border-soft);
}

.pg-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 32px;
  font-size: 13px;
  color: var(--muted-light);
  user-select: none;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-xl);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-green  { background: var(--success-soft); color: #15803d; border: 1px solid rgba(22,163,74,.25); }
.badge-yellow { background: var(--warning-soft); color: #92400e; border: 1px solid rgba(217,119,6,.25); }
.badge-red    { background: var(--danger-soft);  color: #b91c1c; border: 1px solid rgba(220,38,38,.25); }
.badge-gray   { background: #f3f4f6; color: #6b7280; border: 1px solid #e5e7eb; }
.badge-blue   { background: var(--info-soft);   color: #0369a1; border: 1px solid rgba(8,145,178,.25); }

/* ============================================================
   BACK LINK
   ============================================================ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  transition: var(--transition);
  padding: 5px 0;
}

.back-link:hover { color: var(--accent); gap: 8px; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px dashed var(--border);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 14px;
  display: block;
  opacity: .5;
}

.empty-state-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 13.5px;
  color: var(--muted);
  max-width: 320px;
  margin: 0 auto;
}

/* ============================================================
   DRAG & DROP UPLOAD ZONE
   ============================================================ */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  background: var(--surface-2);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
}

.drop-zone-icon { font-size: 36px; display: block; margin-bottom: 10px; }
.drop-zone-title { font-size: 14px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.drop-zone-sub { font-size: 12.5px; color: var(--muted); }
.drop-zone-filename { font-size: 13px; font-weight: 600; color: var(--accent); margin-top: 8px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,25,60,.55);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 24px;
}

.modal.is-open { display: flex; }

.modal-content {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-xl);
  border-top: 4px solid var(--gold);
  animation: modalIn .22s ease;
  position: relative;
}

.modal-content.modal-danger { border-top-color: var(--danger); }

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 7px;
  letter-spacing: -.01em;
}

.modal-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

@keyframes modalIn {
  from { transform: translateY(-20px) scale(.97); opacity: 0; }
  to   { transform: translateY(0) scale(1);       opacity: 1; }
}

/* ============================================================
   SECTION HEADER (for sub-sections within a page)
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -.01em;
}

/* ============================================================
   MISC HELPERS
   ============================================================ */
h1, h2, h3 { color: var(--navy); font-weight: 600; }

.text-muted { color: var(--muted); font-size: 13px; }
.text-sm    { font-size: 12.5px; }

.territory-no {
  font-weight: 700;
  font-size: 13px;
  color: var(--navy-muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   RESPONSIVE — Comprehensive Multi-Breakpoint System
   ============================================================ */

/* ── Tablet (≤ 900px) ─────────────────────────────────────── */
@media (max-width: 900px) {
  .page-content {
    padding: 24px 20px 48px;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .form-section {
    padding: 22px 20px;
  }
}

/* ── Mobile Landscape / Small Tablet (≤ 768px) ──────────────── */
@media (max-width: 768px) {
  /* Header */
  .header-inner {
    padding: 0 14px;
    min-height: 58px;
    flex-wrap: nowrap;
  }

  .header-org { font-size: 14px; }
  .header-sub { display: none; }
  .header-logo-mark { width: 38px; height: 38px; font-size: 18px; }

  /* Mobile nav drawer */
  .header-nav {
    display: none;
    position: fixed;
    top: 61px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--navy);
    border-top: 2px solid var(--gold);
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 12px 10px 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
    z-index: 190;
    overflow-y: auto;
  }

  .header-nav.nav-open {
    display: flex;
    animation: navSlideIn .22s ease;
  }

  @keyframes navSlideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .nav-link {
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
  }

  .nav-sep { display: none; }

  .nav-user-info {
    padding: 12px 16px 6px;
    border-top: 1px solid rgba(255,255,255,.14);
    margin-top: 8px;
  }

  .nav-user-name { font-size: 14px; }

  .nav-logout {
    margin-left: 0;
    margin-top: 4px;
  }

  .nav-toggle { display: flex; }

  /* Page layout */
  .page-content {
    padding: 18px 14px 40px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .page-title { font-size: 18px; }

  /* Stat cards */
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 18px;
  }

  .stat-card { padding: 14px 14px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; font-size: 17px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11px; }

  /* Filter bar */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .filter-search { min-width: unset; }
  .filter-count  { text-align: right; }

  /* Forms */
  .form-section {
    padding: 18px 14px;
    margin-bottom: 18px;
  }

  .form-section[style*="max-width"] {
    max-width: 100% !important;
  }

  /* ── Mobile Table → Card Transformation ──────────────── */
  .doc-table { display: block; }

  .doc-table thead {
    display: none; /* Hide headers; labels shown via data-label */
  }

  .doc-table tbody { display: block; }

  .doc-table tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    padding: 14px 14px 10px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .15s ease;
  }

  .doc-table tbody tr:hover {
    box-shadow: var(--shadow-sm);
    background: var(--surface);
  }

  .doc-table tbody tr.hidden-row { display: none; }

  .doc-table tbody td {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 5px 0;
    font-size: 13.5px;
    border-bottom: none;
    min-height: 28px;
  }

  /* Hide completely empty cells on mobile (e.g. —-only cells) */
  .doc-table tbody td:empty { display: none; }

  .doc-table tbody td::before {
    content: attr(data-label);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted-light);
    min-width: 84px;
    flex-shrink: 0;
    padding-top: 2px;
  }

  /* Cells that have no label (actions, primary ID) */
  .doc-table tbody td[data-label=""] {
    font-weight: 700;
    color: var(--navy);
    font-size: 14.5px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 4px;
  }

  .doc-table tbody td[data-label=""]::before {
    display: none;
  }

  /* Actions cell — full width */
  .doc-table tbody td:last-child {
    padding-top: 10px;
    border-top: 1px solid var(--border-soft);
    margin-top: 4px;
  }

  .doc-table tbody td:last-child::before {
    display: none;
  }

  .td-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .td-actions .btn {
    flex: 1;
    justify-content: center;
    min-width: 90px;
  }

  /* Table wrapper — remove overflow on mobile (cards handle it) */
  .table-wrapper {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
  }

  /* Modals */
  .modal {
    padding: 12px;
    align-items: flex-end; /* slide up from bottom on mobile */
  }

  .modal-content {
    padding: 22px 18px 18px;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius) var(--radius);
    animation: modalSlideUp .24s ease;
  }

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

  .modal-actions {
    flex-direction: column;
    gap: 8px;
  }

  .modal-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Login */
  .login-card {
    padding: 28px 18px 24px;
  }

  /* Section header */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  /* Buttons */
  .btn { font-size: 13px; }

  /* Back link */
  .back-link { margin-bottom: 14px; }

  /* SMTP two-column row → single column */
  .smtp-row {
    flex-direction: column !important;
    gap: 0 !important;
  }
}

/* ── Mobile Portrait (≤ 480px) ──────────────────────────────── */
@media (max-width: 480px) {
  .header-org { font-size: 13px; }

  .page-content { padding: 14px 12px 36px; }

  .stats-bar {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card { padding: 12px 10px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 10px; }

  .page-title { font-size: 16px; }
  .page-title::before { height: 20px; }

  /* Stack stat cards single column on very small screens */
  @media (max-width: 360px) {
    .stats-bar { grid-template-columns: 1fr; }
  }

  .login-card { padding: 22px 14px; }
  .login-logo { width: 50px; height: 50px; font-size: 22px; }

  .filter-search input { font-size: 13px; }

  .form-section { padding: 16px 12px; }
  .form-section h2 { font-size: 14px; }

  .doc-table tbody td { font-size: 13px; }
  .doc-table tbody td::before { min-width: 74px; font-size: 10px; }

  /* Badges wrap gracefully */
  .badge { font-size: 10px; padding: 2px 7px; }

  /* Wider btn touch target */
  .btn, button { min-height: 40px; }
  .btn-sm { min-height: 34px; padding: 5px 10px; }

  .modal-content { padding: 18px 14px; }
  .modal-title { font-size: 15px; }

  .empty-state { padding: 40px 16px; }
  .empty-state-icon { font-size: 38px; }
  .empty-state-title { font-size: 15px; }
}

/* ── Very Small (≤ 360px) ───────────────────────────────────── */
@media (max-width: 360px) {
  .stats-bar { grid-template-columns: 1fr; }
  .header-brand { gap: 8px; }
  .header-logo-mark { width: 32px; height: 32px; font-size: 15px; }
}

/* ============================================================
   STATS CHART CARD
   ============================================================ */
.stats-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.stats-chart-card:hover {
  box-shadow: var(--shadow);
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
  gap: 10px;
}

.chart-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -.01em;
}

.chart-badge {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(37,99,235,.2);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: .02em;
}

.chart-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 36px;
  align-items: center;
}

@media (max-width: 768px) {
  .chart-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

.chart-visual-wrapper {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

.chart-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}

.chart-slice {
  fill: none;
  stroke-width: 20;
  cursor: pointer;
  transition: stroke-width .22s ease, filter .22s ease, opacity .22s ease, stroke-dashoffset .6s ease, stroke-dasharray .6s ease;
}

.chart-slice:hover,
.chart-slice.is-highlighted {
  stroke-width: 25;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.20));
}

.chart-slice-ontime { stroke: #2563eb; }
.chart-slice-overdue { stroke: #dc2626; }
.chart-slice-avail { stroke: #c9a84c; }
.chart-slice-empty { stroke: #e5e7eb; }

.chart-center-info {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  padding: 16px;
}

.chart-center-val {
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
  letter-spacing: -.02em;
  transition: color .2s ease;
}

.chart-center-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 3px;
}

.chart-center-sub {
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 600;
  margin-top: 2px;
}

/* Legend & breakdown bars */
.chart-legend-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.legend-item-group {
  background: var(--surface-2);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  transition: var(--transition);
  cursor: pointer;
}

.legend-item-group:hover,
.legend-item-group.is-hovered {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(37,99,235,.08);
}

.legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.legend-title-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.dot-out { background: #2563eb; }
.legend-dot.dot-ontime { background: #2563eb; }
.legend-dot.dot-overdue { background: #dc2626; }
.legend-dot.dot-avail { background: #c9a84c; }

.legend-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.legend-stats {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-pct {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.progress-track {
  height: 8px;
  background: rgba(0,0,0,.06);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}

.progress-fill {
  height: 100%;
  transition: width .6s ease;
}

.progress-fill.fill-ontime { background: #2563eb; }
.progress-fill.fill-out { background: #2563eb; }
.progress-fill.fill-overdue { background: #dc2626; }
.progress-fill.fill-avail { background: #c9a84c; }

.legend-sub-details {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px stroke var(--border-soft);
  font-size: 12px;
  flex-wrap: wrap;
}

.sub-detail-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.sub-detail-item strong {
  color: var(--text);
  font-weight: 700;
}
