:root {
  color-scheme: dark;
  --bg: #15171a;
  --bg-2: #191c20;
  --card: #1e2126;
  --card-2: #24282e;
  --card-3: #2a2f36;
  --line: #2c3138;
  --line-2: #383e46;
  --text: #e9e7e4;
  --muted: #9ba3ac;
  --faint: #767e88;
  --accent: #c9904e;
  --accent-2: #e0a866;
  --accent-dim: rgba(201, 144, 78, 0.13);
  --accent-edge: rgba(201, 144, 78, 0.28);
  --ok: #6aa77c;
  --ok-dim: rgba(106, 167, 124, 0.13);
  --warn: #d6a24c;
  --warn-dim: rgba(214, 162, 76, 0.13);
  --bad: #cc5f56;
  --bad-dim: rgba(204, 95, 86, 0.13);
  --r: 14px;
  --r-sm: 10px;
  --r-lg: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 10px 30px rgba(0, 0, 0, 0.26);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.32);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --side: 246px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

input, select, textarea, button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.num, table, .tiles, .spec-grid { font-variant-numeric: tabular-nums; }

.noscript { padding: 24px; text-align: center; color: var(--muted); }

.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot-mark { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(155deg, var(--accent), #8b5d2c); opacity: 0.6; animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 0.28; } 50% { opacity: 0.75; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { background-position: -320px 0; } 100% { background-position: 320px 0; } }

.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(410px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 30px 28px; box-shadow: var(--shadow); animation: rise 0.28s ease; }
.login-card .fields { display: grid; gap: 14px; margin-top: 22px; }
.login-lead { color: var(--muted); font-size: 14px; margin-top: 6px; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; flex: none; background: linear-gradient(155deg, var(--accent), #8b5d2c); display: grid; place-items: center; color: #1b1206; }
.brand-name { font-size: 19px; font-weight: 600; letter-spacing: 0.01em; }
.brand-sub { font-size: 12px; color: var(--faint); }

.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100dvh; }

.side { border-right: 1px solid var(--line); background: var(--bg-2); padding: 20px 14px 18px; position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 4px; }
.side-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; }

.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: var(--muted); min-height: 44px; border: 1px solid transparent; cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.nav-item:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav-item.on { background: var(--accent-dim); color: var(--accent-2); border-color: var(--accent-edge); }
.nav-item svg { flex: none; }

.topbar { display: none; }
.bottom-nav { display: none; }

.main { min-width: 0; padding: 30px 34px 64px; }
.page { max-width: 1180px; margin: 0 auto; display: grid; gap: 26px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

.sec-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--faint); font-weight: 600; margin-bottom: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-soft); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 16px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 17px 18px; box-shadow: var(--shadow-soft); }
.tile-label { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.07em; }
.tile-value { font-size: 27px; font-weight: 600; margin-top: 8px; letter-spacing: -0.02em; }
.tile-hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.tile-accent .tile-value { color: var(--accent-2); }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }

.alert-card { border-left: 3px solid var(--line-2); }
.alert-card.bad { border-left-color: var(--bad); }
.alert-card.warn { border-left-color: var(--warn); }
.alert-card.ok { border-left-color: var(--ok); }

.due-list { display: grid; }
.due-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); min-height: 52px; }
.due-row:first-child { border-top: none; }
.due-row:hover { background: var(--card-2); text-decoration: none; }
.due-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.due-title { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-sub { display: block; font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-right { font-size: 12px; text-align: right; white-space: nowrap; color: var(--muted); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--line-2); }
.dot.overdue { background: var(--bad); }
.dot.soon { background: var(--warn); }
.dot.ok { background: var(--ok); }
.dot.unknown { background: var(--faint); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line-2); color: var(--muted); background: var(--card-2); white-space: nowrap; }
.chip.bad { color: var(--bad); border-color: rgba(204, 95, 86, 0.35); background: var(--bad-dim); }
.chip.warn { color: var(--warn); border-color: rgba(214, 162, 76, 0.35); background: var(--warn-dim); }
.chip.ok { color: var(--ok); border-color: rgba(106, 167, 124, 0.35); background: var(--ok-dim); }
.chip.accent { color: var(--accent-2); border-color: var(--accent-edge); background: var(--accent-dim); }
.chip-plate { font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--card-2); color: var(--text); cursor: pointer; font-size: 14px; font-weight: 500; transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease; }
.btn:hover { background: var(--card-3); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #1b1206; }
.btn-accent:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--card-2); }
.btn-danger { background: transparent; border-color: rgba(204, 95, 86, 0.4); color: var(--bad); }
.btn-danger:hover { background: var(--bad-dim); }
.btn-soft { background: var(--accent-dim); border-color: var(--accent-edge); color: var(--accent-2); }
.btn-soft:hover { background: rgba(201, 144, 78, 0.2); border-color: var(--accent); }
.btn-sm { min-height: 34px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--card-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--bad); background: var(--bad-dim); }

.field { display: grid; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); }
.field-full { grid-column: 1 / -1; }

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.input:hover, .select:hover, .textarea:hover { border-color: #454c56; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); background: #1c1f24; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.input::placeholder, .textarea::placeholder { color: #626a74; }
.input[type="date"] { min-height: 44px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.field-act { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field-act .input { flex: 1 1 150px; min-width: 0; }
.field-act .btn { flex: 0 0 auto; min-height: 44px; }
.input.lit, .select.lit, .textarea.lit { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); transition: border-color 0.4s ease, box-shadow 0.4s ease; }

.suggest { position: fixed; z-index: 85; overflow-y: auto; padding: 5px; background: var(--card-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); box-shadow: var(--shadow); }
.suggest-item { display: flex; align-items: center; min-height: 40px; padding: 8px 11px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.suggest-item.on, .suggest-item:hover { background: var(--accent-dim); color: var(--accent-2); }

.check { display: flex; align-items: flex-start; gap: 11px; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-2); cursor: pointer; min-height: 44px; }
.check:hover { border-color: var(--line-2); }
.check input { margin: 2px 0 0; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.check > span { display: block; min-width: 0; }
.check-title { display: block; font-size: 14px; }
.check-detail { display: block; font-size: 12px; color: var(--faint); margin-top: 3px; }
.check.done .check-title { color: var(--muted); text-decoration: line-through; }

.car-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 16px; }
.car-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-soft); display: block; color: inherit; transition: border-color 0.15s ease, transform 0.15s ease; }
.car-card:hover { border-color: var(--line-2); text-decoration: none; transform: translateY(-2px); }
.car-photo { aspect-ratio: 16 / 10; background: var(--card-2); display: grid; place-items: center; color: var(--faint); overflow: hidden; }
.car-photo img { width: 100%; height: 100%; object-fit: cover; }
.car-body { padding: 14px 16px 16px; display: grid; gap: 8px; }
.car-name { font-size: 16px; font-weight: 600; }
.car-meta { font-size: 13px; color: var(--muted); }
.car-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 2px; }

.car-head { display: grid; grid-template-columns: 280px 1fr; gap: 22px; align-items: start; }
.car-head-photo { position: relative; border-radius: var(--r); overflow: hidden; background: var(--card-2); aspect-ratio: 16 / 10; display: grid; place-items: center; color: var(--faint); border: 1px solid var(--line); }
.car-head-photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-set { position: absolute; right: 10px; bottom: 10px; background: rgba(15, 17, 20, 0.82); border: 1px solid var(--line-2); border-radius: 9px; color: var(--text); }
.car-head-info { display: grid; gap: 12px; min-width: 0; }
.car-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.car-sub { color: var(--muted); font-size: 14px; }

.mileage-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.mileage-label { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.07em; }
.mileage-input { width: 130px; min-height: 40px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); padding-bottom: 0; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 11px 14px; border-radius: 10px 10px 0 0; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; min-height: 44px; display: inline-flex; align-items: center; cursor: pointer; }
.tab:hover { color: var(--text); text-decoration: none; background: var(--card); }
.tab.on { color: var(--accent-2); border-bottom-color: var(--accent); }

.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.spec { background: var(--card); padding: 12px 15px; }
.spec-k { font-size: 12px; color: var(--faint); }
.spec-v { font-size: 14px; margin-top: 3px; }

.rows { display: grid; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--line); }
.row:first-child { border-top: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 500; }
.row-sub { font-size: 12px; color: var(--faint); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.row-side { display: flex; align-items: center; gap: 6px; flex: none; }
.row-amount { font-size: 14px; font-weight: 600; white-space: nowrap; }

.empty { text-align: center; padding: 42px 24px; color: var(--muted); display: grid; gap: 12px; justify-items: center; }
.empty-mark { width: 46px; height: 46px; border-radius: 13px; background: var(--card-2); display: grid; place-items: center; color: var(--faint); }
.empty p { max-width: 380px; font-size: 14px; }

.error-block { border: 1px solid rgba(204, 95, 86, 0.35); background: var(--bad-dim); color: #edb3ad; border-radius: var(--r); padding: 14px 16px; font-size: 14px; }

.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; }
.file-card { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--card); }
.file-prev { aspect-ratio: 4 / 3; background: var(--card-2); display: grid; place-items: center; color: var(--faint); overflow: hidden; }
.file-prev img { width: 100%; height: 100%; object-fit: cover; }
.file-info { padding: 10px 12px; display: grid; gap: 6px; }
.file-name { font-size: 13px; word-break: break-word; }
.file-meta { font-size: 11px; color: var(--faint); }
.file-acts { display: flex; gap: 4px; }

.drop { border: 1px dashed var(--line-2); border-radius: var(--r); padding: 26px 20px; text-align: center; color: var(--muted); background: var(--bg-2); display: grid; gap: 12px; justify-items: center; }
.drop.big { padding: 40px 22px; }
.drop-mark { width: 54px; height: 54px; border-radius: 16px; background: var(--accent-dim); color: var(--accent-2); display: grid; place-items: center; }

.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line-2); background: var(--card-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 7px; border: none; background: rgba(15, 17, 20, 0.85); color: var(--text); display: grid; place-items: center; cursor: pointer; }

.chat-page { display: flex; flex-direction: column; gap: 14px; height: calc(100dvh - 140px); max-width: 900px; margin: 0 auto; }
.chat-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chat-scroll { flex: 1; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 84%; display: grid; gap: 6px; }
.msg-user { align-self: flex-end; }
.msg-bot { align-self: flex-start; }
.bubble { padding: 11px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card-2); font-size: 14px; overflow-wrap: anywhere; }
.msg-user .bubble { background: var(--accent-dim); border-color: var(--accent-edge); }
.msg-time { font-size: 11px; color: var(--faint); }
.msg-user .msg-time { text-align: right; }
.bubble img { border-radius: 9px; margin-top: 8px; max-height: 260px; width: auto; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 6px 0 8px; padding-left: 20px; }
.bubble li { margin: 3px 0; }
.bubble h3, .bubble h4, .bubble h5, .bubble h6 { font-size: 14px; margin: 10px 0 6px; color: var(--accent-2); }
.bubble code { background: rgba(255, 255, 255, 0.07); border-radius: 5px; padding: 1px 5px; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.bubble hr { border: none; border-top: 1px solid var(--line-2); margin: 10px 0; }

.composer { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); padding: 12px; display: grid; gap: 10px; }
.composer-row { display: flex; align-items: flex-end; gap: 10px; }
.composer .textarea { min-height: 46px; max-height: 180px; border: none; background: transparent; padding: 8px 4px; }
.composer .textarea:focus { background: transparent; }

.ai-wait { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); padding: 18px 20px; display: grid; gap: 12px; }
.ai-wait-head { display: flex; align-items: center; gap: 11px; font-size: 14px; color: var(--muted); }
.spinner { width: 17px; height: 17px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin 0.85s linear infinite; flex: none; }

.sk { height: 11px; border-radius: 6px; background: linear-gradient(90deg, var(--card-2) 25%, var(--card-3) 37%, var(--card-2) 63%); background-size: 640px 100%; animation: shimmer 1.5s linear infinite; }
.sk-1 { width: 92%; }
.sk-2 { width: 76%; }
.sk-3 { width: 58%; }
.sk-card { height: 128px; border-radius: var(--r); background: linear-gradient(90deg, var(--card) 25%, var(--card-2) 37%, var(--card) 63%); background-size: 640px 100%; animation: shimmer 1.5s linear infinite; }

.urgency { display: grid; gap: 8px; }
.urgency-bar { display: flex; gap: 5px; }
.urgency-seg { height: 7px; flex: 1; border-radius: 4px; background: var(--card-3); }
.urgency-seg.on-1 { background: var(--ok); }
.urgency-seg.on-2 { background: var(--warn); }
.urgency-seg.on-3 { background: #d9803f; }
.urgency-seg.on-4 { background: var(--bad); }

.cause { border: 1px solid var(--line); border-radius: var(--r); background: var(--card-2); padding: 14px 16px; display: grid; gap: 8px; }
.cause-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cause-label { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.cause p { font-size: 14px; color: var(--muted); }

.oem-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.oem-row:first-child { border-top: none; }
.oem-num { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; letter-spacing: 0.03em; }
.oem-brand { font-size: 12px; color: var(--muted); }
.oem-note { font-size: 12px; color: var(--faint); margin-top: 2px; }

.link-group { padding: 14px 16px; border-top: 1px solid var(--line); }
.link-group:first-child { border-top: none; }
.link-group-title { font-size: 12px; color: var(--faint); margin-bottom: 9px; word-break: break-word; }
.link-row { display: flex; gap: 8px; flex-wrap: wrap; }

.toasts { position: fixed; z-index: 90; right: 20px; bottom: 20px; display: grid; gap: 10px; max-width: min(360px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; background: var(--card-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 12px 14px; font-size: 14px; box-shadow: var(--shadow); animation: rise 0.2s ease; }
.toast-ic { color: var(--muted); display: grid; place-items: center; flex: none; }
.toast-good { border-color: rgba(106, 167, 124, 0.4); }
.toast-good .toast-ic { color: var(--ok); }
.toast-bad { border-color: rgba(204, 95, 86, 0.45); }
.toast-bad .toast-ic { color: var(--bad); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s ease, transform 0.25s ease; }

.backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(9, 10, 12, 0.66); display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.modal { width: min(560px, 100%); background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow); animation: rise 0.2s ease; margin: auto; display: flex; flex-direction: column; max-height: calc(100dvh - 40px); }
.modal-wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-error { color: #edb3ad; background: var(--bad-dim); border: 1px solid rgba(204, 95, 86, 0.35); border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.modal-text { font-size: 14px; color: var(--muted); }

.stack { display: grid; gap: 14px; }
.stack-sm { display: grid; gap: 9px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.bad-text { color: var(--bad); }
.warn-text { color: var(--warn); }
.ok-text { color: var(--ok); }
.accent-text { color: var(--accent-2); }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1080px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .car-head { grid-template-columns: 230px 1fr; }
}

@media (max-width: 899px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 20;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    padding: 10px 14px; min-height: 56px;
  }
  .topbar-title { font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { padding: 16px 16px calc(88px + env(safe-area-inset-bottom)); }
  .page { gap: 20px; }
  h1 { font-size: 22px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--bg-2);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bn-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; color: var(--faint); font-size: 11px; }
  .bn-item:hover { text-decoration: none; }
  .bn-item.on { color: var(--accent-2); }
  .car-head { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .btn { width: 100%; }
  .chat-page { height: calc(100dvh - 190px); }
  .msg { max-width: 92%; }
  .toasts { right: 12px; left: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: none; }
  .modal { max-height: calc(100dvh - 24px); }
  .modal-tools .btn { min-height: 44px; }
  .suggest-item { min-height: 44px; }
  .backdrop { padding: 12px; }
  .row { padding: 13px 16px; }
  .due-row { padding: 12px 16px; }
  .card-head { padding: 14px 16px; }
  .card-pad { padding: 16px; }
}

@media (max-width: 520px) {
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tile-value { font-size: 23px; }
  .car-grid { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .row-side { width: 100%; justify-content: flex-end; }
  .modal-head-tools .modal-tools { width: 100%; }
  .modal-head-tools .modal-tools .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.col { min-width: 0; display: flex; flex-direction: column; }
.col .main { flex: 1 1 auto; }
