:root {
  --charcoal: #1a1a1a; --surface: #222; --border-dark: #333; --ivory: #F2EDE6; --sage: #E8EDE6; --sage-dark: #D0D9CE;
  --forest: #1E5C34; --forest-light: #2A7A46; --mint: #7BBF9A; --muted: #6f6f6f; --bg: #F6F4F0; --card: #fff; --line: #E3E0DA;
  --danger: #B3261E; --warn: #9A6700; --warn-bg: #FFF4D6; --danger-bg: #FCE8E6; --info-bg: #E7F0FA;
  --r: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  font-family: Inter, system-ui, -apple-system, sans-serif; color: var(--charcoal);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--forest); }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: 26px; font-weight: 700; }
h1 em, h2 em, .accent { font-family: 'Playfair Display', Georgia, serif; font-style: italic; font-weight: 700; color: var(--forest); }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--charcoal); color: var(--ivory); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 9px; padding: 4px 10px 18px; text-decoration: none; color: #f6f6f6; font-weight: 800; letter-spacing: .04em; font-size: 15px; }
.logo svg { width: 20px; height: 20px; }
.logo small { color: var(--mint); font-weight: 600; letter-spacing: 0; }
.side .who { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--border-dark); font-size: 12px; color: #aaa; }
.side .who strong { color: var(--ivory); display: block; font-size: 13px; }
.nav a { display: flex; align-items: center; gap: 10px; color: #cfcfcf; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: var(--surface); color: #fff; }
.nav a.on { background: var(--surface); color: #fff; box-shadow: inset 3px 0 0 var(--mint); }
.nav .sep { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: #777; padding: 14px 10px 4px; }
.nav .count { margin-left: auto; background: var(--mint); color: var(--charcoal); border-radius: 99px; font-size: 11px; font-weight: 700; padding: 0 7px; }
.main { min-width: 0; }
.top { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 4; }
.top .menu { display: none; margin-right: auto; }
.content { padding: 26px 28px 60px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); text-decoration: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .top .menu { display: inline-flex; }
  .content { padding: 18px 16px 60px; }
  .top { padding: 10px 16px; }
}

/* components */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 1fr) 340px; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-side { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 26px; font-weight: 800; margin-top: 2px; letter-spacing: -.01em; }
.stat .s { font-size: 12px; color: var(--muted); }
.stat.dark { background: var(--charcoal); color: var(--ivory); border-color: var(--charcoal); }
.stat.dark .v { color: var(--mint); font-family: 'Playfair Display', serif; font-style: italic; }
.stat.dark .k, .stat.dark .s { color: #aaa; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 99px; cursor: pointer; font-weight: 600; font-size: 13px; text-decoration: none; color: var(--charcoal); white-space: nowrap; }
.btn:hover { border-color: #bbb; }
.btn.primary { background: var(--forest); border-color: var(--forest); color: #fff; }
.btn.primary:hover { background: var(--forest-light); }
.btn.mint { background: var(--mint); border-color: var(--mint); color: var(--charcoal); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }
.hide { display: none !important; }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.t td { padding: 10px; border-bottom: 1px solid #f0eee9; vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #faf9f6; }
.t .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--sage); color: var(--forest); white-space: nowrap; text-transform: capitalize; }
.pill.grey { background: #eee; color: #555; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill.dark { background: var(--charcoal); color: var(--mint); }
.pill.info { background: var(--info-bg); color: #1d4f86; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #bbb; }
.dot.up { background: #2e9e5b; } .dot.down { background: var(--danger); }

label.f { display: grid; gap: 5px; font-weight: 600; font-size: 12.5px; }
label.f .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input.i, select.i, textarea.i { width: 100%; padding: 8px 11px; border: 1px solid #d6d2cb; border-radius: 8px; background: #fff; font-weight: 400; font-size: 13.5px; }
input.i:focus, select.i:focus, textarea.i:focus { outline: 2px solid var(--mint); outline-offset: 0; border-color: var(--forest); }
textarea.i { resize: vertical; min-height: 70px; }
.form { display: grid; gap: 14px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form .two { grid-template-columns: 1fr; } }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--charcoal); border-bottom-color: var(--forest); }
.tabs a .count { background: var(--sage); color: var(--forest); border-radius: 99px; font-size: 11px; padding: 0 6px; margin-left: 4px; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty h3 { color: var(--charcoal); margin-bottom: 4px; }
.callout { background: var(--sage); border-radius: var(--r); padding: 14px 16px; }
.callout.warn { background: var(--warn-bg); }
.callout.dark { background: var(--charcoal); color: var(--ivory); }
.callout.dark em { color: var(--mint); }

/* kanban */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #EFECE6; border-radius: var(--r); padding: 10px; min-height: 120px; }
.col h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 2px 4px 10px; display: flex; justify-content: space-between; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; display: block; text-decoration: none; color: inherit; }
.tile:hover { border-color: var(--mint); }
.tile .ttl { font-weight: 600; }
.tile .meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(20,20,20,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(860px, 100%); }
.modal h2 { margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--charcoal); color: var(--ivory); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; animation: pop .2s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* notifications */
.bell { position: relative; }
.bell .badge { position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; border-radius: 99px; padding: 0 5px; }
.drop { position: absolute; right: 18px; top: 52px; width: 360px; max-height: 70vh; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.15); z-index: 30; }
.drop .it { display: block; padding: 10px 14px; border-bottom: 1px solid #f1efea; text-decoration: none; color: inherit; }
.drop .it.unread { background: #F6F8F5; box-shadow: inset 3px 0 0 var(--mint); }
.drop .it .b { font-size: 12px; color: var(--muted); }

/* login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth .art { background: var(--charcoal); color: var(--ivory); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth .art h1 { font-size: 44px; max-width: 12ch; }
.auth .art h1 em { color: var(--mint); }
.auth .art p { color: #bbb; max-width: 40ch; font-size: 15px; }
.auth .panel { display: grid; place-items: center; padding: 32px; }
.auth form { width: min(360px, 100%); }
@media (max-width: 800px) { .auth { grid-template-columns: 1fr; } .auth .art { padding: 28px; } .auth .art h1 { font-size: 30px; } }

/* editor */
.editor { display: grid; grid-template-columns: 220px minmax(0, 1fr) minmax(0, 1.1fr); gap: 14px; align-items: start; }
.editor.no-preview { grid-template-columns: 220px minmax(0, 1fr); }
@media (max-width: 1250px) { .editor { grid-template-columns: 200px minmax(0, 1fr); } .editor .pv { grid-column: 1 / -1; } }
@media (max-width: 760px) { .editor, .editor.no-preview { grid-template-columns: 1fr; } }
.pagelist a { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: inherit; font-weight: 500; }
.pagelist a.on { background: var(--sage); color: var(--forest); font-weight: 700; }
.pagelist a:hover:not(.on) { background: #f4f2ee; }
.sec-card { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: #fff; }
.sec-card > header { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; user-select: none; }
.sec-card > header .ty { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--forest); font-weight: 700; }
.sec-card > header .sum { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.sec-card .body { padding: 4px 12px 14px; display: grid; gap: 10px; border-top: 1px solid #f1efea; }
.sec-card.closed .body { display: none; }
.list-item { border: 1px dashed #d8d4cc; border-radius: 8px; padding: 10px; display: grid; gap: 8px; position: relative; }
.list-item .x { position: absolute; right: 6px; top: 6px; }
.pv { position: sticky; top: 70px; }
.pv iframe { width: 100%; height: calc(100vh - 150px); border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.pv.mobile iframe { width: 390px; max-width: 100%; display: block; margin: 0 auto; }
.img-field { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.thumb { width: 100%; max-height: 90px; object-fit: cover; border-radius: 6px; }
.swatch { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); padding: 0; cursor: pointer; }
.theme-card { border: 2px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; background: #fff; text-align: left; }
.theme-card.on { border-color: var(--forest); }
.theme-card .sw { display: flex; gap: 4px; margin-top: 6px; }
.theme-card .sw span { width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,.08); }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; padding-top: 6px; }
.bars div { flex: 1; background: var(--mint); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div:hover { background: var(--forest); }
.bars div:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--charcoal); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; margin-bottom: 4px; }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.hbar .b { grid-column: 1 / -1; height: 6px; background: #eee; border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.hbar .b span { display: block; height: 100%; background: var(--forest); }
.uptime { display: flex; gap: 2px; }
.uptime span { flex: 1; height: 26px; border-radius: 2px; background: #2e9e5b; }
.uptime span.d { background: var(--danger); }
.uptime span.n { background: #e5e5e5; }

.comment { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.comment.internal { background: var(--warn-bg); border-color: #f0dca0; }
.comment.mine { background: #F6F8F5; }
.comment .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.pre { white-space: pre-wrap; }
.score { font-size: 34px; font-weight: 800; font-family: 'Playfair Display', serif; font-style: italic; }
.issue { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; }
.drop-zone { border: 2px dashed #cfcac2; border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.drop-zone.over { border-color: var(--forest); background: var(--sage); }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.file { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.file .pic { aspect-ratio: 4/3; background: #f1efea center/cover; display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.file .meta { padding: 8px 10px; font-size: 12px; }
.file .meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
