body { min-height: 100vh; padding: 32px; }

/* ---------- shell ---------- */
.shell {
  max-width: 1440px; margin: 0 auto; min-height: calc(100vh - 64px);
  display: grid; grid-template-columns: 280px 1fr;
  background: var(--shell); border-radius: 32px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(60, 50, 110, 0.12);
}
.sidebar { padding: 28px 24px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 28px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 14px; height: 48px; padding: 0 16px; border-radius: 999px;
  color: var(--ink-2); text-decoration: none; font-size: 15px; transition: background .15s;
}
.nav a i { display: grid; width: 20px; height: 20px; color: var(--muted); }
.nav a i svg { width: 20px; height: 20px; }
.nav a:hover { background: var(--line); }
.nav a.active { background: var(--card); color: var(--ink); font-weight: 500; box-shadow: var(--shadow); }
.nav a.active i { color: var(--ink); }
.nav-sep { height: 1px; background: var(--line-2); margin: 14px 4px; }
.side-link { margin-top: auto; padding: 0 16px; font-size: 13px; color: var(--muted); text-decoration: none; }
.side-link:hover { color: var(--ink); text-decoration: underline; }
.side-link + .side-foot { margin-top: 0; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 12px; padding: 8px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--grad-2); display: grid; place-items: center; font-weight: 600; color: var(--accent-ink); flex: none; }
.who { display: grid; flex: 1; min-width: 0; font-size: 14px; }
.who b { font-weight: 500; }
.who span { font-size: 13px; }

.main { padding: 28px 40px 48px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 18px; margin-bottom: 28px; min-height: 52px; flex-wrap: wrap; }
.topbar h1 { font-size: 32px; font-weight: 500; letter-spacing: -0.02em; }
.topbar-sep { width: 1px; height: 24px; background: var(--line-2); }
.topbar .spacer { flex: 1; }
.topbar .btn.primary { height: 48px; padding: 0 22px; }
.pill i { display: grid; }
.pill i svg { width: 14px; height: 14px; }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; border-radius: 16px; background: var(--amber-soft); color: var(--ink-2); margin-bottom: 20px; }
.banner i { color: var(--amber); display: grid; }
.banner i svg { width: 20px; height: 20px; }
body.readonly .editable { pointer-events: none; opacity: .6; }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.stat { display: flex; align-items: center; gap: 20px; padding: 22px 24px; border-radius: 18px; }
.stat:nth-child(1) { background: var(--grad-1); }
.stat:nth-child(2) { background: var(--grad-2); }
.stat:nth-child(3) { background: var(--grad-3); }
.stat .ico { width: 54px; height: 54px; border-radius: 50%; background: var(--card); display: grid; place-items: center; flex: none; }
.stat .ico svg { width: 24px; height: 24px; }
.stat .lbl { color: var(--ink-2); font-size: 14px; opacity: .85; }
.stat .val { font-size: 28px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; }
.stat .val small { font-size: 15px; color: var(--muted); font-weight: 400; margin-left: 4px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 12px; margin-bottom: 36px; }

.chart-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; flex-wrap: wrap; }
.chart-head h2 { font-size: 22px; }
.chart-head .sep { width: 1px; height: 20px; background: var(--line-2); }
.chart-head select { border: 0; background: transparent; color: var(--ink-2); cursor: pointer; padding: 4px; outline: none; }
.chart-head .avg { margin-left: auto; font-size: 30px; letter-spacing: -0.02em; }
.chart-head .avg small { font-size: 14px; color: var(--muted); }
.chart { position: relative; display: grid; grid-template-columns: 44px 1fr; height: 330px; margin-top: 16px; }
.y-axis { position: relative; color: var(--muted); font-size: 13px; }
.y-axis span { position: absolute; right: 12px; transform: translateY(50%); }
.plot { position: relative; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; padding-bottom: 32px; }
.bar-col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; }
.bar { position: relative; border-radius: 14px; background: var(--hatch); min-height: 26px; transition: height .5s cubic-bezier(.2,.8,.2,1); }
.bar.today { background: linear-gradient(180deg, #c7c3f3, #d9d6f8); }
@media (prefers-color-scheme: dark) { .bar.today { background: linear-gradient(180deg, #4d468f, #3a3570); } }
.bar .tag {
  position: absolute; left: 50%; top: -6px; transform: translate(-50%, -100%); white-space: nowrap;
  background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 13px; box-shadow: var(--shadow);
}
.bar.today .tag { background: var(--accent); color: #fff; }
.bar-col .day { position: absolute; bottom: -30px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 14px; }
.bar-col.today .day { color: var(--accent-ink); font-weight: 500; }
.limit-line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--pink); z-index: 2; pointer-events: none; }
.limit-line span { position: absolute; left: 0; top: -14px; background: var(--pink); color: #fff; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; }

.limits-list { display: flex; flex-direction: column; }
.limit-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.limit-row:last-of-type { border-bottom: 0; }
.limit-row .ring { width: 48px; height: 48px; }
.limit-row .ring::before { width: 38px; height: 38px; }
.limit-row .meta { flex: 1; min-width: 0; display: grid; }
.limit-row .meta b { font-weight: 500; font-size: 15px; }
.limit-row .meta span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.section-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h2 { font-size: 24px; }
.section-head .spacer { flex: 1; }
.search { position: relative; }
.search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); display: grid; }
.search i svg { width: 16px; height: 16px; }
.search input { border: 0; background: transparent; padding-left: 36px; height: 36px; outline: none; width: 180px; }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; min-width: 640px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 400; font-size: 14px; padding: 14px 12px; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.tbl td { padding: 16px 12px; border-bottom: 1px solid var(--line-2); font-size: 14.5px; vertical-align: middle; }
.tbl tr:hover td { background: color-mix(in srgb, var(--card) 55%, transparent); }
.site-cell { display: flex; align-items: center; gap: 12px; }
.fav { width: 32px; height: 32px; border-radius: 10px; background: var(--grad-3); display: grid; place-items: center; font-weight: 600; font-size: 13px; color: var(--accent-ink); flex: none; overflow: hidden; }
.fav img { width: 18px; height: 18px; }
.ring-cell { display: flex; align-items: center; gap: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 12px !important; }

/* ---------- editors ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.group-card { padding: 0; overflow: hidden; }
.group-top { display: flex; align-items: center; gap: 14px; padding: 20px 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.group-top .name { font-size: 20px; font-weight: 500; border: 0; background: transparent; outline: none; padding: 4px 6px; border-radius: 8px; min-width: 120px; flex: 1; }
.group-top .name:focus { background: var(--shell); }
.color-in { width: 28px; height: 28px; border: 0; padding: 0; border-radius: 50%; overflow: hidden; cursor: pointer; background: none; }
.color-in::-webkit-color-swatch-wrapper { padding: 0; }
.color-in::-webkit-color-swatch { border: 0; border-radius: 50%; }
.color-in::-moz-color-swatch { border: 0; border-radius: 50%; }
.group-body { padding: 20px 24px 24px; display: grid; gap: 22px; }
.group-status { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips .input { width: 220px; height: 32px; border-radius: 999px; font-size: 13px; }
.fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.days .field > span { text-align: center; }
.days .input { text-align: center; padding: 0 6px; }
.sub-h { font-size: 13px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.sched { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.sched .input { width: 130px; }

.add-row { display: flex; gap: 10px; }
.add-row .input { height: 48px; border-radius: 999px; padding: 0 20px; }
.add-row .btn { height: 48px; padding: 0 24px; }
.hint { font-size: 13px; color: var(--muted); margin: 10px 4px 0; }
.blocked-list { margin-top: 8px; }
.b-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.b-row:last-child { border-bottom: 0; }
.b-row .meta { flex: 1; display: grid; min-width: 0; }
.b-row .meta b { font-weight: 500; }
.b-row .meta span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.opt-row { display: flex; gap: 16px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--line); }
.opt-row:last-child { border-bottom: 0; }
.opt-row .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--shell); flex: none; color: var(--ink-2); }
.opt-row .ico svg { width: 20px; height: 20px; }
.opt-row .meta { flex: 1; min-width: 0; }
.opt-row .meta b { font-weight: 500; display: block; }
.opt-row .meta span { color: var(--muted); font-size: 13px; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
pre.code { background: var(--shell); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; overflow: auto; font-size: 12.5px; max-height: 320px; margin: 0; white-space: pre; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 10px; color: var(--ink-2); }
.steps code, p code { background: var(--shell); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 12.5px; }
.tabs { display: inline-flex; background: var(--shell); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; }
.tabs button { border: 0; background: transparent; height: 32px; padding: 0 14px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); font-weight: 500; }

/* ---------- gate ---------- */
.gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--ground); z-index: 50; }
.gate-card { width: min(420px, 100%); display: grid; gap: 16px; padding: 36px; border-radius: 28px; }
.gate-card h1 { font-size: 28px; margin-top: 12px; }
.gate-card p { margin: -8px 0 4px; }
.gate-error { color: var(--pink); min-height: 1em; margin: 0 !important; font-size: 13px; }
.gate-card .btn { height: 48px; }
.gate-link { justify-self: center; font-size: 13px; color: var(--muted); }

@media (max-width: 1100px) {
  .grid-2, .two { grid-template-columns: 1fr; }
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  body { padding: 0; }
  .shell { grid-template-columns: 1fr; border-radius: 0; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); min-width: 0; padding: 20px 16px 12px; gap: 14px; }
  .nav a { flex: none; }
  .topbar h1 { font-size: 26px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav-sep, .side-foot, .side-link { display: none; }
  .main { padding: 20px 16px 40px; }
  .stats { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
