@font-face {
  font-family: "Inter";
  src: url("fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --surface-3: #e8ebf2;
  --border: #e3e6ee;
  --border-strong: #d3d8e3;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #667085;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --on-primary: #ffffff;
  --danger: #dc2626;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --mark: #fde68a;
  --paper: #ffffff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 12px 32px rgba(16, 24, 40, .08);
  --shadow-lg: 0 24px 64px rgba(16, 24, 40, .24);
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1017;
    --surface: #141a24;
    --surface-2: #1b2230;
    --surface-3: #232c3d;
    --border: #252e3e;
    --border-strong: #334055;
    --text: #e8ecf3;
    --text-2: #c3cad6;
    --muted: #8b95a7;
    --primary: #8b93ff;
    --primary-hover: #a5abff;
    --primary-soft: #1f2446;
    --on-primary: #0c1017;
    --danger: #f87171;
    --warn: #fbbf24;
    --warn-soft: #3a2c0b;
    --mark: #7c5b0d;
    --paper: #f4f4f2;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .3);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 11px; width: 100%; min-width: 0; outline: none; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; accent-color: var(--primary); flex: none; margin: 0; }
textarea { resize: vertical; }
select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 16px; }
.upper { text-transform: uppercase; }
h2, h3, h4 { letter-spacing: -.015em; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: var(--surface-2); color: var(--text);
  cursor: pointer; font-weight: 550; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.btn.block { width: 100%; height: 42px; }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius-sm); border: 0; background: transparent; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link { border: 0; background: none; color: var(--primary); cursor: pointer; font-size: 12px; padding: 0; font-weight: 550; text-transform: none; letter-spacing: 0; }

/* ------------------------------------------------------------------ brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.02em; white-space: nowrap; }
.brand.big { font-size: 22px; justify-content: center; }
.logo { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, #6366f1, #8b5cf6); display: grid; place-items: center; flex: none; box-shadow: 0 4px 12px rgba(99, 102, 241, .35); color: #fff; }
.logo svg { width: 18px; height: 18px; stroke-width: 2.2; }

/* ------------------------------------------------------------------ login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(900px 500px at 50% -10%, color-mix(in srgb, var(--primary) 16%, transparent), transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 36px 32px; box-shadow: var(--shadow-md); display: grid; gap: 14px; text-align: center; }
.login-card p { margin: 0 0 6px; }
.error-text { color: var(--danger); min-height: 1.2em; font-size: 13px; margin: 0 !important; }

/* ------------------------------------------------------------------ top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1600px; margin: 0 auto; padding: 12px 24px; display: grid; grid-template-columns: 280px minmax(0, 1fr) auto; gap: 24px; align-items: center; }
.brand-wrap { display: flex; align-items: center; gap: 4px; min-width: 0; }
.search { position: relative; display: flex; align-items: center; width: 100%; max-width: 680px; }
.search > svg { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.search input { height: 42px; padding: 0 44px 0 40px; border-radius: 12px; background: var(--surface-2); border-color: transparent; }
.search input:focus { background: var(--surface); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd { position: absolute; right: 11px; font: 500 11px "Inter", ui-sans-serif, sans-serif; color: var(--muted); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; padding: 1px 7px; pointer-events: none; }
.top-actions { display: flex; gap: 4px; align-items: center; }
.top-actions .btn { margin-right: 6px; }
.only-mobile { display: none !important; }

/* ------------------------------------------------------------------ layout */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; padding: 24px; max-width: 1600px; margin: 0 auto; }
.sidebar { position: sticky; top: 91px; align-self: start; max-height: calc(100vh - 110px); overflow-y: auto; overflow-x: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; scrollbar-width: thin; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px; min-width: 0; }
.panel + .panel { margin-top: 0; }
.filters { display: grid; gap: 20px; }
.filter-group { min-width: 0; }
.filter-group h4 { margin: 0 0 10px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { min-width: 0; border: 0; background: transparent; padding: 6px 4px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 550; font-size: 13px; display: grid; place-items: center; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.small { display: inline-grid; }
.seg.small button { width: 34px; height: 32px; padding: 0; }

.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.presets button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 6px 8px; font-size: 12.5px; font-weight: 500; cursor: pointer; color: var(--text-2); white-space: nowrap; }
.presets button:hover { border-color: var(--primary); color: var(--primary); }
.presets button.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.date-range { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 6px; }
.date-range input { padding: 7px 8px; font-size: 12.5px; }
.date-range span { color: var(--muted); }

.tag-list { display: grid; gap: 1px; margin: 0 -6px 10px; }
.tag-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; user-select: none; min-width: 0; color: var(--text-2); }
.tag-row:hover { background: var(--surface-2); }
.tag-row.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tag-row .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tag-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-row .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--surface-2); border-radius: 999px; padding: 0 7px; min-width: 22px; text-align: center; }
.tag-row.active .count { background: var(--surface); color: var(--primary); }
.check { display: flex; gap: 10px; align-items: center; padding: 5px 2px; color: var(--text-2); cursor: pointer; font-size: 13.5px; }

/* stats */
.stats { display: grid; gap: 14px; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat .label { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.stat .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.stat-foot { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.stat-foot .warn { color: var(--warn); font-weight: 600; }
.stat-foot .err { color: var(--danger); font-weight: 600; }
.spark { display: grid; grid-template-columns: repeat(12, 1fr); align-items: end; gap: 4px; height: 56px; }
.spark .bar { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.spark .bar i { display: block; background: color-mix(in srgb, var(--primary) 30%, var(--surface-2)); border-radius: 3px; min-height: 3px; }
.spark .bar.now i { background: var(--primary); }
.spark .bar span { font-size: 9.5px; color: var(--muted); text-align: center; line-height: 1; }

/* ------------------------------------------------------------------ toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; min-height: 38px; }
.toolbar-right { display: flex; gap: 8px; align-items: center; }
.toolbar select { width: auto; height: 38px; padding-top: 0; padding-bottom: 0; box-shadow: var(--shadow-sm); }
.result-info { color: var(--muted); font-size: 14px; }
.result-info b { color: var(--text); font-weight: 650; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 16px; }
.active-filters:empty { display: none; }
.af { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 550; padding: 4px 6px 4px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2); }
.af button { border: 0; background: var(--surface-2); color: var(--muted); border-radius: 50%; width: 18px; height: 18px; display: grid; place-items: center; cursor: pointer; padding: 0; font-size: 13px; line-height: 1; }
.af button:hover { color: var(--text); }

/* ------------------------------------------------------------------ cards (grid view) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; min-width: 0;
  transition: transform .15s, box-shadow .15s, border-color .15s; box-shadow: var(--shadow-sm); outline: none; }
.card:hover, .card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card:focus-visible { border-color: var(--primary); }
.thumb { aspect-ratio: 4 / 3; position: relative; overflow: hidden; display: grid; place-items: center; padding: 16px 16px 0;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3)); border-bottom: 1px solid var(--border); color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 1px 2px rgba(16, 24, 40, .12)) drop-shadow(0 6px 14px rgba(16, 24, 40, .10)); }
.thumb .placeholder { display: grid; place-items: center; gap: 6px; font-size: 12px; padding-bottom: 16px; }
.thumb .placeholder svg { width: 34px; height: 34px; stroke-width: 1.5; }
.pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; text-transform: capitalize; white-space: nowrap; line-height: 18px; }
.thumb .pill { position: absolute; top: 10px; left: 10px; background: var(--surface); color: var(--text-2); box-shadow: var(--shadow); }
.thumb .pill.status { left: auto; right: 10px; }
.pill.processing { background: var(--warn-soft) !important; color: var(--warn) !important; display: inline-flex; align-items: center; gap: 4px; }
.pill.processing svg { width: 11px; height: 11px; }
.pill.error { background: var(--danger) !important; color: #fff !important; }
.card-body { padding: 12px 14px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title title" "date amount" "chips chips" "snip snip"; gap: 2px 8px; flex: 1; align-content: start; }
.c-main { display: contents; }
.c-title { grid-area: title; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.c-date { grid-area: date; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-amount { grid-area: amount; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.c-amount.none { color: var(--muted); font-weight: 500; }
.c-type { display: none; }
.chips { grid-area: chips; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; min-width: 0; }
.chips:empty { display: none; }
.chip { font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; line-height: 18px; background: color-mix(in srgb, var(--c) 13%, transparent); color: color-mix(in srgb, var(--c) 85%, var(--text)); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.snippet { grid-area: snip; font-size: 12px; line-height: 1.5; color: var(--muted); margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-strong); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ list view */
.list-head { display: none; }
.view-list .list-head { display: grid; }
.grid.list, .list-head { --cols: 48px minmax(0, 1fr) 96px 120px 110px; }
.list-head { grid-template-columns: var(--cols); gap: 16px; padding: 10px 16px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
.list-head .r { text-align: right; }
.grid.list { grid-template-columns: 1fr; gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.grid.list .card { display: grid; grid-template-columns: var(--cols); gap: 16px; align-items: center; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; }
.grid.list .card:last-child { border-bottom: 0; }
.grid.list .card:hover, .grid.list .card:focus-visible { transform: none; background: var(--surface-2); box-shadow: none; }
.grid.list .thumb { width: 48px; height: 48px; aspect-ratio: auto; padding: 4px; border-radius: 8px; border: 1px solid var(--border); }
.grid.list .thumb img { object-position: center; filter: drop-shadow(0 1px 1px rgba(16, 24, 40, .15)); }
.grid.list .thumb .pill, .grid.list .thumb .placeholder span { display: none; }
.grid.list .thumb .placeholder { padding: 0; }
.grid.list .thumb .placeholder svg { width: 20px; height: 20px; }
.grid.list .card-body { display: contents; }
.grid.list .card-body > *, .grid.list .c-main > * { grid-area: auto; }
.grid.list .c-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.grid.list .chips { margin-top: 0; }
.grid.list .c-type { display: block; color: var(--text-2); text-transform: capitalize; font-size: 13px; }
.grid.list .c-type .pill { padding: 0; }
.grid.list .c-date { font-size: 13px; color: var(--text-2); }
.grid.list .snippet { grid-column: 2 / -1; margin: -6px 0 0; padding: 0; border: 0; -webkit-line-clamp: 1; }

/* ------------------------------------------------------------------ empty / misc */
.empty { text-align: center; padding: 72px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty .ico { width: 64px; height: 64px; border-radius: 18px; display: inline-grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty .ico svg { width: 30px; height: 30px; stroke-width: 1.7; }
.empty h3 { color: var(--text); margin: 16px 0 4px; font-size: 17px; }
.empty p { margin: 0 auto; max-width: 380px; }
.empty .btn { margin-top: 18px; }
.load-more { text-align: center; margin: 24px 0; }

/* ------------------------------------------------------------------ drop overlay */
.drop-overlay { position: fixed; inset: 0; z-index: 100; background: color-mix(in srgb, var(--primary) 14%, rgba(10, 14, 25, .45)); backdrop-filter: blur(4px); display: grid; place-items: center; pointer-events: none; padding: 16px; }
.drop-box { background: var(--surface); border: 2px dashed var(--primary); border-radius: 24px; padding: 48px 64px; text-align: center; box-shadow: var(--shadow-lg); }
.drop-box svg { width: 44px; height: 44px; color: var(--primary); }
.drop-box p { font-size: 18px; font-weight: 650; margin: 12px 0 4px; }

/* ------------------------------------------------------------------ modals */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 14, 25, .55); backdrop-filter: blur(3px); animation: fade .15s; }
.modal-card { position: relative; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-height: calc(100vh - 48px); overflow: hidden; animation: pop .18s ease-out; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }

.detail-card { max-width: 1240px; height: min(900px, calc(100vh - 48px)); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr); }
.preview { position: relative; background: var(--surface-2); display: grid; place-items: center; overflow: auto; padding: 28px; border-right: 1px solid var(--border);
  background-image: radial-gradient(color-mix(in srgb, var(--muted) 18%, transparent) 1px, transparent 1px); background-size: 18px 18px; }
.preview img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; background: var(--paper); border-radius: 4px; box-shadow: 0 2px 6px rgba(16, 24, 40, .12), 0 16px 40px rgba(16, 24, 40, .16); }
.preview img.zoom { max-width: none; max-height: none; cursor: zoom-out; align-self: start; }
.preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.preview pre { background: var(--paper); color: #111; padding: 24px; border-radius: 6px; box-shadow: var(--shadow-md); white-space: pre-wrap; max-width: 100%; font: 12px/1.6 ui-monospace, monospace; }
.detail-side { display: flex; flex-direction: column; min-height: 0; }
.detail-scroll { flex: 1; overflow-y: auto; padding: 22px 24px 8px; display: flex; flex-direction: column; gap: 18px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.detail-head > div { min-width: 0; }
.detail-head h2 { margin: 0; font-size: 21px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.detail-head p { margin: 6px 0 0; }
.eyebrow { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; }
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.summary > div { padding: 12px 14px; min-width: 0; }
.summary > div + div { border-left: 1px solid var(--border); }
.summary .label { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.summary .value { font-size: 16px; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.summary .value.big { font-size: 20px; letter-spacing: -.02em; }
.summary .value.none { color: var(--muted); font-weight: 500; }
.section-title { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin: 0 0 -6px; }
.detail-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 12px; }
.detail-form label, .field { display: grid; gap: 5px; font-size: 12.5px; font-weight: 550; color: var(--text-2); min-width: 0; }
.detail-form label input, .detail-form label select, .detail-form label textarea { font-size: 14px; font-weight: 400; color: var(--text); }
.field-label { font-size: 12.5px; font-weight: 550; }
.span2 { grid-column: span 2; }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.input-prefix input { padding-left: 46px; font-variant-numeric: tabular-nums; }
.tag-editor { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 6px 8px; min-height: 40px; background: var(--surface); cursor: text; }
.tag-editor:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.tag-editor input { border: 0; box-shadow: none !important; flex: 1; min-width: 110px; padding: 3px 2px; width: auto; background: transparent; }
.tag-editor .chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 2px 4px 2px 10px; line-height: 20px; }
.tag-editor .chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 4px; font-size: 15px; line-height: 1; opacity: .6; border-radius: 50%; }
.tag-editor .chip button:hover { opacity: 1; }
.tag-editor .chip .auto { font-size: 9px; font-weight: 700; opacity: .65; text-transform: uppercase; letter-spacing: .04em; }
.content-box { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.content-box summary { padding: 11px 14px; cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; user-select: none; }
.content-box summary::-webkit-details-marker { display: none; }
.content-box summary svg { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.content-box[open] summary svg { transform: rotate(90deg); }
.content-box summary:hover { background: var(--surface-2); }
.content-box pre { margin: 0; padding: 14px; border-top: 1px solid var(--border); background: var(--surface-2); max-height: 340px; overflow: auto; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.detail-actions { display: flex; gap: 8px; align-items: center; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.spacer { flex: 1; }
.status-banner { padding: 10px 12px; border-radius: 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; font-weight: 500; }
.status-banner.processing { background: var(--warn-soft); color: var(--warn); }
.status-banner.error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

/* settings */
.settings-card { max-width: 860px; display: flex; flex-direction: column; }
.settings-card .settings-head { padding: 22px 24px 14px; border-bottom: 1px solid var(--border); }
.settings-card .settings-head p { margin: 6px 0 0; font-size: 13.5px; }
.rules-head, .rule { display: grid; grid-template-columns: 20px 200px minmax(0, 1fr) 38px; gap: 10px; align-items: start; }
.rules-head { padding: 12px 24px 6px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.rules { display: grid; gap: 8px; overflow-y: auto; padding: 4px 24px 16px; flex: 1; min-height: 0; }
.rule input[type=checkbox] { margin-top: 11px; }
.rule .r-tag { font-weight: 550; }
.rule textarea { min-height: 38px; font-size: 13px; line-height: 1.45; resize: none; overflow: hidden; field-sizing: content; }
.rule .icon-btn:hover { color: var(--danger); }
.rule.off .r-tag, .rule.off textarea { opacity: .5; }
.settings-card .detail-actions { position: static; }

/* toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: grid; gap: 8px; justify-items: end; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .2s; max-width: 380px; }
.toast.error { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .topbar-inner { grid-template-columns: auto minmax(0, 1fr) auto; }
  .layout, .topbar-inner { padding-left: 20px; padding-right: 20px; }
  .layout { grid-template-columns: 250px minmax(0, 1fr); gap: 20px; }
  .detail-card { grid-template-columns: minmax(0, 1fr) minmax(360px, 1fr); }
}
@media (max-width: 860px) {
  .only-mobile { display: inline-grid !important; }
  .only-desktop { display: none !important; }
  .topbar-inner { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand actions" "search search"; gap: 10px; padding: 10px 16px 12px; }
  .brand-wrap { grid-area: brand; }
  .top-actions { grid-area: actions; }
  .search { grid-area: search; max-width: none; }
  .search kbd { display: none; }
  .search input { padding-right: 12px; }
  .top-actions .btn { margin-right: 2px; padding: 0 12px; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: min(320px, 88vw); max-height: none; z-index: 40; background: var(--bg); padding: 16px; box-shadow: var(--shadow-lg); transform: translateX(-105%); transition: transform .22s ease; }
  .sidebar.open { transform: none; }
  .sidebar-head { display: flex !important; }
  .scrim { position: fixed; inset: 0; z-index: 39; background: rgba(10, 14, 25, .45); }
  .toolbar { gap: 10px; }
  .result-info { flex: 1 1 100%; }
  .toolbar-right { flex: 1; }
  .toolbar-right select { flex: 1; min-width: 0; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .thumb { padding: 12px 12px 0; }
  .card-body { padding: 10px 12px 12px; }
  .c-title { font-size: 14px; }
  .snippet { display: none; }
  .grid.list, .list-head { --cols: 44px minmax(0, 1fr) auto; }
  .grid.list .c-type, .list-head .h-type, .list-head .h-date { display: none; }
  .grid.list .c-date { display: none; }
  .grid.list .card { gap: 12px; padding: 10px 12px; }
  .grid.list .thumb { width: 44px; height: 44px; }
  .list-head { padding: 10px 12px; gap: 12px; }
  .modal { padding: 0; place-items: end center; }
  .modal-card { border-radius: 18px 18px 0 0; max-height: 100dvh; }
  .detail-card { height: 100dvh; border-radius: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: 34dvh minmax(0, 1fr); }
  .preview { border-right: 0; border-bottom: 1px solid var(--border); padding: 16px; }
  .detail-scroll { padding: 16px 16px 8px; }
  .detail-actions { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .detail-actions .btn { flex: 1; padding: 0 10px; }
  .detail-actions .spacer { display: none; }
  .detail-actions #dDelete { flex: 0 0 auto; }
  .summary > div { padding: 10px 12px; }
  .summary .value { font-size: 14px; }
  .summary .value.big { font-size: 17px; }
  .settings-card { height: 92dvh; }
  .rules-head { display: none; }
  .rule { grid-template-columns: 20px minmax(0, 1fr) 38px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .rule textarea { grid-column: 2 / 3; }
  .toasts { left: 16px; right: 16px; bottom: 16px; justify-items: stretch; }
}
@media (max-width: 400px) {
  .brand-text { display: none; }
}

/* ================================================================== v1.1 additions */
:root { --chart: #4f46e5; --chart-grid: #e8ebf2; --ok: #059669; }
@media (prefers-color-scheme: dark) { :root { --chart: #7c7ff5; --chart-grid: #232c3d; --ok: #34d399; } }
.count-pill { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--warn-soft); color: var(--warn); border-radius: 999px; padding: 0 7px; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }

/* export menu */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 290px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); padding: 6px; }
.menu a { display: block; padding: 9px 11px; border-radius: 8px; cursor: pointer; color: var(--text); text-decoration: none; }
.menu a:hover { background: var(--surface-2); }
.menu a b { display: block; font-weight: 600; font-size: 13.5px; }
.menu a span { font-size: 12px; color: var(--muted); }

/* selection */
.card .sel { position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 7px; border: 2px solid #fff; background: rgba(15, 23, 42, .35); display: none; place-items: center; color: #fff; box-shadow: var(--shadow); z-index: 2; }
.card .sel svg { width: 15px; height: 15px; stroke-width: 3; opacity: 0; }
.selecting .card .sel { display: grid; }
.selecting .card .thumb .pill.status { display: none; }
.card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary), var(--shadow-md); }
.card.selected .sel { background: var(--primary); border-color: var(--primary); }
.card.selected .sel svg { opacity: 1; }
.card { position: relative; }
.grid.list .card .sel { position: static; grid-column: 1; display: none; }
.selecting .grid.list .card .sel { display: grid; position: absolute; left: 8px; top: 50%; transform: translateY(-50%); border-color: var(--border-strong); }
.bulkbar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 8px 8px 8px 16px; width: min(940px, calc(100vw - 32px)); flex-wrap: wrap; animation: pop .2s; }
.bulkbar #bulkCount { font-weight: 650; }
.pill.dup { background: var(--warn-soft); color: var(--warn); }
.pill.src { background: var(--surface); color: var(--text-2); }

/* reminders */
.reminders { display: grid; gap: 6px; }
.rem { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); cursor: pointer; text-align: left; border: 0; width: 100%; color: inherit; }
.rem:hover { background: var(--primary-soft); }
.rem .ri { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--surface); color: var(--primary); }
.rem .ri svg { width: 16px; height: 16px; }
.rem b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rem span { font-size: 12px; color: var(--muted); }
.rem .soon { color: var(--warn); font-weight: 650; }
.rem > div { min-width: 0; }

/* detail extras */
.preview { position: relative; }
.preview-toggle { position: absolute; z-index: 3; margin: 14px; }
.status-banner.dup { background: var(--warn-soft); color: var(--warn); flex-wrap: wrap; }
.status-banner.dup .link { font-size: 13px; }
.items { width: 100%; border-collapse: collapse; font-size: 13px; border-top: 1px solid var(--border); }
.items td { padding: 7px 14px; border-bottom: 1px solid var(--border); }
.items td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.items tr:last-child td { border-bottom: 0; }

/* settings tabs */
.settings-card { height: min(820px, calc(100vh - 48px)); }
.tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--border); overflow-x: auto; flex: none; }
.tabs button { border: 0; background: none; padding: 12px 10px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.pane-intro { margin: 14px 24px 0; font-size: 13.5px; }
.pane-body { padding: 18px 24px 24px; overflow-y: auto; flex: 1; display: grid; gap: 14px; align-content: start; }
.box { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface); }
.box h3 { margin: 0 0 4px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.box p { margin: 4px 0; color: var(--muted); font-size: 13.5px; }
.box code, .pane-body code { font: 12.5px ui-monospace, monospace; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; color: var(--text-2); }
.kvs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13.5px; margin-top: 8px; }
.kvs dt { color: var(--muted); }
.kvs dd { margin: 0; overflow-wrap: anywhere; }
.badge-ok, .badge-off, .badge-err { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.badge-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge-off { background: var(--surface-2); color: var(--muted); }
.badge-err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.dev { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.dev:last-child { border-bottom: 0; }
.dev .di { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.dev .dm { flex: 1; min-width: 0; }
.dev .dm b { display: block; font-size: 14px; }
.dev .dm span { font-size: 12.5px; color: var(--muted); }
.snap-list { font-size: 13px; display: grid; gap: 4px; margin-top: 8px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* reports */
.reports-card { max-width: 1040px; height: min(900px, calc(100vh - 48px)); display: flex; flex-direction: column; }
.r-controls { display: flex; gap: 8px; align-items: center; }
.r-controls select { width: auto; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.tile .value { font-size: 24px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .sub { font-size: 12px; color: var(--muted); }
.r-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.chart-box h3 { margin: 0 0 2px; font-size: 14.5px; }
.chart-box .sub { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-l { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-t { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .bar { fill: var(--chart); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart g.on .bar { fill: var(--primary-hover); }
.hbars { display: grid; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(0, 150px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; cursor: default; }
.hbar .nm { display: flex; align-items: center; gap: 7px; min-width: 0; }
.hbar .nm i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.hbar .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 12px; background: var(--surface-2); border-radius: 0 4px 4px 0; }
.hbar .fill { height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .v { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.hbar .v small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.r-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.r-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.r-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.r-table td.n, .r-table th.n { text-align: right; }
.r-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chart-tip { position: fixed; z-index: 300; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12.5px; padding: 7px 10px; border-radius: 8px; box-shadow: var(--shadow-md); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-tip b { display: block; }
@media (max-width: 860px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .r-grid { grid-template-columns: 1fr; }
  .bulkbar { bottom: 10px; }
  .bulkbar .link { display: none; }
}
/* charts must not inherit the icon stroke style (svg { stroke: currentColor }) */
.chart svg, .chart svg * { stroke: none; }
.chart svg .grid-l { stroke: var(--chart-grid); stroke-width: 1; }
.btn.ghost.on { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
