:root {
  --ink: #101218;
  --muted: #667085;
  --paper: #f3f4f7;
  --card: #ffffff;
  --line: #e6e8ee;
  --ember: #e85d2c;
  --ember-dark: #c94a1e;
  --terra: var(--ember);
  --terra-dark: var(--ember-dark);
  --good: #0f9d6e;
  --forest: var(--good);
  --warn: #f5a524;
  --bad: #e11d48;
  --sidebar: #12151c;
  --sidebar-text: #c5cad3;
  --shadow: 0 1px 2px rgba(16, 18, 24, 0.05), 0 10px 28px rgba(16, 18, 24, 0.05);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Outfit, "Segoe UI", system-ui, sans-serif;
  letter-spacing: -0.011em;
}

h1,
h2,
h3,
.brand-kicker {
  font-family: inherit;
  letter-spacing: -0.03em;
}

h2 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 600;
}

h3 {
  margin: 0 0 8px;
  font-weight: 600;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

aside {
  padding: 28px 20px;
  background: var(--sidebar);
  color: #f7f8fa;
}

.brand-kicker {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  color: var(--ember);
}

.brand-line {
  display: flex;
  flex-direction: column;
}

aside h1 {
  margin: 4px 0 0;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
  color: #fff;
}

.brand-copy {
  color: #8b93a1;
  line-height: 1.45;
  font-size: 13px;
  margin: 10px 0 0;
}

nav {
  display: grid;
  gap: 4px;
  margin: 28px 0 20px;
}

nav button,
.btn,
.btn-ghost {
  border: 0;
  cursor: pointer;
  font: inherit;
}

nav button {
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  color: var(--sidebar-text);
  font-weight: 500;
}

nav button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

nav button.active {
  background: var(--ember);
  color: #fff;
}

.aside-status {
  font-size: 13px;
  color: #8b93a1;
  display: grid;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  background: #4a5160;
}

.dot.on {
  background: #22c55e;
}

.dot.warn {
  background: var(--warn);
}

main {
  padding: 28px 32px 56px;
  min-width: 0;
}

.hidden {
  display: none !important;
}

.hero,
.card,
.table-wrap,
form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero,
.card,
form {
  padding: 18px 20px;
}

.hero {
  background:
    linear-gradient(135deg, #1a1e27 0%, #12151c 70%),
    var(--sidebar);
  color: #fff;
  border: 0;
}

.hero .brand-kicker {
  color: #ffb089;
}

.hero h2 {
  color: #fff;
  margin: 4px 0 6px;
}

.hero p {
  margin: 0;
  color: #b4bac6;
  font-size: 14px;
}

.grid {
  display: grid;
  gap: 14px;
}

.stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 18px 0 24px;
}

.stat h3 {
  margin: 0;
  font-size: clamp(1.45rem, 4vw, 1.9rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.btn {
  background: var(--ember);
  color: white;
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 40px;
  font-weight: 600;
}

.btn:hover {
  background: var(--ember-dark);
}

.btn-ghost {
  background: #eef0f4;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 40px;
  font-weight: 600;
}

.btn-ghost:hover {
  background: #e4e7ed;
}

.btn.small,
.btn-ghost.small {
  padding: 7px 11px;
  min-height: 34px;
  font-size: 13px;
}

.people {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef0f4;
  color: #3f4654;
  white-space: nowrap;
}

.badge.in {
  background: #dcfce7;
  color: #166534;
}

.badge.out {
  background: #ffe8df;
  color: #9a3412;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

input,
select {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  width: 100%;
  max-width: 100%;
}

input:focus,
select:focus {
  outline: 2px solid rgba(232, 93, 44, 0.28);
  border-color: var(--ember);
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.enroll-banner {
  margin: 0 0 18px;
  padding: 16px 18px;
  border-radius: 14px;
  background: #fff4ee;
  border: 1px solid #ffd4c2;
}

.enroll-banner strong {
  display: block;
  font-size: 1.05rem;
}

.enroll-banner p {
  margin: 6px 0 0;
}

.enroll-banner.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.enroll-banner.bad {
  border-color: #fecdd3;
  background: #fff1f2;
}

#toast {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  left: auto;
  max-width: min(420px, calc(100vw - 32px));
  background: var(--ink);
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  z-index: 40;
  font-weight: 500;
}

.qr {
  width: min(220px, 70vw);
  height: auto;
  aspect-ratio: 1;
  background: white;
  border-radius: 16px;
  margin-top: 12px;
}

.empty {
  color: var(--muted);
  padding: 8px 0;
}

.money.pos {
  color: var(--good);
  font-weight: 600;
}

.money.neg {
  color: var(--bad);
  font-weight: 600;
}

.phone-only {
  display: none;
}

.line-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.line-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.line-card .meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.line-card .actions {
  margin-top: 8px;
}

.section-title {
  margin: 16px 0 8px;
}

.emp-edit {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.emp-edit label {
  font-size: 12px;
}

.emp-edit select,
.emp-edit .salary-input {
  max-width: none;
  margin-top: 4px;
}

@media print {
  aside,
  nav,
  .actions,
  form {
    display: none !important;
  }

  .app {
    grid-template-columns: 1fr;
  }

  .hero {
    background: #fff;
    color: #000;
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  aside {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px 12px 8px;
    padding-top: max(10px, env(safe-area-inset-top));
    border-right: 0;
  }

  .brand-line {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
  }

  .brand-kicker {
    font-size: 10px;
    letter-spacing: 0.12em;
  }

  aside h1 {
    font-size: 17px;
    margin: 0;
    font-weight: 600;
  }

  .help-desk,
  .desk-only {
    display: none !important;
  }

  .phone-only {
    display: block;
  }

  .brand-copy {
    display: none;
  }

  nav {
    display: flex;
    gap: 6px;
    margin: 10px 0 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  nav::-webkit-scrollbar {
    display: none;
  }

  nav button {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #d5d9e1;
  }

  nav button.active {
    background: var(--ember);
    color: #fff;
    box-shadow: none;
  }

  .aside-status {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: 11px;
    color: #8b93a1;
  }

  main {
    padding: 12px 12px 32px;
  }

  h2 {
    font-size: 1.2rem;
    margin: 0 0 4px;
  }

  h3 {
    font-size: 1rem;
    margin: 0 0 6px;
  }

  .hero,
  .card,
  form {
    padding: 14px;
    border-radius: 12px;
  }

  .hero h2 {
    font-size: 1.25rem;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0 14px;
  }

  .stat h3 {
    font-size: 1.2rem;
  }

  .stat p {
    font-size: 11px;
    margin: 2px 0 0;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .people {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .row {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .btn,
  .btn-ghost {
    padding: 7px 12px;
    min-height: 34px;
    font-size: 13px;
  }

  .btn.small,
  .btn-ghost.small {
    padding: 6px 10px;
    min-height: 32px;
    font-size: 12px;
  }

  .badge {
    font-size: 11px;
    padding: 3px 8px;
  }

  .empty {
    font-size: 12px;
    padding: 4px 0;
    line-height: 1.35;
  }

  .enroll-banner {
    padding: 10px 12px;
    margin: 0 0 10px;
    border-radius: 12px;
  }

  .enroll-banner strong {
    font-size: 0.95rem;
  }

  input,
  select {
    padding: 9px 10px;
  }

  #toast {
    left: 10px;
    right: 10px;
    max-width: none;
    padding: 10px 12px;
    font-size: 13px;
  }

  .qr {
    width: 160px;
  }
}

@media (max-width: 720px) {
  .stack-table thead {
    display: none;
  }

  .stack-table tbody tr {
    display: grid;
    gap: 5px;
    padding: 10px;
  }

  .stack-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 0;
    border: 0;
    font-size: 13px;
  }

  .stack-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    flex: 0 0 30%;
  }

  .stack-table td.actions {
    justify-content: flex-start;
  }

  .stack-table td.actions::before,
  .stack-table td.empty::before {
    display: none;
  }

  .stack-table td.empty {
    display: block;
  }
}
