:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #1d1f26; --muted: #6b7280; --border: #e5e7eb; --accent: #f26b38; --accent-ink: #ffffff;
  --side: #1d1f26; --side-2: #262932; --side-text: #e8e9ec; --side-muted: #9aa0ab;
  --good: #1f9d55; --good-bg: #e6f6ec; --bad: #d64545; --bad-bg: #fdecec; --warn: #b7791f; --warn-bg: #fdf3e1; --info: #2f6fdb; --info-bg: #e8f0fd;
  --row-hover: #fafafb; --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b; --card: #1c1f26; --text: #e8e9ec; --muted: #9aa0ab; --border: #2c303a; --side: #0f1115; --side-2: #1a1d23;
    --good-bg: #173324; --bad-bg: #3a1c1c; --warn-bg: #3a2e15; --info-bg: #1a2a45; --row-hover: #22262e; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; }
h3 { font-size: 15px; margin: 0 0 10px; font-weight: 650; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Consolas, monospace; word-break: break-all; }
[hidden] { display: none !important; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.side { width: 250px; flex: none; background: var(--side); color: var(--side-text); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding-bottom: 24px; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { padding: 18px 28px 40px; outline: none; max-width: 1600px; width: 100%; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .14em; font-size: 22px; color: #fff; padding: 22px 24px 18px; }
.brand:hover { text-decoration: none; }
.brand-dark { color: var(--text); justify-content: center; padding: 0 0 6px; }
.brand-sun { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(242, 107, 56, .25), 0 0 18px rgba(242, 107, 56, .5); }
.side-user { display: flex; gap: 12px; align-items: center; padding: 12px 24px 16px; border-bottom: 1px solid var(--side-2); margin-bottom: 6px; }
.side-user-name { font-weight: 600; } .side-user-role { color: var(--side-muted); font-size: 12px; }
.side-group { width: 100%; display: flex; align-items: center; gap: 12px; background: none; border: 0; color: var(--side-text); padding: 12px 24px; font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.side-group:hover { background: var(--side-2); }
.side-group .chev { margin-left: auto; transition: transform .15s; display: flex; }
.side-group[aria-expanded="true"] .chev { transform: rotate(180deg); }
.side-items { padding: 2px 0 8px; }
.side-items a { display: block; color: var(--side-muted); padding: 7px 24px 7px 54px; font-size: 13.5px; border-left: 3px solid transparent; }
.side-items a:hover { color: #fff; text-decoration: none; background: var(--side-2); }
.side-items a.active { color: #fff; border-left-color: var(--accent); background: var(--side-2); }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 28px; background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.top-spacer { flex: 1; }
.input.quick-add { width: auto; min-width: 180px; background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 8px; border: 0; background: transparent; color: var(--text); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--bg); text-decoration: none; }
.burger { display: none; }
.bell-count { position: absolute; top: 2px; right: 2px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }

/* page head */
.page-head { margin-bottom: 16px; }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.crumbs a { color: var(--muted); display: inline-flex; } .crumbs .ico { width: 16px; height: 16px; }
.page-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-line { display: flex; gap: 12px; align-items: center; margin: -4px 0 12px; }

/* cards & grids */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.stack > .card { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--text); display: block; }
.kpi:hover { border-color: var(--accent); text-decoration: none; }
.kpi-label { color: var(--muted); font-size: 12.5px; } .kpi-value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9cdd4; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #e05a28; border-color: #e05a28; }
.btn-dark { background: #2b2f3a; border-color: #2b2f3a; color: #fff; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-ghost { color: var(--bad); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; padding: 10px; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 10px; }
.input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; min-height: 36px; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(242, 107, 56, .18); }
textarea.input { resize: vertical; }
.input.readonly { background: var(--bg); color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.modal-wide .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.field-wide { grid-column: 1 / -1; }
.field-check { display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }
.field-check label { margin: 0; }
.field-err { color: var(--bad); font-size: 12px; min-height: 0; }
.req { color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* picker */
.picker { position: relative; }
.picker-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 2px); background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); max-height: 260px; overflow-y: auto; }
.picker-item { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; }
.picker-item:hover, .picker-item:focus { background: var(--bg); }

/* tables */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .input { width: auto; min-width: 170px; }
.search-wrap { position: relative; flex: 1; min-width: 220px; }
.search-wrap .ico { position: absolute; left: 10px; top: 9px; color: var(--muted); }
.search-wrap .input { padding-left: 34px; width: 100%; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 12px; font-weight: 650; color: var(--muted); border-bottom: 1px solid var(--border); padding: 8px 10px; white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-compact td { padding: 7px 10px; }
.table tfoot td { font-weight: 700; border-bottom: 0; }
.table .num { text-align: right; }
.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
th[aria-sort="ascending"] .th-sort::after { content: " ▲"; } th[aria-sort="descending"] .th-sort::after { content: " ▼"; }
.row-link { cursor: pointer; } .row-link:hover td { background: var(--row-hover); }
.empty { text-align: center; color: var(--muted); padding: 30px !important; }
.list-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 8px; flex-wrap: wrap; }
.pager { display: flex; gap: 6px; align-items: center; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-good { background: var(--good-bg); color: var(--good); } .badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-warn { background: var(--warn-bg); color: var(--warn); } .badge-info { background: var(--info-bg); color: var(--info); }

/* detail */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 24px; margin: 0; }
.dl-item dt { font-size: 12px; color: var(--muted); } .dl-item dd { margin: 2px 0 0; font-weight: 500; white-space: pre-wrap; word-break: break-word; }
.dl-wide { grid-column: 1 / -1; }
.note-form { margin-bottom: 14px; }
.note { border-top: 1px solid var(--border); padding: 10px 0; }
.note-head { display: flex; gap: 10px; align-items: baseline; } .note-body { white-space: pre-wrap; margin-top: 4px; }
.timeline { list-style: none; padding: 0; margin: 0; } .timeline > li { border-left: 2px solid var(--border); padding: 4px 0 12px 14px; }
.changes { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.dropzone { display: block; border: 2px dashed var(--border); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; margin-bottom: 12px; }
.dropzone input { display: block; margin: 0 auto 6px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; }
.file-ico { width: 54px; height: 54px; display: grid; place-items: center; background: var(--bg); border-radius: 6px; font-size: 11px; font-weight: 700; color: var(--muted); }

/* notifications */
.notif-list { max-width: 820px; margin: 10px auto; }
.notif-sep { background: #2b2f3a; color: #fff; text-align: center; font-weight: 600; padding: 6px; border-radius: 6px; margin: 16px 0 10px; }
.notif { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.notif.unread { border-color: #f3a0a0; background: var(--bad-bg); }
.notif-body { flex: 1; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #5b6170; color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; }

/* modal & toast */
.modal-back { position: fixed; inset: 0; background: rgba(15, 17, 21, .55); display: grid; place-items: start center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--card); color: var(--text); border-radius: 12px; width: min(720px, 100%); box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
.modal-wide { width: min(1040px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #2b2f3a; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); transition: opacity .4s, transform .4s; max-width: 380px; }
.toast-err { background: var(--bad); } .toast.out { opacity: 0; transform: translateY(8px); }
.loading { color: var(--muted); padding: 30px; text-align: center; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 30% 20%, rgba(242, 107, 56, .18), transparent 50%), var(--side); }
.login-card { background: var(--card); padding: 30px; border-radius: 14px; width: min(380px, 100%); display: grid; gap: 8px; box-shadow: 0 30px 80px rgba(0, 0, 0, .4); }
.login-card label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 6px; }
.login-card p { text-align: center; margin: 0 0 6px; }

/* responsive */
@media (max-width: 960px) {
  .side { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  body.side-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  .burger { display: inline-flex; }
  main { padding: 14px 16px 30px; }
  .top { padding: 8px 16px; }
  .grid-2, .grid-3, .form-grid, .modal-wide .form-grid { grid-template-columns: 1fr; }
  .quick-add { min-width: 0; max-width: 150px; }
}
@media print { .side, .top, .actions, .tabs { display: none !important; } main { padding: 0; } .card { box-shadow: none; } }

/* list: selection, bulk bar, column chooser */
.table th.sel, .table td.sel { width: 34px; padding-right: 0; }
.row-link.selected td { background: rgba(242, 107, 56, .07); }
.row-link.highlight td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; margin-bottom: 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); }
.bulk-bar .input { width: auto; min-width: 170px; }
.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 14px; margin-bottom: 10px; }
.col-choice { display: flex; gap: 6px; align-items: center; }

.multi { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 6px 0; }
.multi-opt { display: inline-flex; gap: 4px; align-items: center; font-size: 13px; color: var(--text) !important; font-weight: 400 !important; margin: 0 !important; }
.file-cat { width: auto; min-width: 150px; max-width: 200px; }
.brand-logo { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; background: #fff; }
.app-footer { padding: 14px 28px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); }
.col-order { list-style: none; padding: 0; margin: 0 0 10px; max-height: 55vh; overflow-y: auto; }
.col-order li { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border); }
.col-move { display: flex; gap: 4px; }
