:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --side: #14201f;
  --side-ink: #c9d4d2;
  --side-ink-strong: #ffffff;
  --side-hover: rgba(255,255,255,.06);
  --side-on: rgba(94, 199, 182, .16);
  --ink: #1c2321;
  --ink-2: #4d5755;
  --muted: #7b8583;
  --line: #e6e3dc;
  --line-2: #efede8;
  --accent: #0f6b62;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ee;
  --focus: #3ba596;
  --green: #1f7a4d; --green-bg: #e3f3ea;
  --amber: #9a5b00; --amber-bg: #fdf0d9;
  --red: #b42318; --red-bg: #fde7e4;
  --blue: #1f5aa6; --blue-bg: #e4eefb;
  --gray: #5b6563; --gray-bg: #eeede9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20,32,31,.04), 0 2px 8px rgba(20,32,31,.04);
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1514;
    --surface: #161e1d;
    --surface-2: #1b2423;
    --side: #0b100f;
    --ink: #e7ecea;
    --ink-2: #b6c0be;
    --muted: #84908d;
    --line: #273230;
    --line-2: #212b29;
    --accent: #3fb3a2;
    --accent-ink: #062521;
    --accent-soft: #163330;
    --green: #6fd29d; --green-bg: #133024;
    --amber: #f2b552; --amber-bg: #33270f;
    --red: #ff8a7f; --red-bg: #3a1714;
    --blue: #8ab8f5; --blue-bg: #14263d;
    --gray: #aab4b2; --gray-bg: #232d2b;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; display: flex; align-items: center; gap: .5rem; }
h2 { font-size: 1.05rem; display: flex; align-items: center; gap: .45rem; }
.ic { flex: none; vertical-align: -.2em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.w100 { width: 100%; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack.tight { gap: .35rem; }
.row-gap { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.row-gap.end { justify-content: flex-end; flex-wrap: nowrap; }
form.inline { display: inline; margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 1.25rem 1.25rem 1rem; color: var(--side-ink-strong); font-weight: 700; font-size: 1.05rem; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: #1d8a7d; color: #fff; }
.side nav { padding: 0 .75rem; flex: 1; }
.nav-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #6f7f7c; padding: 1rem .6rem .35rem; }
.nav-link { display: flex; align-items: center; gap: .65rem; padding: .5rem .6rem; border-radius: 8px; color: var(--side-ink); font-size: .92rem; }
.nav-link:hover { background: var(--side-hover); text-decoration: none; color: var(--side-ink-strong); }
.nav-link.on { background: var(--side-on); color: #8fe3d5; font-weight: 600; }
.nav-lock { margin-left: auto; opacity: .55; display: flex; }
.side-foot { padding: .75rem; border-top: 1px solid rgba(255,255,255,.07); display: flex; flex-direction: column; gap: .6rem; }
.side-foot .btn.ghost { color: var(--side-ink); border-color: rgba(255,255,255,.12); background: transparent; }
.me { display: flex; align-items: center; gap: .6rem; }
.me .icon-btn { color: var(--side-ink); }
.me .icon-btn:hover { background: var(--side-hover); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #2a3c3a; color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.me-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.me-text strong { color: var(--side-ink-strong); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: #7d8d8a; font-size: .75rem; }

.main { min-width: 0; }
.topbar { display: none; }
.content { max-width: 1240px; margin: 0 auto; padding: 1.75rem 2rem 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head p { margin: .3rem 0 0; }
.back { display: inline-flex; align-items: center; gap: .25rem; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
.section-title { margin: 2rem 0 .75rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 1.25rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; height: 38px; padding: 0 .95rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 .88rem/1 var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.sm { height: 30px; padding: 0 .65rem; font-size: .8rem; }
.btn.ok { color: var(--green); border-color: transparent; background: var(--green-bg); }
.btn.ok:hover { filter: brightness(.97); background: var(--green-bg); }
.btn.danger-ghost { color: var(--red); background: transparent; }
.btn.danger-ghost:hover { background: var(--red-bg); }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.icon-btn.xs { width: 26px; height: 26px; }
.icon-btn.danger:hover { color: var(--red); background: var(--red-bg); }
.icon-btn.done { color: var(--green); }

.badge { display: inline-flex; align-items: center; padding: .12rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; background: var(--gray-bg); color: var(--gray); }
.t-green.badge { background: var(--green-bg); color: var(--green); }
.t-amber.badge { background: var(--amber-bg); color: var(--amber); }
.t-red.badge { background: var(--red-bg); color: var(--red); }
.t-blue.badge { background: var(--blue-bg); color: var(--blue); }
.chips { display: flex; flex-wrap: wrap; gap: .25rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .85rem; margin-bottom: 1.25rem; }
.stat { padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .2rem; border-top: 3px solid var(--gray); }
.stat.t-green { border-top-color: var(--green); }
.stat.t-amber { border-top-color: var(--amber); }
.stat.t-red { border-top-color: var(--red); }
.stat.t-blue { border-top-color: var(--blue); }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.45rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-sub { font-size: .78rem; color: var(--muted); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.tabs { display: flex; gap: .25rem; background: var(--line-2); padding: .25rem; border-radius: 10px; overflow-x: auto; max-width: 100%; }
.tab { padding: .38rem .8rem; border-radius: 7px; color: var(--ink-2); font-size: .86rem; font-weight: 600; white-space: nowrap; }
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.count { color: var(--muted); font-weight: 500; margin-left: .15rem; }
.search { display: flex; align-items: center; gap: .4rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 .65rem; color: var(--muted); height: 38px; min-width: 220px; }
.search input { border: 0; background: transparent; outline: 0; padding: 0; height: 100%; width: 100%; color: var(--ink); font: inherit; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
.grid th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: .7rem .85rem; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: .65rem .85rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td { background: var(--surface-2); }
.grid tr.muted td { opacity: .55; }
.grid tr.muted .row-title { text-decoration: line-through; }
.grid tr.late td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.grid.compact td, .grid.compact th { padding: .5rem .75rem; }
.actions-col { width: 1%; white-space: nowrap; }
.row-title { font-weight: 600; color: var(--ink); }
.ext { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.clip { color: var(--ink-2); }
.no-match { padding: 1rem; text-align: center; margin: 0; }
.btn.ok span { display: inline; }

.secret, .copyable { display: inline-flex; align-items: center; gap: .15rem; }
.secret-val { font-family: var(--mono); font-size: .84rem; background: var(--line-2); padding: .1rem .4rem; border-radius: 5px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.secret-block { display: flex; flex-direction: column; align-items: stretch; gap: .5rem; }
.secret-block .secret-val { white-space: pre-wrap; max-width: none; padding: .75rem; margin: 0; }

.empty { text-align: center; padding: 3rem 1rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p { color: var(--muted); margin: 0 0 1rem; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.form-grid .wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; margin: 0; border: 0; padding: 0; }
.field label, .field legend { font-size: .84rem; font-weight: 600; color: var(--ink-2); padding: 0; }
.req { color: var(--red); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: .93rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .55rem .7rem; min-height: 40px;
}
.search input[type=search] { border: 0; min-height: 0; padding: 0; }
textarea { resize: vertical; line-height: 1.5; }
textarea.mono { font-family: var(--mono); font-size: .86rem; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.help { color: var(--muted); font-size: .78rem; }
.err { color: var(--red); font-size: .8rem; font-weight: 600; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { padding-right: 2.4rem; }
.pw-wrap .icon-btn { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; padding-top: .5rem; border-top: 1px solid var(--line-2); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .4rem; margin-top: .4rem; }
.perm { display: flex; align-items: center; gap: .55rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; font-size: .9rem; background: var(--surface); }
.perm:hover { background: var(--surface-2); }
.perm input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.perms[disabled] .perm { opacity: .45; cursor: not-allowed; }
.perms .admin-note { display: none; }
.perms[disabled] .admin-note { display: block; }

.detail { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem 1.5rem; margin: 0; }
.detail > div { min-width: 0; }
.detail .wide { grid-column: 1 / -1; }
.detail dt { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: .25rem; }
.detail dd { margin: 0; word-break: break-word; }
.detail .ext { white-space: normal; word-break: break-all; }
.meta { margin: 1.25rem 0 0; font-size: .8rem; border-top: 1px solid var(--line-2); padding-top: .8rem; }
.prose { color: var(--ink); }
.steps { margin: 0; padding-left: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: .55rem; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: .65rem; align-items: start; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem; display: grid; place-items: center; }

.related { margin-top: 1.5rem; }
.related-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .7rem; }

.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid var(--line-2); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list li > a:not(.btn) { flex: 1; min-width: 0; color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .when { display: flex; flex-direction: column; min-width: 78px; font-size: .82rem; font-weight: 600; line-height: 1.2; }
.mini-list .when small { color: var(--muted); font-weight: 500; }
.check-btn { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line); background: var(--surface); color: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; }
.check-btn:hover { border-color: var(--green); color: var(--green); background: var(--green-bg); }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
.quick-item { display: flex; gap: .8rem; padding: 1rem; color: var(--ink); align-items: flex-start; }
.quick-item:hover { text-decoration: none; border-color: var(--accent); }
.quick-item strong { display: flex; align-items: center; gap: .3rem; }
.quick-item small { display: block; color: var(--muted); font-size: .8rem; margin-top: .15rem; line-height: 1.4; }
.quick-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }

.flash { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem .9rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .9rem; font-weight: 500; background: var(--green-bg); color: var(--green); }
.flash.f-err { background: var(--red-bg); color: var(--red); }
.flash-x { background: none; border: 0; color: inherit; cursor: pointer; padding: .15rem; display: flex; opacity: .7; }

.unlock { max-width: 420px; margin: 3rem auto; text-align: center; }
.unlock .field { text-align: left; }
.unlock-ic { width: 60px; height: 60px; border-radius: 50%; background: var(--amber-bg); color: var(--amber); display: grid; place-items: center; margin: 0 auto; }

body.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), var(--bg)); }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; font-weight: 700; font-size: 1.15rem; margin-bottom: 1.25rem; }
.auth h1 { font-size: 1.35rem; margin-bottom: .25rem; }
.auth p { margin: 0; }

.scrim { display: none; }

@media (max-width: 1100px) {
  .detail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; }
  .topbar { display: flex; align-items: center; gap: .5rem; position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); padding: .5rem 16px; }
  .topbar-title { font-weight: 700; }
  .content { padding: 1.25rem 16px 4rem; }
  .dash-grid, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  h1 { font-size: 1.3rem; }
  .hide-sm { display: none; }
  .form-grid, .detail { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .stat { padding: .8rem; }
  .stat-value { font-size: 1.15rem; }
  .search { min-width: 0; width: 100%; }
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  table.grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
  .grid thead { display: none; }
  .grid tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .6rem; padding: .4rem .2rem; }
  .grid td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border: 0; padding: .35rem .8rem; text-align: right; }
  .grid td::before { content: attr(data-label); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; text-align: left; flex: none; }
  .grid td.actions-col { width: 100%; justify-content: flex-end; border-top: 1px solid var(--line-2); margin-top: .3rem; padding-top: .5rem; }
  .grid td.actions-col::before { content: none; }
  .grid tbody tr:hover td { background: transparent; }
  .grid tr.late { box-shadow: inset 3px 0 0 var(--red); }
  .grid tr.late td:first-child { box-shadow: none; }
  .page-head > .row-gap { width: 100%; }
}
