/* PrePost panel theme. Same family as the desktop app. Colours come only from these tokens. */
:root {
    color-scheme: light;
    --bg: #faf6f2; --surface: #ffffff; --surface-2: #fcf8f4; --border: #efe5dc;
    --text: #1f140c; --text-2: #4a3628; --muted: #7d6656;
    --accent: #c2410c; --accent-hover: #9a3412; --accent-soft: #ffedd5; --on-accent: #ffffff;
    --sidebar-bg: #2a1a10; --sidebar-text: #f6e4d6; --sidebar-muted: #b0907a; --sidebar-active: #c2410c; --sidebar-hover: rgba(255,255,255,.07);
    --good: #15803d; --good-soft: #dcfce7; --warn: #a16207; --warn-soft: #fef9c3; --bad: #b91c1c; --bad-soft: #fee2e2;
    --shadow: 0 1px 3px rgba(60,30,10,.07);
}
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #17100b; --surface: #21170f; --surface-2: #2a1e15; --border: #3b2c20;
        --text: #f8ece2; --text-2: #e0cdbd; --muted: #b09a88;
        --accent: #f97316; --accent-hover: #fb923c; --accent-soft: #43240f; --on-accent: #1f0f05;
        --sidebar-bg: #120b07; --sidebar-active: #c2410c;
        --good: #4ade80; --good-soft: #143321; --warn: #facc15; --warn-soft: #3a2f0a; --bad: #f87171; --bad-soft: #451a1a;
        --shadow: none;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--text); background: var(--bg); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.icon { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code, .mono { font-family: Consolas, "Cascadia Mono", monospace; }

/* Shell */
.shell { display: flex; min-height: 100%; }
.sidebar { width: 232px; flex: none; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
.brand b { display: block; font-size: 15px; color: #fff; }
.brand small { font-size: 12px; color: var(--sidebar-muted); }
.nav-label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--sidebar-muted); padding: 14px 10px 5px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--sidebar-text); font-weight: 550; margin-bottom: 2px; }
.nav-item:hover { background: var(--sidebar-hover); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.1); }
.side-foot .who { padding: 0 10px 8px; font-size: 13px; color: var(--sidebar-muted); overflow-wrap: anywhere; }
.side-foot button { width: 100%; background: none; border: 0; cursor: pointer; font: inherit; text-align: left; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 28px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar .titles { flex: 1; min-width: 220px; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 22px 28px 40px; display: flex; flex-direction: column; gap: 18px; }

/* Parts */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-body { padding: 16px 18px; }
.card-head .hint { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.tile { padding: 14px 16px; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 26px; font-weight: 650; line-height: 1.3; }
.tile .note { color: var(--muted); font-size: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 36px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; min-height: 30px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .subtle, td.subtle { white-space: nowrap; }
.subtle { color: var(--muted); font-size: 13px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); align-items: center; }
.filters input[type=search] { flex: 1 1 240px; }
.filters select { flex: 0 1 190px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label, .label-text { font-weight: 600; font-size: 13px; color: var(--text-2); }
.field small { color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea, input[type=file] {
    font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; width: 100%; min-height: 38px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.field .error { color: var(--bad); font-size: 13px; font-weight: 550; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; }
.check { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 14px; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 8px; align-items: center; }

/* Messages */
.alert { padding: 11px 15px; border-radius: 10px; font-weight: 550; }
.alert.success { background: var(--good-soft); color: var(--good); }
.alert.info { background: var(--accent-soft); color: var(--text); }
.alert.error { background: var(--bad-soft); color: var(--bad); }
.alert ul { margin: 0; padding-left: 18px; }

/* Details */
.facts { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 14px; margin: 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.key-box { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px dashed var(--accent); border-radius: 10px; padding: 10px 14px; flex-wrap: wrap; }
.key-box code { font-size: 17px; font-weight: 700; flex: 1; min-width: 200px; overflow-wrap: anywhere; }
.bar { height: 7px; background: var(--border); border-radius: 6px; overflow: hidden; margin: 5px 0 12px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar i.full { background: var(--bad); }
.usage-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }

/* Sign-in: picture on the left, form on the right */
.auth-body { background: var(--surface); }
.auth-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth-art { background: radial-gradient(120% 90% at 15% 0%, #4a2c17 0%, #2a1a10 55%, #1d1109 100%); color: #fff; display: flex; flex-direction: column; padding: 34px 44px; min-width: 0; }
.auth-brand { display: flex; align-items: center; gap: 11px; font-size: 18px; }
.auth-brand img { width: 40px; height: 40px; border-radius: 10px; }
.auth-illustration { display: block; width: 100%; max-width: 500px; max-height: 58vh; margin: auto; }
.auth-copy { max-width: 440px; }
.auth-copy h2 { font-size: 24px; line-height: 1.3; margin-bottom: 8px; color: #fff; }
.auth-copy p { color: #e4cdbb; }
.auth-side { display: flex; align-items: center; justify-content: center; padding: 32px 24px; min-width: 0; }
.auth-form { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 28px; margin-bottom: 6px; }
.auth-sub { color: var(--muted); margin-bottom: 24px; }
.auth-form input[type=email], .auth-form input[type=text], .auth-form input[type=password] { min-height: 44px; }
.auth-submit { width: 100%; min-height: 44px; font-size: 15px; }
.auth-back { text-align: center; margin-top: 14px; }
.auth-mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 24px; font-size: 17px; }
.auth-mobile-brand img { width: 36px; height: 36px; border-radius: 9px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 46px; }
.password-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; }
.password-toggle:hover { color: var(--text); background: var(--surface-2); }
.link-button { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); font-weight: 600; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
details > summary { list-style: none; width: fit-content; }
details > summary::-webkit-details-marker { display: none; }
@media (max-width: 860px) {
    .auth-split { grid-template-columns: minmax(0, 1fr); }
    .auth-art { display: none; }
    .auth-mobile-brand { display: flex; }
}
.qr { background: #fff; padding: 10px; border-radius: 10px; display: inline-block; line-height: 0; border: 1px solid var(--border); }
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; font-family: Consolas, monospace; margin: 10px 0; }
.upload-progress { height: 8px; background: var(--border); border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.upload-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* Confirm dialog */
dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 22px; max-width: 440px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(20,10,5,.5); }
dialog h2 { margin-bottom: 6px; }
dialog p { color: var(--text-2); margin-bottom: 16px; }
dialog .form-actions { justify-content: flex-end; }

@media (max-width: 900px) {
    .sidebar { width: 72px; padding: 14px 8px; }
    .brand div, .nav-label, .nav-item span, .side-foot .who { display: none; }
    .nav-item { justify-content: center; }
    .grid-2, .grid-side { grid-template-columns: minmax(0, 1fr); }
    .content, .topbar { padding-left: 16px; padding-right: 16px; }
}
