:root {
  --brand: #e5383b;
  --brand-ink: #ffffff;
  --brand-soft: #fdeaea;
  --bg: #faf8f5;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #ece8e1;
  --chip: #f2efea;
  --side: #0b1320;
  --side-ink: #aeb7c6;
  --side-hover: #152033;
  --good: #16803c; --good-bg: #e6f6ec;
  --bad: #b42318; --bad-bg: #fdecea;
  --warn: #a15c07; --warn-bg: #fef3dc;
  --info: #1d4ed8; --info-bg: #e8effe;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20,20,30,.04), 0 4px 14px rgba(20,20,30,.05);
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Space Grotesk", "DM Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.ico { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 256px; background: var(--side); color: var(--side-ink); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40; transition: transform .2s; }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font: 700 18px var(--font-head); }
.brand-name { color: #fff; font: 700 18px var(--font-head); line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: var(--side-ink); }
.nav { flex: 1; overflow-y: auto; padding: 8px 12px 12px; }
.nav-group { margin-top: 14px; }
.nav-title { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #6c7790; padding: 6px 10px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--side-ink); font-weight: 500; font-size: 14.5px; margin-bottom: 2px; }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.side-foot { padding: 12px 20px; font-size: 12px; color: #6c7790; border-top: 1px solid rgba(255,255,255,.07); }
.main { margin-left: 256px; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(250,248,245,.92); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 30; }
.topbar .site { color: var(--muted); font-size: 14px; }
.top-right { display: flex; align-items: center; gap: 14px; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; cursor: pointer; border-radius: 8px; }
.icon-btn { position: relative; background: none; border: 0; padding: 8px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.icon-btn:hover { background: var(--chip); }
.dot { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 5px 12px 5px 6px; background: #fff; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; font: 700 12px var(--font-head); display: grid; place-items: center; }
.user-chip b { display: block; font-size: 13px; line-height: 1.2; }
.user-chip small { color: var(--muted); font-size: 11.5px; }
.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(20,20,30,.14); padding: 6px; display: none; z-index: 50; }
.menu.open { display: block; }
.menu a, .menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; background: none; border: 0; text-align: left; cursor: pointer; font-size: 14px; }
.menu a:hover, .menu button:hover { background: var(--chip); color: var(--ink); }
.menu .head { padding: 8px 12px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.menu .alert-n { background: var(--brand-soft); color: var(--brand); border-radius: 8px; padding: 1px 8px; font-weight: 700; font-size: 12px; }
.content { padding: 26px 28px 60px; max-width: 1480px; width: 100%; }
.scrim { display: none; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 30px; line-height: 1.15; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tag-demo { font: 600 11px var(--font); letter-spacing: .06em; text-transform: uppercase; background: var(--brand-soft); color: var(--brand); border: 1px solid #f7c9ca; border-radius: 6px; padding: 3px 8px; }
.tabs { display: flex; gap: 4px; background: var(--chip); border-radius: 12px; padding: 4px; width: fit-content; max-width: 100%; overflow-x: auto; margin-bottom: 18px; }
.tabs a { padding: 8px 16px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* ---------- cards / buttons ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card h3 { font-size: 16px; margin-bottom: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 14px; cursor: pointer; background: var(--chip); color: var(--ink); white-space: nowrap; line-height: 1.2; }
.btn:hover { background: #e9e5de; color: var(--ink); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--line); }
.btn-soft { background: var(--chip); }
.btn-danger { background: var(--bad-bg); color: var(--bad); }
.btn-danger:hover { background: #fadbd7; color: var(--bad); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline { display: inline; margin: 0; }

/* ---------- quick actions / stat cards ---------- */
.quick { padding: 18px 20px; margin-bottom: 20px; }
.quick .label { font-weight: 700; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; background: var(--chip); border-radius: 9px; font-size: 13.5px; font-weight: 600; }
.chip:hover { background: #e9e5de; color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; }
.stat:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(20,20,30,.09); color: var(--ink); }
.stat-ico { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font: 700 24px var(--font-head); line-height: 1.2; }
.stat .v.money { font-size: 21px; }
.charts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.chart-card { padding: 18px 18px 12px; min-height: 290px; display: flex; flex-direction: column; }
.chart-card h3 { margin-bottom: 8px; font-size: 15px; }
.chart { flex: 1; min-height: 210px; position: relative; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-size: 12.5px; margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
.empty-chart { height: 100%; min-height: 200px; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.tip { position: absolute; pointer-events: none; background: #111827; color: #fff; padding: 5px 9px; border-radius: 7px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -120%); z-index: 5; display: none; }

/* ---------- tables ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search input { width: 100%; padding: 9px 12px 9px 36px; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fcfbf9; }
.table th a { color: inherit; }
.table th a:hover { color: var(--ink); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfbf9; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table a.row-link { font-weight: 600; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; gap: 8px; font-size: 14px; color: var(--muted); }
.pager .pages { display: flex; gap: 4px; }
.pager a, .pager span.cur { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; padding: 0 8px; font-weight: 600; }
.pager a:hover { background: var(--chip); color: var(--ink); }
.pager span.cur { background: var(--brand); color: #fff; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.summary div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 18px; min-width: 170px; box-shadow: var(--shadow); }
.summary small { color: var(--muted); display: block; font-size: 12.5px; }
.summary b { font: 700 18px var(--font-head); }

/* ---------- badges / progress ---------- */
.badge { display: inline-block; padding: 3px 10px; 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); }
.bar { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.good > i { background: #1f9d55; }
.bar.warn > i { background: #e0a21b; }
.bar.bad > i { background: var(--brand); }
.pct { font-size: 12.5px; color: var(--muted); margin-left: 8px; }
.cellflex { display: flex; align-items: center; }
.stars { color: #e0a21b; letter-spacing: 1px; }

/* ---------- forms ---------- */
label.lbl { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=password], input[type=color], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #ddd8cf; border-radius: 10px; background: #fff; outline: none; transition: border-color .12s, box-shadow .12s; }
input[type=color] { padding: 3px; height: 42px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea { min-height: 96px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px 20px; }
.form-grid .wide { grid-column: 1 / -1; }
.field .help { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.field .err { font-size: 13px; color: var(--bad); margin-top: 5px; font-weight: 500; }
.field.has-err input, .field.has-err select, .field.has-err textarea { border-color: var(--bad); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; padding: 10px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-foot { display: flex; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.req { color: var(--brand); }
.errsum { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; font-weight: 500; }

/* ---------- detail ---------- */
.detail { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px 24px; }
.detail dt { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.detail dd { margin: 0; font-weight: 500; word-break: break-word; }
.detail .wide { grid-column: 1 / -1; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stack > * + * { margin-top: 16px; }

/* ---------- flash ---------- */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 500; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.flash.success { background: var(--good-bg); color: var(--good); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.flash button { background: none; border: 0; cursor: pointer; font-size: 18px; line-height: 1; color: inherit; opacity: .6; }
.alerts-card { padding: 14px 18px; margin-bottom: 20px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.alert-pill { display: inline-flex; gap: 8px; align-items: center; background: var(--warn-bg); color: var(--warn); border-radius: 999px; padding: 6px 14px; font-size: 13.5px; font-weight: 600; }
.alert-pill b { background: #fff; border-radius: 999px; padding: 0 8px; }

/* ---------- kanban ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.board.four { grid-template-columns: repeat(4, minmax(240px, 1fr)); grid-auto-flow: row; }
.col { background: var(--chip); border-radius: 14px; padding: 12px; min-height: 160px; }
.col h4 { font: 700 13px var(--font-head); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; justify-content: space-between; margin: 2px 4px 10px; }
.kcard { background: #fff; border-radius: 10px; padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow); border: 1px solid var(--line); font-size: 14px; }
.kcard b { display: block; margin-bottom: 4px; }
.kcard .meta { color: var(--muted); font-size: 12.5px; }
.kcard select { padding: 5px 8px; font-size: 12.5px; margin-top: 8px; border-radius: 8px; }
.prio-urgent { border-left: 4px solid var(--brand); }
.prio-high { border-left: 4px solid #e0a21b; }

/* ---------- invoice editor ---------- */
.lines th, .lines td { padding: 8px 8px; }
.lines input { padding: 8px 10px; }
.totals { margin-left: auto; width: 320px; max-width: 100%; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 10px; font: 700 18px var(--font-head); }

/* ---------- auth ---------- */
.auth-bg { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 500px at 80% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 440px; padding: 34px; }
.auth-card.wide { max-width: 760px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand .brand-mark { width: 44px; height: 44px; font-size: 22px; }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 22px; }
.pw-wrap { position: relative; }
.pw-wrap button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 600; padding: 6px 8px; }
.reqs li { margin: 4px 0; }
.reqs .ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
.reqs .no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
.demo-note { background: var(--chip); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; margin-top: 18px; }
.err-page { text-align: center; padding: 80px 20px; }
.err-page .code { font: 700 72px var(--font-head); color: var(--brand); line-height: 1; }

/* ---------- misc ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 12px; justify-content: space-between; font-size: 14px; }
.timeline li:last-child { border: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.clock { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 16px 20px; margin-bottom: 16px; }
.bal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.bal { padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.bal small { color: var(--muted); }
.bal b { display: block; font: 700 22px var(--font-head); }

@media (max-width: 1200px) { .charts { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 8px 0 30px rgba(0,0,0,.25); }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .main { margin-left: 0; }
  .menu-btn { display: grid; place-items: center; }
  .topbar { padding: 0 14px; }
  .topbar .site { display: none; }
  .content { padding: 18px 14px 50px; }
  .user-chip div { display: none; }
  .user-chip { padding: 4px; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .board.four { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .charts { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-ico { width: 36px; height: 36px; }
  .stat .v { font-size: 19px; }
  .page-head h1 { font-size: 24px; }
  .board.four { grid-template-columns: 1fr; }
  .auth-card { padding: 24px; }
  .form-grid { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .no-print, .scrim { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
