:root {
  --bg: #07090d;
  --bg-2: #0c1016;
  --surface: #121820;
  --surface-2: #18212c;
  --line: rgba(255,255,255,.08);
  --text: #eef3f8;
  --muted: #8b9cb3;
  --accent: #5eead4;
  --accent-2: #2dd4bf;
  --gold: #fbbf24;
  --ok: #34d399;
  --warn: #f59e0b;
  --danger: #f87171;
  --night: #818cf8;
  --leave: #38bdf8;
  --h12: #2dd4bf;
  --h24: #fb923c;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; max-width: 100%; }
body {
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(94,234,212,.12), transparent 50%),
    radial-gradient(900px 500px at 110% 0%, rgba(251,191,36,.08), transparent 45%),
    var(--bg);
  color: var(--text);
  letter-spacing: .01em;
}
a { color: var(--accent); text-decoration: none; }
h1,h2,h3 { margin: 0 0 .6rem; font-weight: 600; }
.muted { color: var(--muted); }
.mono, .kpi b, table .num { font-family: "IBM Plex Mono", ui-monospace, monospace; }

.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #0e141c, #0a0e14);
  border-right: 1px solid var(--line);
  padding: 1.1rem .9rem 5rem;
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.brand { display: flex; gap: .75rem; align-items: center; color: var(--text); margin-bottom: 1.2rem; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #5eead4, #0ea5e9); color: #042f2e; font-weight: 700;
}
.brand small { display: block; color: var(--muted); font-size: .75rem; }
.side-nav { display: flex; flex-direction: column; gap: .15rem; }
.side-nav a {
  color: var(--muted); padding: .48rem .7rem; border-radius: 10px; font-size: .92rem;
}
.side-nav a:hover, .side-nav a.active { background: var(--surface-2); color: var(--text); }
.side-nav a.active { box-shadow: inset 2px 0 0 var(--accent); }
.side-nav b {
  background: var(--danger); color: #111; border-radius: 99px; padding: 0 .35rem; font-size: .7rem;
}
.side-logout { margin-top: 1rem; }
.side-logout button, .btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 12px; padding: .55rem .9rem; cursor: pointer; font: inherit;
}
.btn.primary { background: linear-gradient(135deg, #2dd4bf, #14b8a6); color: #042f2e; border: 0; font-weight: 600; }
.btn.danger { background: #7f1d1d; border-color: #991b1b; }
.btn:hover { filter: brightness(1.08); }

.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(7,9,13,.86);
  backdrop-filter: blur(16px); z-index: 5;
}
.top-meta h1 { margin: 0; font-size: 1.15rem; }
.top-actions { margin-left: auto; display: flex; gap: .7rem; align-items: center; }
.who { color: var(--muted); font-size: .9rem; }
.top-meta { min-width: 0; }
.top-meta h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill {
  display: inline-block; margin-top: .2rem; font-size: .75rem; color: var(--accent);
  border: 1px solid rgba(94,234,212,.25); padding: .1rem .5rem; border-radius: 99px;
  max-width: min(100%, 16rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pill.warn { color: var(--warn); border-color: rgba(245,158,11,.3); }
.content { padding: 1.1rem 1.25rem 6rem; }
.page { display: grid; gap: 1rem; }
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent 40%), var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.stack { display: grid; gap: .7rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .8rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .85rem .95rem;
}
.kpi span { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.kpi b { display: block; font-size: 1.25rem; margin-top: .25rem; }
.kpi.gold b { color: var(--gold); }
.kpi.ok b { color: var(--ok); }
.kpi.warn b { color: var(--warn); }

label { display: grid; gap: .28rem; color: var(--muted); font-size: .86rem; }
input, select, textarea {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text); border-radius: 10px;
  padding: .55rem .7rem; font: inherit; width: 100%; max-width: 100%; font-size: 16px;
}
textarea { min-height: 80px; }
.check { display: flex; align-items: center; gap: .45rem; }
.row-form { display: flex; flex-wrap: wrap; gap: .5rem; }
.row-form > * { flex: 1 1 140px; }

.table-wrap { overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.table tr:hover td { background: rgba(255,255,255,.02); }

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .4rem; }
.cal-head { color: var(--muted); font-size: .75rem; padding: .3rem; text-align: center; }
.cal-hint { margin: 0; }
.day {
  min-height: 108px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .45rem;
  cursor: pointer; display: grid; align-content: start; gap: .15rem;
  min-width: 0; overflow: hidden;
}
.day:hover { border-color: rgba(94,234,212,.35); }
.day.today { outline: 1px solid var(--accent); background: rgba(45,212,191,.08); }
.day.weekend { background: #10141b; }
.day.holiday { outline: 1px solid rgba(251,191,36,.35); }
.day.locked { opacity: .7; }
.day .d { color: var(--muted); font-size: .78rem; }
.chip { display: inline-block; font-size: .7rem; padding: .1rem .35rem; border-radius: 6px; margin: .12rem .12rem 0 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.h12 { background: rgba(45,212,191,.18); color: var(--h12); }
.chip.h24 { background: rgba(251,146,60,.18); color: var(--h24); }
.chip.night { background: rgba(129,140,248,.18); color: var(--night); }
.chip.leave { background: rgba(56,189,248,.16); color: var(--leave); }
.chip.absence { background: rgba(248,113,113,.16); color: var(--danger); }
.chip.callout { background: rgba(251,191,36,.16); color: var(--gold); }
.legend { display: flex; flex-wrap: wrap; gap: .5rem; color: var(--muted); font-size: .8rem; }
.lg { padding: .1rem .4rem; border-radius: 6px; border: 1px solid var(--line); }
.lg.h12 { color: var(--h12); } .lg.h24 { color: var(--h24); } .lg.night { color: var(--night); }
.lg.leave { color: var(--leave); } .lg.absence { color: var(--danger); } .lg.callout { color: var(--gold); }

.modal, .drawer {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: end center;
  z-index: 30; padding: 1rem;
}
.modal { place-items: center; }
.modal .panel, .drawer .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1rem;
  width: min(640px, 100%); max-height: 90vh; overflow: auto;
}
.drawer { place-items: end; }
.drawer .panel { width: min(520px, 100%); border-radius: 18px 18px 0 0; }
.seg { display: flex; background: var(--surface); border-radius: 10px; border: 1px solid var(--line); }
.seg button { background: none; border: 0; color: var(--muted); padding: .4rem .7rem; cursor: pointer; }
.seg button.active { color: var(--text); background: var(--surface-2); border-radius: 8px; }
.type-picks, .quick-add { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.quick-add { margin: .6rem 0 1rem; }
.type-picks button, .quick-add button {
  text-align: left; line-height: 1.25; min-height: 3rem;
}
.type-picks button small, .quick-add button small { display: block; color: var(--muted); font-weight: 400; }
.type-picks button.active { outline: 2px solid var(--accent); color: var(--text); }
.time-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.shift-row {
  display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center;
  padding: .65rem 0; border-bottom: 1px solid var(--line);
}
.shift-row .actions { display: flex; flex-wrap: wrap; gap: .3rem; }
.shift-row .actions .btn { padding: .35rem .55rem; font-size: .8rem; }
details.more { color: var(--muted); }
details.more summary { cursor: pointer; }

.alert { padding: .7rem .8rem; border-radius: 10px; }
.alert.danger { background: rgba(248,113,113,.12); color: #fecaca; }
.alert.ok { background: rgba(52,211,153,.12); color: #bbf7d0; }
[hidden] { display: none !important; }
.toast {
  position: fixed; bottom: 5.5rem; left: 50%; transform: translateX(-50%); background: #111827;
  border: 1px solid var(--line); padding: .7rem 1rem; border-radius: 12px; z-index: 50;
  pointer-events: none; max-width: min(90vw, 28rem);
}
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 1.5rem; box-shadow: var(--shadow); }
.auth-brand { margin-bottom: 1.2rem; }
.nav-toggle { display: none; }
.mobile-nav { display: none; }
.select.compact { width: auto; }
.today-card { background: linear-gradient(135deg, rgba(45,212,191,.12), var(--surface)); }
.why-line { display: grid; grid-template-columns: 1.4fr .8fr .6fr .6fr; gap: .4rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.forecast-tag { color: var(--gold); font-size: .75rem; text-transform: uppercase; }

@media (max-width: 1100px) {
  .kpi-grid, .grid-2 { grid-template-columns: 1fr 1fr; }
  .calendar { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; transform: translateX(-110%); transition: .2s; z-index: 40; }
  .sidebar.open { transform: none; }
  .nav-toggle { display: inline-flex; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(10,14,20,.94); border-top: 1px solid var(--line); padding: .4rem .3rem calc(.4rem + env(safe-area-inset-bottom));
    z-index: 20;
  }
  .mobile-nav a { color: var(--muted); text-align: center; font-size: .72rem; padding: .35rem 0; }
  .mobile-nav a.active { color: var(--accent); }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .day { min-height: 64px; padding: .28rem .22rem; font-size: .72rem; }
  .day .d { font-size: .68rem; }
  .chip { font-size: .58rem; padding: .05rem .22rem; margin: .06rem .04rem 0 0; }
  .calendar { gap: .22rem; }
  .type-picks, .quick-add { grid-template-columns: 1fr; }
  .shift-row { grid-template-columns: 1fr; }
  .content { padding: .85rem .75rem 6.5rem; }
  .toolbar { gap: .35rem; }
  .topbar { padding: .7rem .75rem; gap: .5rem; }
  .top-actions { max-width: 40%; }
  .who { display: none; }
  .kpi b { font-size: 1.02rem; overflow-wrap: anywhere; }
  .why-line { grid-template-columns: 1fr; }
  .modal, .drawer { padding: .5rem; }
  .modal .panel, .drawer .panel { width: 100%; max-width: 100%; }
  .legend { font-size: .72rem; gap: .3rem; }
  .table { font-size: .8rem; }
  .table th, .table td { padding: .4rem .3rem; word-break: break-word; }
}
