:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #f1f4f9;
  --text: #182033;
  --muted: #647089;
  --line: #dfe5ee;
  --primary: #174ea6;
  --primary-dark: #0d2f68;
  --accent: #00a6a6;
  --danger: #b42318;
  --warning: #a15c00;
  --success: #0f7b45;
  --shadow: 0 18px 60px rgba(18, 31, 53, 0.10);
  --radius: 22px;

  --status-warning-bg: #fff4df;
  --status-success-bg: #e9fbf2;
  --status-danger-bg: #fff1f0;
  --sidebar-bg: #ffffff;
  --topbar-bg: rgba(246, 247, 251, 0.84);
  --auth-gradient-start: #f8fbff;
  --auth-gradient-end: #eef3fb;
  --card-bg: rgba(255, 255, 255, 0.86);
  --card-border: rgba(223, 229, 238, 0.92);
}

[data-theme="dark"] {
  --bg: #0b0f19;
  --surface: #111827;
  --surface-soft: #1a2332;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --line: #1f2937;
  --primary: #3b82f6;
  --primary-dark: #1d4ed8;
  --accent: #2dd4bf;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);

  --status-warning-bg: rgba(245, 158, 11, 0.12);
  --status-success-bg: rgba(34, 197, 94, 0.12);
  --status-danger-bg: rgba(239, 68, 68, 0.12);
  --sidebar-bg: var(--surface);
  --topbar-bg: rgba(17, 24, 39, 0.84);
  --auth-gradient-start: #111827;
  --auth-gradient-end: #0b0f19;
  --card-bg: rgba(26, 35, 50, 0.86);
  --card-border: rgba(31, 41, 55, 0.92);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 42px;
  align-items: center;
  padding: 48px;
  background:
    radial-gradient(circle at 10% 10%, rgba(0, 166, 166, 0.15), transparent 32%),
    linear-gradient(135deg, var(--auth-gradient-start) 0%, var(--auth-gradient-end) 100%);
}

.auth-hero {
  max-width: 760px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.auth-hero h1 {
  margin: 14px 0;
  font-size: clamp(2.4rem, 5vw, 5.4rem);
  line-height: 0.96;
  letter-spacing: -0.07em;
}

.auth-hero p {
  margin: 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 34px;
}

.hero-grid div,
.metric-card,
.card,
.table-card,
.auth-panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-grid div {
  padding: 20px;
}

.hero-grid strong {
  display: block;
  margin-bottom: 6px;
}

.hero-grid span,
.small-note,
.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.auth-panel {
  width: min(100%, 480px);
  justify-self: center;
  padding: 30px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--surface);
  font-weight: 900;
  letter-spacing: -0.04em;
  margin-bottom: 22px;
}

.brand-mark.small {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  margin: 0;
  flex: 0 0 auto;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  background: var(--surface-soft);
  border-radius: 16px;
  margin-bottom: 22px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px 14px;
  border-radius: 13px;
  font-weight: 700;
}

.tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 8px 20px var(--line);
}

.auth-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 15px;
  padding: 13px 14px;
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(23, 78, 166, 0.55);
  box-shadow: 0 0 0 4px rgba(23, 78, 166, 0.10);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn {
  border: 0;
  border-radius: 15px;
  padding: 12px 16px;
  font-weight: 800;
}

.primary-btn {
  background: var(--primary);
  color: var(--surface);
}

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

.secondary-btn {
  background: rgba(59, 130, 246, 0.10);
  color: var(--primary);
}

.ghost-btn {
  background: var(--surface-soft);
  color: var(--text);
}

.danger-btn {
  background: var(--status-danger-bg);
  color: var(--danger);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 290px 1fr;
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.sidebar-head strong,
.sidebar-head span {
  display: block;
}

.sidebar-head span {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--muted);
  font-weight: 800;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(59, 130, 246, 0.10);
  color: var(--primary);
}

.sidebar .ghost-btn {
  margin-top: auto;
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 112px;
  background: var(--topbar-bg);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
  padding: 24px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h2 {
  margin: 8px 0 0;
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.user-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: 0 10px 30px var(--shadow);
  font-size: 0.9rem;
  font-weight: 800;
}

.content {
  padding: 34px;
  display: grid;
  gap: 24px;
}

.grid-2,
.grid-3,
.form-grid {
  display: grid;
  gap: 18px;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }

.card,
.metric-card,
.table-card {
  padding: 22px;
}

.metric-card strong {
  display: block;
  font-size: 2.3rem;
  letter-spacing: -0.06em;
  margin-top: 6px;
}

.card h3,
.table-card h3 {
  margin: 0 0 16px;
  letter-spacing: -0.03em;
}

.action-row,
.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Responsive text utilities */
.text-2xl {
  display: block;
  font-size: 2.4rem;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.text-xl {
  display: block;
  font-size: 1.8rem;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.text-lg {
  display: block;
  font-size: 1.6rem;
  letter-spacing: -0.03em;
}

.text-md {
  display: block;
  font-size: 1.4rem;
  margin-top: 4px;
}

.label-muted {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  text-align: left;
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 900;
}

.status.open,
.status.pending {
  color: var(--warning);
  background: var(--status-warning-bg);
}

.status.closed,
.status.approved,
.status.active {
  color: var(--success);
  background: var(--status-success-bg);
}

.status.rejected,
.status.inactive {
  color: var(--danger);
  background: var(--status-danger-bg);
}

.copy-box {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px dashed var(--line);
  word-break: break-all;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  width: min(100%, 520px);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h3 {
  margin: 0 0 6px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 420px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-weight: 700;
}

.mobile-only {
  display: none !important;
}

.notif-dropdown {
  position: fixed;
  top: 70px;
  right: 24px;
  z-index: 25;
  width: min(100%, 360px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 70vh;
  overflow-y: auto;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
}

.sidebar-close {
  display: none;
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.4rem;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
}

@media (max-width: 980px) {
  .auth-screen {
    grid-template-columns: 1fr;
    padding: 18px;
    gap: 24px;
  }
  .auth-hero h1 {
    font-size: clamp(1.8rem, 6vw, 2.8rem);
  }
  .hero-grid,
  .grid-2,
  .grid-3,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 260ms ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close {
    display: grid;
    place-items: center;
  }
  .mobile-only {
    display: grid !important;
  }
  .topbar {
    min-height: 72px;
    padding: 14px 18px;
    position: sticky;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar h2 {
    font-size: 1.4rem;
  }
  .content {
    padding: 14px;
    gap: 14px;
    min-width: 0;
    overflow-x: hidden;
  }
  .card,
  .metric-card,
  .table-card {
    padding: 14px;
    word-break: break-word;
    min-width: 0;
  }
  .metric-card strong {
    font-size: 1.6rem;
  }
  .text-2xl {
    font-size: 1.6rem;
  }
  .text-xl {
    font-size: 1.4rem;
  }
  .text-lg {
    font-size: 1.3rem;
  }
  .text-md {
    font-size: 1.1rem;
  }
  .table-wrap {
    margin: 0 -14px;
    padding: 0 14px;
  }
  table {
    min-width: 520px;
    font-size: 0.82rem;
  }
  th,
  td {
    padding: 8px 6px;
    white-space: nowrap;
  }
  .modal-overlay {
    padding: 8px;
  }
  .modal-content {
    padding: 16px;
    width: 100%;
    border-radius: 16px;
  }
  .modal-content .grid-2,
  .modal-content .grid-3 {
    grid-template-columns: 1fr;
  }
  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    max-width: none;
    font-size: 0.9rem;
  }
  .user-chip {
    font-size: 0.78rem;
    padding: 8px 10px;
  }
  .notif-dropdown {
    top: 64px;
    right: 8px;
    left: 8px;
    width: auto;
    max-height: 80vh;
    border-radius: 18px;
  }
  input,
  select,
  textarea {
    padding: 11px 12px;
  }
  .eyebrow {
    font-size: 0.7rem;
  }
  .topbar h2 {
    font-size: 1.3rem;
    margin-top: 4px;
  }
  .card h3,
  .table-card h3 {
    font-size: 1.05rem;
    margin-bottom: 12px;
  }
}
