/* ============================================================
   Orbit — dark calendar
   Palette: deep ink base, four vibrant priority hues.
   Type: Space Grotesk (display) / Manrope (body) / JetBrains Mono (numerals)
   ============================================================ */

:root {
  --bg:          #0A0C12;
  --surface:     #11141D;
  --surface-2:   #171B27;
  --surface-3:   #1E2432;
  --line:        #262C3D;
  --line-soft:   #1B2030;
  --text:        #E8EBF5;
  --text-dim:    #A3ABC2;
  --muted:       #78819A;

  --p-low:       #22E0C8;
  --p-medium:    #7C5CFF;
  --p-high:      #FFB33C;
  --p-urgent:    #FF4D8D;

  --accent:      #7C5CFF;
  --accent-2:    #FF4D8D;
  --danger:      #FF5470;
  --focus:       #22E0C8;

  --radius:      14px;
  --radius-sm:   9px;
  --shadow:      0 18px 46px rgba(0, 0, 0, .55);
  --ease:        cubic-bezier(.22, .68, .38, 1);

  --hue: 0deg; /* nudged per month, drives the aurora */
}

* { box-sizing: border-box; }

/* Layout rules like `display:flex` outrank the browser's own [hidden] rule,
   so state it here once and let every hidden element mean it. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, .brand-word { font-family: 'Space Grotesk', system-ui, sans-serif; letter-spacing: -.02em; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(124, 92, 255, .35); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- shared controls ---------- */

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .58rem 1rem;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  background: var(--surface-3);
  color: var(--text);
  transition: transform .12s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}
.btn:hover { background: #262D3E; }
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
a.btn { text-decoration: none; text-align: center; }
a.btn-block { display: block; }

.btn-primary {
  background: linear-gradient(96deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 20px rgba(124, 92, 255, .28);
}
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(96deg, var(--accent), var(--accent-2)); }

.btn-quiet { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn-ghost:hover { border-color: var(--p-low); color: var(--p-low); background: transparent; }
.btn-ghost.is-on { border-color: var(--p-low); color: var(--p-low); }

.btn-danger { background: transparent; border-color: rgba(255, 84, 112, .4); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 84, 112, .12); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: #35405A; }

.link-btn {
  background: none; border: 0; padding: 0;
  color: var(--muted); font-size: .78rem; font-weight: 600;
  cursor: pointer; text-transform: none; letter-spacing: 0;
}
.link-btn:hover { color: var(--p-low); }

.field { display: flex; flex-direction: column; gap: .38rem; margin-bottom: 1rem; }
.field > span {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.field > span em { font-style: normal; font-weight: 500; text-transform: none; letter-spacing: 0; opacity: .7; }
.field input, .field select, .field textarea, .add-row input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .62rem .75rem;
  color: var(--text);
  width: 100%;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus, .add-row input:focus {
  border-color: var(--accent);
  outline: none;
  background: var(--surface-3);
}
.field textarea { resize: vertical; }
.hint { color: var(--muted); font-size: .76rem; }
.field-row { display: flex; gap: .75rem; }
.field-row > * { flex: 1; min-width: 0; }
.sub-field { margin: .75rem 0 0; }

.form-error {
  color: #FF8FA6;
  background: rgba(255, 84, 112, .1);
  border: 1px solid rgba(255, 84, 112, .28);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem;
  font-size: .85rem;
  margin: 0 0 .9rem;
}

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg-btn {
  border: 0; background: transparent; color: var(--muted);
  padding: .35rem .7rem; border-radius: 7px; font-size: .82rem; font-weight: 600; cursor: pointer;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--surface-3); color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-dim);
  border-radius: 999px; padding: .3rem .68rem; font-size: .8rem; font-weight: 600; cursor: pointer;
  transition: border-color .15s var(--ease), color .15s var(--ease);
}
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--accent)); flex: none; }
.chip:hover { color: var(--text); }
.chip.is-active { border-color: var(--dot, var(--accent)); color: var(--text); background: color-mix(in srgb, var(--dot, var(--accent)) 14%, transparent); }

/* ---------- brand ---------- */

.brand { display: flex; align-items: center; gap: .6rem; }
.brand-word { font-size: 1.15rem; font-weight: 700; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(from 210deg, var(--p-urgent), var(--p-medium), var(--p-low), var(--p-high), var(--p-urgent));
  box-shadow: 0 0 0 3px rgba(124, 92, 255, .14);
}
.brand-lg .brand-word { font-size: 1.8rem; }
.brand-lg .brand-mark { width: 32px; height: 32px; }

/* ---------- sign in ---------- */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(1100px 520px at 12% -10%, rgba(124, 92, 255, .22), transparent 60%),
    radial-gradient(900px 480px at 92% 8%, rgba(255, 77, 141, .16), transparent 62%),
    var(--bg);
}
.gate-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2rem 1.75rem 1.75rem;
  box-shadow: var(--shadow);
}
.gate-lede { color: var(--text-dim); margin: .9rem 0 1.5rem; font-size: .95rem; }
.tabs { display: flex; gap: .35rem; background: var(--surface-2); border-radius: 10px; padding: 4px; margin-bottom: 1.4rem; }
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: .5rem; border-radius: 7px; font-weight: 600; font-size: .88rem; cursor: pointer;
}
.tab.is-active { background: var(--surface-3); color: var(--text); }

/* ---------- app frame ---------- */

.app {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 340px;
  grid-template-areas: "side main rail";
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

.aurora {
  position: fixed;
  inset: 0 0 auto 0;
  height: 220px;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(620px 200px at 22% 0%, rgba(124, 92, 255, .20), transparent 70%),
    radial-gradient(520px 180px at 68% 0%, rgba(255, 77, 141, .13), transparent 70%),
    radial-gradient(460px 160px at 95% 0%, rgba(34, 224, 200, .10), transparent 70%);
  filter: hue-rotate(var(--hue));
  transition: filter .6s var(--ease);
}

/* ---------- sidebar ---------- */

.sidebar {
  grid-area: side;
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
  padding: 1.1rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  overflow-y: auto;
  z-index: 30;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.sidebar-close { display: none; }
.filter-group { display: flex; flex-direction: column; gap: .55rem; }
.group-title {
  margin: 0;
  display: flex; align-items: center; justify-content: space-between;
  font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .8rem; }
.account {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  border-top: 1px solid var(--line-soft); padding-top: .8rem;
}
.account-name { font-size: .85rem; font-weight: 600; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.scrim { position: fixed; inset: 0; background: rgba(4, 6, 11, .68); z-index: 25; }

/* ---------- top bar ---------- */

.main { grid-area: main; display: flex; flex-direction: column; min-width: 0; overflow: hidden; position: relative; z-index: 1; }

.topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.05rem 1.4rem .9rem;
  border-bottom: 1px solid var(--line-soft);
}
.menu-btn { display: none; }
.period { min-width: 0; }
.period h1 { font-size: 1.5rem; font-weight: 600; }
.period-sub { margin: .1rem 0 0; font-size: .78rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; letter-spacing: .02em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

/* ---------- calendar ---------- */

.board { flex: 1; min-height: 0; overflow-y: auto; padding: 1rem 1.4rem 2rem; }
.calendar { display: flex; flex-direction: column; gap: .5rem; }

.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekdays span {
  text-align: center;
  font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); padding-bottom: .2rem;
}

.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }

.cell {
  position: relative;
  min-height: 118px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: .45rem .45rem .5rem;
  display: flex; flex-direction: column; gap: .3rem;
  cursor: pointer;
  text-align: left;
  transition: border-color .16s var(--ease), background .16s var(--ease), transform .16s var(--ease);
}
.cell:hover { border-color: #333B54; background: var(--surface-2); }
.cell.is-outside { opacity: .42; }
.cell.is-selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.cell.is-today .daynum {
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 3px 12px rgba(255, 77, 141, .3);
}

.cell-top { display: flex; align-items: center; justify-content: space-between; gap: .25rem; }
.daynum {
  font-family: 'JetBrains Mono', monospace;
  font-size: .78rem; font-weight: 500;
  min-width: 23px; height: 23px;
  display: grid; place-items: center;
  border-radius: 7px;
  color: var(--text-dim);
}
.cell-count { font-family: 'JetBrains Mono', monospace; font-size: .66rem; color: var(--muted); }

/* the signature: stacked priority bars */
.bars { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bar {
  display: flex; align-items: center; gap: .34rem;
  font-size: .74rem; font-weight: 500;
  padding: .2rem .34rem .2rem .3rem;
  border-radius: 6px;
  background: var(--surface-2);
  border-left: 3px solid var(--dot, var(--accent));
  color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar .bar-time { font-family: 'JetBrains Mono', monospace; font-size: .64rem; color: var(--muted); flex: none; }
.bar .bar-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bar.is-done { opacity: .42; text-decoration: line-through; background: transparent; }
.bar.is-late { border-left-color: var(--danger); color: #FF9DAF; }
.more { font-size: .68rem; color: var(--muted); padding-left: .2rem; }

.dots { display: none; gap: 3px; flex-wrap: wrap; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--dot, var(--accent)); }
.dots i.is-done { opacity: .3; }

/* ---------- list view ---------- */

.listing { display: flex; flex-direction: column; gap: 1.4rem; }
.list-day { display: flex; flex-direction: column; gap: .5rem; }
.list-day h3 {
  font-size: .8rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: baseline; gap: .6rem;
}
.list-day h3 span { font-family: 'JetBrains Mono', monospace; letter-spacing: 0; text-transform: none; color: var(--text-dim); }

/* ---------- task card ---------- */

.task {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--dot, var(--accent));
  border-radius: var(--radius-sm);
  padding: .65rem .75rem;
  display: flex; gap: .65rem; align-items: flex-start;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.task:hover { background: var(--surface-2); }
.task.is-done { opacity: .5; }
.task.is-done .task-title { text-decoration: line-through; }

.tick {
  flex: none;
  width: 20px; height: 20px; margin-top: .12rem;
  border-radius: 6px;
  border: 1.6px solid var(--dot, var(--accent));
  background: transparent;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s var(--ease);
}
.tick svg { opacity: 0; transition: opacity .12s var(--ease); }
.tick:hover { background: color-mix(in srgb, var(--dot, var(--accent)) 22%, transparent); }
.task.is-done .tick { background: var(--dot, var(--accent)); }
.task.is-done .tick svg { opacity: 1; }

.task-main { min-width: 0; flex: 1; }
.task-title { font-weight: 600; font-size: .93rem; word-break: break-word; cursor: pointer; }
.task-meta { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin-top: .3rem; font-size: .74rem; color: var(--muted); }
.task-meta .pill {
  display: inline-flex; align-items: center; gap: .3rem;
  border: 1px solid var(--line); border-radius: 999px; padding: .08rem .48rem;
}
.task-meta .pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--accent)); }
.task-meta .mono { font-family: 'JetBrains Mono', monospace; }
.task-meta .late { color: #FF8FA6; font-weight: 600; }
.task-meta .assigned { color: #B9A9FF; font-weight: 600; }
.task-notes { margin: .4rem 0 0; font-size: .82rem; color: var(--text-dim); white-space: pre-wrap; }

.steps { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .28rem; }
.steps li { display: flex; align-items: center; gap: .45rem; font-size: .82rem; color: var(--text-dim); }
.steps input { accent-color: var(--p-low); width: 15px; height: 15px; cursor: pointer; flex: none; }
.steps li.done span { text-decoration: line-through; opacity: .55; }
.step-bar { height: 3px; border-radius: 3px; background: var(--surface-3); margin-top: .5rem; overflow: hidden; }
.step-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--p-low), var(--accent)); transition: width .25s var(--ease); }

.task-actions { display: flex; gap: .25rem; flex: none; }
.mini-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
}
.mini-btn:hover { background: var(--surface-3); color: var(--text); }

/* ---------- rail ---------- */

.rail {
  grid-area: rail;
  border-left: 1px solid var(--line-soft);
  background: var(--surface);
  padding: 1.1rem 1.1rem 2rem;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 1rem;
  z-index: 1;
}
.rail-eyebrow { margin: 0; font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.rail-head h2 { font-size: 1.15rem; margin-top: .2rem; }
.rail-body { display: flex; flex-direction: column; gap: 1.4rem; }
.rail-section { display: flex; flex-direction: column; gap: .5rem; }
.rail-section h3 {
  font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: .45rem;
}
.rail-section h3 b { color: var(--danger); font-weight: 700; }
.empty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 1.1rem; text-align: center; color: var(--muted); font-size: .85rem;
}
.empty strong { display: block; color: var(--text-dim); font-weight: 600; margin-bottom: .2rem; }

/* ---------- floating add ---------- */

.fab {
  display: none;
  position: fixed;
  right: 1.1rem;
  bottom: calc(1.1rem + env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  border-radius: 18px; border: 0;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 12px 30px rgba(124, 92, 255, .4);
  cursor: pointer;
  z-index: 20;
}

/* ---------- editor sheet ---------- */

.sheet { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(4, 6, 11, .72); backdrop-filter: blur(3px); }
.sheet-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: min(88dvh, 900px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: rise .22s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.25rem .8rem;
  border-bottom: 1px solid var(--line-soft);
}
.sheet-head h2 { font-size: 1.1rem; }
.sheet-body { padding: 1.15rem 1.25rem .4rem; overflow-y: auto; }
.sheet-foot {
  display: flex; align-items: center; gap: .5rem;
  padding: .9rem 1.25rem calc(.9rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
}
.sheet-foot .spacer { flex: 1; }

.pri-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.pri {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-dim);
  border-radius: var(--radius-sm); padding: .5rem .3rem; font-size: .8rem; font-weight: 600; cursor: pointer;
  position: relative;
  transition: border-color .15s var(--ease), color .15s var(--ease), background .15s var(--ease);
}
.pri::before {
  content: ''; display: block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--dot); margin: 0 auto .3rem;
}
.pri.is-active { border-color: var(--dot); color: var(--text); background: color-mix(in srgb, var(--dot) 16%, transparent); }

.inline-field { display: flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--muted); }
.inline-field input { width: 68px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .62rem .5rem; text-align: center; }

.weekday-picker { display: flex; gap: .3rem; margin-top: .6rem; flex-wrap: wrap; }
.wd {
  width: 38px; height: 34px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  font-size: .74rem; font-weight: 700; cursor: pointer;
}
.wd.is-active { border-color: var(--accent); color: #fff; background: color-mix(in srgb, var(--accent) 26%, transparent); }

.subtask-edit { list-style: none; margin: 0 0 .5rem; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.subtask-edit li {
  display: flex; align-items: center; gap: .5rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .38rem .5rem .38rem .65rem; font-size: .86rem;
}
.subtask-edit li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.subtask-edit input[type=checkbox] { accent-color: var(--p-low); width: 15px; height: 15px; }
.add-row { display: flex; gap: .5rem; }
.add-row input { flex: 1; }

/* ---------- toast + offline ---------- */

.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(1.4rem + env(safe-area-inset-bottom));
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: .6rem 1rem;
  border-radius: 999px;
  font-size: .85rem; font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 80;
  animation: rise .2s var(--ease);
}
.offline-bar {
  position: fixed; top: 0; left: 0; right: 0;
  background: var(--p-high); color: #241802;
  font-size: .8rem; font-weight: 700; text-align: center;
  padding: .35rem .8rem; z-index: 90;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1239px) {
  .app {
    grid-template-columns: 264px minmax(0, 1fr);
    grid-template-areas: "side main" "side rail";
    grid-template-rows: minmax(0, 1fr) auto;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  .sidebar { position: sticky; top: 0; height: 100dvh; }
  .main { overflow: visible; }
  .board { overflow: visible; }
  .rail { border-left: 1px solid var(--line-soft); border-top: 1px solid var(--line-soft); overflow: visible; }
}

@media (max-width: 899px) {
  body { font-size: 15px; }
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "main" "rail";
    grid-template-rows: auto auto;
  }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: min(300px, 84vw);
    height: 100dvh;
    transform: translateX(-102%);
    transition: transform .24s var(--ease);
    box-shadow: var(--shadow);
  }
  .sidebar.is-open { transform: none; }
  .sidebar-close { display: grid; }
  .menu-btn { display: grid; }

  .topbar { padding: .8rem .9rem .7rem; flex-wrap: wrap; }
  .period h1 { font-size: 1.2rem; }
  .topbar-actions { gap: .35rem; }
  .seg-view { order: 3; }
  .board { padding: .8rem .9rem 6rem; }

  .grid { gap: 4px; }
  .cell { min-height: 64px; border-radius: 10px; padding: .3rem .25rem; gap: .18rem; align-items: center; }
  .cell-top { justify-content: center; }
  .cell-count { display: none; }
  .bars { display: none; }
  .dots { display: flex; justify-content: center; }

  .rail { border-left: 0; padding: 1rem .9rem 6rem; }
  .fab { display: grid; place-items: center; }
  #new-task { display: none; }

  .sheet { align-items: flex-end; }
  .sheet-panel {
    width: 100%;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    animation: slide-up .24s var(--ease);
  }
  @keyframes slide-up { from { transform: translateY(100%); } }
  .field-row { flex-direction: column; gap: 0; }
  .pri-picker { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 380px) {
  .wd { width: 34px; }
  .weekdays span { font-size: .6rem; letter-spacing: .06em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* ============================================================
   Administration
   ============================================================ */

.admin-body { min-height: 100dvh; }

.admin-shell { position: relative; min-height: 100dvh; display: flex; flex-direction: column; }

.admin-top {
  position: relative;
  z-index: 2;
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.6rem;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(17, 20, 29, .72);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
}
.admin-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: .62rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--p-urgent);
  border: 1px solid color-mix(in srgb, var(--p-urgent) 45%, transparent);
  background: color-mix(in srgb, var(--p-urgent) 12%, transparent);
  border-radius: 999px; padding: .16rem .5rem;
}
.admin-tabs { display: inline-flex; gap: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.admin-top-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.admin-top-actions .btn { text-decoration: none; display: inline-flex; align-items: center; }

.admin-main { position: relative; z-index: 1; padding: 1.6rem; max-width: 1400px; width: 100%; margin: 0 auto; }
.panel { display: flex; flex-direction: column; gap: 1.4rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-top: 2px solid var(--dot, var(--accent));
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
}
.stat-label { margin: 0; font-size: .7rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.stat-value {
  margin: .35rem 0 .1rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.1rem; font-weight: 600; line-height: 1;
  color: var(--dot, var(--text));
}
.stat-sub { margin: 0; font-size: .78rem; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 1.05rem 1.2rem;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { font-size: 1.05rem; }
.card-sub { margin: .15rem 0 0; font-size: .8rem; color: var(--muted); width: 100%; }

.filter-bar {
  display: flex; gap: .75rem; flex-wrap: wrap;
  padding: .9rem 1.2rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.mini-field { display: flex; flex-direction: column; gap: .25rem; min-width: 150px; }
.mini-field.grow { flex: 1; min-width: 200px; }
.mini-field > span { font-size: .66rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.mini-field select, .mini-field input {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .45rem .6rem; color: var(--text); width: 100%;
}
.mini-field select:focus, .mini-field input:focus { border-color: var(--accent); outline: none; }

.result-count { margin: 0; padding: .7rem 1.2rem 0; font-size: .76rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
  text-align: left; font-size: .66rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); padding: .8rem 1.2rem; border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
.table td { padding: .7rem 1.2rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-done { opacity: .5; }
.table .num { text-align: right; }
.table .mono { font-family: 'JetBrains Mono', monospace; font-size: .82rem; }
.table .who { display: block; font-weight: 600; color: var(--text); }
.table .sub { display: block; font-size: .74rem; color: var(--muted); }
.table .is-late { color: #FF8FA6; font-weight: 600; }
.table .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: .3rem; vertical-align: middle; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn + .btn { margin-left: .35rem; }
.btn-sm { padding: .32rem .7rem; font-size: .78rem; }

.pill-role {
  display: inline-block;
  font-size: .7rem; font-weight: 700; letter-spacing: .04em;
  border: 1px solid var(--line); border-radius: 999px; padding: .1rem .55rem;
  color: var(--text-dim);
}
.pill-role.is-admin { border-color: color-mix(in srgb, var(--p-medium) 55%, transparent); color: #B9A9FF; background: color-mix(in srgb, var(--p-medium) 14%, transparent); }
.pill-role.is-off { border-color: rgba(255, 84, 112, .4); color: #FF8FA6; margin-left: .3rem; }

.pill-pri {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .75rem; font-weight: 600; text-transform: capitalize; color: var(--text-dim);
}
.pill-pri i { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }

@media (max-width: 899px) {
  .admin-top { padding: .8rem .9rem; gap: .6rem; }
  .admin-tabs { order: 3; width: 100%; }
  .admin-tabs .seg-btn { flex: 1; }
  .admin-main { padding: 1rem .9rem 3rem; }
  .table th, .table td { padding: .6rem .8rem; }
  .card-head { padding: .9rem; }
  .filter-bar { padding: .8rem .9rem; }
}
