:root {
    --ink: #1c1917;
    --muted: #57534e;
    --line: #e7e2d9;
    --paper: #f3f1ec;
    --card: #fffcf7;
    --sidebar: #1e2a32;
    --sidebar-text: #d6dde3;
    --accent: #c6522a;
    --new: #2f6fed;
    --progress: #b54708;
    --closed: #067647;
    --danger: #b42318;
    --shadow: 0 1px 2px rgba(28, 25, 23, .06);
    --sans: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--sans); color: var(--ink); background: var(--paper); font-size: 15px; line-height: 1.45; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 8px; }
h2 { margin: 0 0 8px; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 22px 16px; display: flex; flex-direction: column; gap: 18px; }
.sidebar-bar { display: flex; align-items: center; gap: 10px; }
.sidebar-panel { display: flex; flex-direction: column; gap: 18px; flex: 1; min-width: 0; min-height: 0; }
.menu-toggle { display: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; text-decoration: none; color: inherit; min-width: 0; }
.sidebar .brand { color: white; }
.mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: white; display: grid; place-items: center; font-weight: 700; }
.sidebar nav, .sidebar-foot { display: flex; flex-direction: column; gap: 4px; }
.sidebar a, .sidebar button.link { color: var(--sidebar-text); text-decoration: none; padding: 8px 10px; border-radius: 8px; background: transparent; border: 0; text-align: left; }
.sidebar > a.button { justify-content: flex-start; }
.sidebar a.active, .sidebar a:hover, .sidebar button.link:hover { background: rgba(255, 255, 255, .08); }
.sidebar .group { margin: 12px 10px 4px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: #93a1ab; }
.sidebar-foot { margin-top: auto; }
.who { padding: 8px 10px 0; font-weight: 650; color: white; }
.main { padding: 22px 28px 48px; min-width: 0; }
.boot { padding: 24px; }
.topbar, .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.topbar { margin-bottom: 16px; }
.search { flex: 1; min-width: 240px; }
.row > input, .search > input, .filters > select, .row > select { width: auto; flex: 1 1 160px; min-width: 140px; }
.topbar > .button { flex: 0 0 auto; }
input, select, textarea { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
textarea { min-height: 120px; resize: vertical; }
button, .button { border-radius: 10px; padding: 8px 14px; border: 1px solid transparent; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: white; }
button.ghost, a.ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
button.danger { background: var(--danger); }
button.link { padding: 8px 10px; }
button:disabled { opacity: .6; cursor: default; }
.banner { border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.banner.bad { background: #fde8e6; color: var(--danger); }
.banner.good { background: #e7f6ee; color: var(--closed); }
.banner.warn { background: #fff4e5; color: var(--progress); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 16px 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: 16px; align-items: start; }
.split > * { min-width: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters a, .chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 10px; text-decoration: none; color: var(--muted); }
.filters a.active, .chip.active { background: var(--sidebar); color: white; border-color: var(--sidebar); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
tr.fresh td:first-child { box-shadow: inset 3px 0 0 var(--new); }
tr.overdue { background: #fff6f5; }
.subject { font-weight: 650; text-decoration: none; }
.muted { color: var(--muted); }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 650; background: #eef2f6; }
.kicker { color: var(--muted); font-size: 13px; }
.conversation { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.post { border-radius: 10px; }
.post.opening .body { font-size: 16px; line-height: 1.65; }
.post-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.post-head .author { color: var(--new); font-weight: 700; font-size: 15px; }
.post-head .when { margin-left: auto; color: var(--ink); font-size: 13px; font-weight: 650; }
.badge.tech { background: #e7f0ff; color: var(--new); font-size: 11px; letter-spacing: .01em; }
.history { display: flex; flex-direction: column; gap: 8px; }
.history .post { padding: 12px 14px; border: 1px solid #e6e9ee; background: #f7f8fa; border-left: 3px solid var(--new); }
.history .post.note { background: #f8f4ea; border-color: #eadfc8; border-left-color: var(--progress); }
.history .post.assistant { background: #f3f7f4; border-color: #d5e6da; border-left-color: #067647; }
.history .post.system { background: #f3f4f6; border-color: #e6e8ec; border-left-color: #c5c9d1; }
.history .post.system .author { color: #3d4f63; }
.history .post.system .body { color: #3f3f46; font-size: 14px; }
.reply-panel .reply-box { margin: 0; padding: 0; border: 0; background: transparent; }
.post .body, .article-body, .composer { overflow-wrap: anywhere; }
.post .body p, .article-body p { margin: 0 0 12px; }
.post .body p:last-child, .article-body p:last-child { margin-bottom: 0; }
.post .body ul, .post .body ol, .article-body ul, .article-body ol { margin: 0 0 12px; padding-left: 22px; }
.post .body li, .article-body li { margin: 4px 0; }
.post .body a, .article-body a { color: var(--new); }
.post .body img, .article-body img, .composer img, .shot { display: block; max-width: min(100%, 960px); height: auto; margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; }
.reply-box { margin: 0; }
.side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.side p, .side a, .side li { overflow-wrap: anywhere; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span, .checkline { font-size: 13px; color: var(--muted); }
.checkline { display: flex; gap: 8px; align-items: center; color: var(--ink); }
.checkline input, .checks input { width: auto; }
.checks { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow: auto; margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-decoration: none; display: block; }
.stat strong { display: block; font-size: 28px; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; }
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(520px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.people { list-style: none; padding: 0; margin: 0 0 8px; }
.people li { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; padding: 4px 0; min-width: 0; }
.file-list { margin: 8px 0 0; padding-left: 18px; }
.file-list li { margin: 6px 0; }
.compose-screen { height: 100vh; display: flex; flex-direction: column; background: var(--paper); overflow: hidden; }
.compose-top { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--sidebar); color: white; }
.compose-top a, .compose-top strong { color: white; text-decoration: none; }
.compose-top .spacer { flex: 1; }
.compose-top button { background: var(--accent); }
.compose { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; padding: 16px 20px 20px; align-items: stretch; }
.compose-main { display: flex; flex-direction: column; min-height: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.compose-side { align-self: stretch; min-height: 0; overflow: auto; }
.subject-line input { font-size: 18px; }
.composer { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: white; }
.composer.reply { flex: none; min-height: 160px; margin-bottom: 10px; }
.composer[data-empty="true"]:before { content: attr(data-placeholder); color: var(--muted); }
.compose-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.compose-bar .muted { margin: 0; }
.more summary { cursor: pointer; font-weight: 650; }
.public-bar { display: flex; justify-content: space-between; padding: 16px 22px; background: var(--sidebar); color: white; }
.public-bar a { color: white; }
button.pick { display: flex; justify-content: flex-start; width: 100%; text-align: left; background: transparent; color: inherit; border: 0; border-radius: 0; padding: 2px 0; font-weight: 400; white-space: normal; }
.admin-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 420px); gap: 16px; align-items: start; }
.admin-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; align-items: start; }
.admin-layout > *, .admin-board > *, .split > *, .compose > * { min-width: 0; }
.table-scroll { overflow-x: auto; max-width: 100%; }
td, th { overflow-wrap: anywhere; }
input[type="file"] { max-width: 100%; }
.rule-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .8fr) minmax(0, 1.3fr) auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.rule-row .field { margin-bottom: 0; }
.rule-row .ghost { margin-bottom: 2px; }
.narrow { width: min(640px, 100%); }

@media (max-width: 1080px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: sticky; top: 0; z-index: 6; gap: 0; padding: 0; }
    .sidebar-bar { padding: 10px 12px; }
    .menu-toggle { display: inline-flex; margin-left: auto; flex: none; background: transparent; color: white; border: 1px solid rgba(255, 255, 255, .35); }
    .sidebar-panel { display: none; padding: 0 12px 12px; max-height: min(70vh, 560px); overflow: auto; }
    .sidebar.open .sidebar-panel { display: flex; }
    .sidebar nav, .sidebar-foot { flex-direction: column; }
    .sidebar-foot { margin-top: 8px; }
    .split, .admin-layout, .compose, .rule-row, .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .compose-screen { height: auto; min-height: 100vh; overflow: visible; }
    .compose-main, .composer { min-height: 40vh; }
    .compose-side { max-height: none; }
    .main { padding: 16px; }
}

@media (max-width: 720px) {
    h1 { font-size: 24px; }
    .stats { grid-template-columns: minmax(0, 1fr); }
    .main { padding: 14px 12px 32px; }
    input, select, textarea { font-size: 16px; }
    .search { flex-basis: 100%; min-width: 0; }
    .topbar > .button, .compose-top button { min-height: 44px; }
    .sidebar a, .sidebar button.link, .checkline { min-height: 44px; }
    .filters a { min-height: 36px; }
    .compose-top { flex-wrap: wrap; padding: 10px 12px; }
    .compose-top .spacer { display: none; }
    .compose-top button { margin-left: auto; }
    .compose { padding: 12px; }
    .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: auto; }
    .data-table tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
    .data-table td { border: 0; padding: 3px 0; }
    .data-table td.check:empty, .data-table td.check:not(:has(input)) { display: none; }
    .data-table td[data-label] { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px; align-items: start; }
    .data-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; letter-spacing: .03em; text-transform: uppercase; font-weight: 650; }
    .pager { flex-wrap: wrap; }
    .viewer-backdrop { padding: 8px; }
}
