:root {
    color-scheme: dark;
    font: 15px/1.5 Inter, system-ui, sans-serif;
    background: #0c1420;
    color: #eaf2f9;
    --muted: #a1b4c8;
    --border: #2a3a4e;
    --panel: #131f2f;
    --accent: #72e0af;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
a { color: inherit; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.2; margin: .75rem 0 1.5rem; }
.muted { color: var(--muted); }
.mode { margin: 0; color: var(--accent); font-size: .86rem; font-weight: 650; }
.brand { display: flex; align-items: center; gap: .7rem; font-size: 1.15rem; font-weight: 750; }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px; background: #164030; color: var(--accent); }
form { display: grid; gap: .55rem; }
form + form { margin-top: .6rem; }
input:not([type="hidden"]), button { font: inherit; min-height: 2.8rem; border-radius: 7px; }
input:not([type="hidden"]) { background: #0d1724; color: inherit; border: 1px solid var(--border); width: 100%; padding: .7rem .8rem; margin-bottom: .5rem; }
button { cursor: pointer; border: 1px solid transparent; background: var(--accent); color: #0e281e; font-weight: 750; padding: .6rem .9rem; }
button.secondary { background: #192a40; color: #eaf2f9; border-color: var(--border); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.feedback { border: 1px solid #76545f; background: #32232d; color: #ffc3cc; border-radius: 8px; padding: .75rem; }
.notice { border: 1px solid #38634e; background: #18352a; color: #b9f0d3; border-radius: 8px; padding: .75rem; }
.workspace { display: grid; grid-template-columns: 15rem minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; padding: 1.5rem 1rem; border-right: 1px solid var(--border); }
nav { display: grid; gap: .3rem; margin: 2rem 0; }
nav a { text-decoration: none; color: var(--muted); display: block; border-radius: 8px; padding: .65rem .8rem; }
nav a[aria-current], nav a:hover { background: #1c2b3f; color: #fff; }
.logout { margin-top: auto; }
.main { min-width: 0; padding: 0 clamp(1rem, 4vw, 3rem) 2rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-bottom: 1px solid var(--border); min-height: 4.25rem; margin-bottom: 2rem; }
.account { margin: 0; font-weight: 650; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 15rem)); gap: 1rem; }
.metrics a { display: grid; gap: .35rem; text-decoration: none; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1.1rem; }
.metrics a:hover { border-color: var(--accent); }
.metrics strong { font-size: 1.9rem; }
.table-panel { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
table { border-collapse: collapse; text-align: left; width: 100%; }
th, td { padding: .85rem .95rem; white-space: nowrap; }
th { color: var(--muted); background: #152336; font-size: .87rem; }
tbody tr + tr { border-top: 1px solid var(--border); }
.title-row, .row-actions { display: flex; align-items: center; gap: .8rem; }
.title-row { justify-content: space-between; flex-wrap: wrap; margin-bottom: 1.4rem; }
.title-row h1 { margin: 0; }
.button-link { display: inline-block; border-radius: 7px; padding: .6rem .9rem; background: var(--accent); color: #0e281e; font-weight: 750; text-decoration: none; }
.row-actions form { margin: 0; }
.row-actions button { min-height: 2.2rem; padding: .35rem .6rem; }
.editor { border: 1px solid var(--border); background: var(--panel); margin-bottom: 1.4rem; border-radius: 10px; padding: 1rem; }
.editor h2 { margin: 0 0 1rem; font-size: 1.15rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: .85rem 1rem; }
.fields label { display: grid; gap: .4rem; }
.fields select { width: 100%; min-height: 2.8rem; border: 1px solid var(--border); border-radius: 7px; font: inherit; background: #0d1724; color: inherit; padding: .6rem; }
.editor .row-actions { margin-top: .6rem; }
.filters > * { width: 8.75rem; text-align: center; }
.filters a { background: #192a40; color: #eaf2f9; border: 1px solid var(--border); }
.subnav { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0 0 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: .65rem; }
.subnav a { border: 1px solid transparent; }
.subnav a[aria-current] { border-color: var(--border); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .85rem; }
.detail-grid dt { color: var(--muted); font-size: .85rem; }
.detail-grid dd { margin: .2rem 0; overflow-wrap: anywhere; }
.state-badge { display: inline-block; padding: .2rem .55rem; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: .82rem; }
.state-badge.active, .state-badge.paid { background: #153d30; border-color: #315947; color: #a7f0cc; }
.state-badge.soon, .state-badge.expired, .state-badge.overdue { background: #362d1c; border-color: #665332; color: #ffe1a5; }
.check-option { display: flex; align-items: center; gap: .5rem; }
.check-option input[type="checkbox"] { width: 1rem; min-height: 1rem; padding: 0; margin: 0; accent-color: var(--accent); }
.report-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); gap: 1rem; }
.report-metrics > div { background: #0d1724; border: 1px solid var(--border); border-radius: 9px; padding: .85rem; }
.report-metrics dt { color: var(--muted); font-size: .9rem; }
.report-metrics dd { margin: .3rem 0 0; font-size: 1.2rem; font-weight: 750; }
.report-pagination { margin-top: 1rem; }
.open-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--accent); margin-left: .55rem; }
.threads { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.threads a { border: 1px solid var(--border); border-radius: 7px; padding: .45rem .7rem; text-decoration: none; }
.threads a[aria-current] { border-color: var(--accent); }
.conversation { display: grid; gap: .9rem; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); padding: 1rem; }
.message { max-width: min(43rem, 90%); justify-self: start; border: 1px solid var(--border); border-radius: 12px; padding: .7rem .85rem; background: #192b40; overflow-wrap: anywhere; }
.own-message { justify-self: end; background: #153d30; border-color: #315947; }
.message p { white-space: pre-wrap; margin: .35rem 0; }
.message time { color: var(--muted); font-size: .82rem; }
.support-form, .archive-support { margin-top: 1rem; }
.support-search { margin-bottom: .8rem; }
.support-search label { display: grid; gap: .35rem; }
.support-conversation-actions { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: 1rem; }
.support-conversation-actions .archive-support { margin: 0; }
.support-conversation-actions .archive-support[hidden] { display: none; }
.support-form button, .archive-support button { justify-self: start; }
.support-form textarea { border: 1px solid var(--border); border-radius: 7px; background: #0d1724; color: inherit; font: inherit; padding: .7rem; resize: vertical; }

@media (max-width: 680px) {
    .workspace { display: block; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--border); gap: .85rem; }
    nav { margin: 0; display: flex; flex-wrap: wrap; }
    .logout { align-self: start; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar { margin-bottom: 1.15rem; }
}
