:root {
  --ink: #1c1f24;
  --muted: #5c6570;
  --line: #e4e6ea;
  --paper: #f6f7f9;
  --card: #ffffff;
  --side: #1f2328;
  --side-2: #2a3036;
  --accent: #e4570f;
  --accent-2: #c2410c;
  --ok: #067647;
  --warn: #b45309;
  --bad: #b42318;
  --info: #344054;
  --shadow: none;
  font-size: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, "Segoe UI", "Noto Sans", sans-serif;
  font-size: 14px;
  line-height: 1.4;
  overflow-x: clip;
}
a { color: #9a3412; }
img { max-width: 100%; }

.shell { display: flex; min-height: 100vh; align-items: stretch; min-width: 0; max-width: 100%; }
.side {
  width: 216px;
  flex: 0 0 216px;
  background: var(--side);
  color: #e6e8eb;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side .brand { display: flex; align-items: center; padding: 12px 14px; text-decoration: none; border-bottom: 1px solid #343a40; }
.side .brand img { height: 36px; width: auto; display: block; background: white; border-radius: 4px; }
.side nav { display: flex; flex-direction: column; padding: 8px 0; }
.side nav a {
  color: #c9cdd2;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-left: 2px solid transparent;
}
.side nav a:hover { background: var(--side-2); color: white; }
.side nav a.active { background: var(--side-2); color: white; border-left-color: var(--accent); }
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: white;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-row { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 48px; }
.top-meta { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.top-meta form { margin: 0; }
.top-meta .quiet { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13px; }
.top-meta .quiet.active { color: var(--accent); }
.who-name { font-size: 13px; color: var(--muted); }

.main { padding: 16px 20px 48px; width: 100%; min-width: 0; max-width: 100%; }
h1 { font-size: 20px; line-height: 1.25; margin: 0 0 6px; font-weight: 650; letter-spacing: 0; }
h2 { font-size: 15px; margin: 16px 0 6px; font-weight: 650; }
h3 { margin: 0 0 6px; font-size: 14px; font-weight: 650; }
.lead { color: var(--muted); margin: 0; max-width: 78ch; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.top-row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }

.card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: none;
  padding: 12px;
}
.stack { display: grid; gap: 8px; }
.request-row h2 { margin: 2px 0; font-size: 15px; }
table.fit form { margin-top: 4px; }
table.fit button, table.fit .btn { white-space: nowrap; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat strong { display: block; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 12px; }

button, .btn, button.small, .btn.small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid #d0d5dd;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.primary:hover, .btn.primary:hover { background: var(--accent-2); }
button.ghost, .btn.ghost { background: white; color: var(--ink); }
button.line, .btn.line { background: white; color: var(--accent-2); border-color: #f0b48a; }
button.line:hover, .btn.line:hover { background: #fff7f2; }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.field { margin-bottom: 10px; width: 100%; min-width: 0; }
.span-2 { grid-column: 1 / -1; }
input:not([type]),
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="email"],
input[type="url"], input[type="search"], input[type="tel"], select, textarea, input[type="file"] {
  width: 100%;
  max-width: 100%;
  font: inherit;
  font-size: 13px;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d0d5dd;
  background: white;
  color: var(--ink);
}
textarea { min-height: 88px; display: block; resize: vertical; }
textarea.letter { min-height: 168px; font-family: "Segoe UI", sans-serif; }
.file-ui { position: relative; display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; }
.file-ui input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-caption { color: var(--muted); font-size: 12px; }
table .actions input, table input[style] { width: auto; }
.dt-container { font-size: 13px; }
.dt-container .dt-layout-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; margin: 6px 0; }
.dt-container input[type="search"], .dt-container select { width: auto; min-width: 160px; padding: 4px 8px; }
table.fit { width: 100% !important; table-layout: fixed; }
table.fit td { overflow-wrap: break-word; }
table.fit th { overflow-wrap: normal; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; color: var(--ink); font-size: 13px; }
.check input { width: 14px; height: 14px; margin: 0; }

.flash { padding: 8px 10px; border-radius: 4px; margin-bottom: 10px; border: 1px solid var(--line); font-size: 13px; }
.flash.info { background: #f4f6f8; }
.flash.ok { background: #f3faf6; color: var(--ok); }
.flash.error { background: #fef3f2; color: var(--bad); }
.flash.warn { background: #fffaeb; color: var(--warn); }

.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 12px; flex-wrap: wrap; }
.steps li { padding: 3px 8px; border-radius: 4px; background: white; border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.steps li.now { background: var(--ink); color: white; border-color: var(--ink); }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.crumbs a { color: var(--muted); text-decoration: none; font-weight: 600; }
.crumb-sep { color: #98a2b3; }
.request-head { margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.request-now { margin: 0; color: var(--muted); font-size: 13px; }
.stage-stepper { display: flex; gap: 0; list-style: none; padding: 0; margin: 10px 0 0; overflow: hidden; }
.stage-stepper li {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  border-top: 2px solid var(--line);
  border-radius: 0;
  padding: 8px 8px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.step-n {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  background: #eef0f3;
  color: var(--muted);
}
.step-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-stepper li.done { color: var(--ok); border-top-color: #abefc6; }
.stage-stepper li.done .step-n { background: #ecfdf3; color: var(--ok); }
.stage-stepper li.now { color: var(--ink); border-top-color: var(--accent); }
.stage-stepper li.now .step-n { background: var(--accent); color: white; }

.table-wrap { overflow-x: clip; max-width: 100%; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.fit td { overflow: hidden; }
table.fit td:last-child { overflow: visible; }
table.fit td button, table.pick td button { display: flex; width: 100%; margin-top: 4px; }
table.data th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 650; background: #fafbfc; }
tr.problem { background: #fffaeb; }
tr.manual { background: #f8fafc; }
tr.cancelled td.name { text-decoration: line-through; color: #98a2b3; }
tr.bad-price { background: #fffaeb; }
tr.overdue { background: #fef3f2; }

.badge, .mark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  background: #f2f4f7;
  color: #344054;
  border: 1px solid #e4e7ec;
  line-height: 1.35;
  vertical-align: middle;
}
.badge::before, .mark::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #98a2b3;
  display: inline-block;
  flex: 0 0 auto;
}
.badge.warn { background: #fffaeb; color: #b54708; border-color: #fedf89; }
.badge.ok { background: #ecfdf3; color: #067647; border-color: #abefc6; }
.badge.bad { background: #fef3f2; color: #b42318; border-color: #fecdca; }
.badge.info { background: #f2f4f7; color: #344054; border-color: #e4e7ec; }
.badge.demo { background: #f2f4f7; color: #667085; border-color: #e4e7ec; }
.badge.warn::before { background: var(--warn); }
.badge.ok::before { background: var(--ok); }
.badge.bad::before { background: var(--bad); }
.badge.copper::before { background: var(--accent); }
.badge.info::before { background: #475467; }
.badge.demo::before { background: #98a2b3; }
.badge:empty { width: 8px; height: 8px; padding: 0; border: 0; background: transparent; }
.badge:empty::before { width: 8px; height: 8px; }
.missing-mail { color: var(--muted); font-size: 13px; }
td.clip { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap, td.nowrap { white-space: nowrap; }

.empty { border: 1px dashed #d0d5dd; border-radius: 6px; padding: 16px; background: white; }
.empty h2 { margin-top: 0; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters .field { flex: 1 1 160px; width: auto; }
.kanban { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.stage-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.stage-tabs a {
  text-decoration: none;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 650;
}
.stage-tabs a.active { background: var(--ink); color: white; border-color: var(--ink); }
table.pick { width: 100%; table-layout: fixed; }
table.pick th, table.pick td { overflow-wrap: break-word; }
table.pick .mark { white-space: nowrap; }
table.pick input.mail-inline { min-height: 32px; margin-top: 4px; }
tr.gap { background: #fffaeb; }
.coverage { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.coverage span { background: white; border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; font-size: 12px; }
.coverage span.gap { background: #fffaeb; border-color: #f5d48a; }
.pipe { background: white; border: 1px solid var(--line); border-radius: 6px; padding: 8px; min-height: 80px; }
.pipe h2 { font-size: 12px; margin: 0 0 6px; }
.pipe-card { display: grid; gap: 2px; padding: 6px; margin-bottom: 6px; border-radius: 4px; background: var(--paper); color: inherit; text-decoration: none; border: 1px solid var(--line); }
.filter-input { width: 100%; margin: 6px 0 10px; }

.bell { position: relative; }
.bell summary { cursor: pointer; list-style: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 4px; color: var(--ink); }
.bell summary::-webkit-details-marker { display: none; }
.bell-icon { width: 18px; height: 18px; display: block; }
.bell-badge {
  position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--bad); color: white; font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}
.bell-panel {
  position: absolute; right: 0; top: 36px; width: min(320px, 80vw); max-height: 70vh; overflow: auto;
  background: white; border: 1px solid var(--line); border-radius: 6px; padding: 8px; z-index: 40;
  display: grid; gap: 4px;
}
.bell-panel a { color: var(--ink); text-decoration: none; font-size: 13px; }
.bell-label { margin: 4px 0 0; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.bell-row { display: grid; gap: 2px; padding: 6px; border-radius: 4px; background: var(--paper); }
.bell-all { font-weight: 650; }

.bar-row { display: grid; grid-template-columns: minmax(100px, 180px) 1fr 48px; gap: 8px; align-items: center; margin: 4px 0; }
.bar { background: #eef0f3; border-radius: 4px; height: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
.best-price { background: #f3faf6; font-weight: 650; }
.preview { background: #fafbfc; border: 1px solid var(--line); border-radius: 4px; padding: 10px; margin-top: 8px; }
.preview pre { white-space: pre-wrap; font-family: inherit; margin: 0; font-size: 13px; }
.order-block { margin-bottom: 12px; }
.progress { height: 8px; background: #eef0f3; border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.log { max-height: 280px; overflow: auto; background: #fafbfc; border: 1px solid var(--line); border-radius: 4px; padding: 8px; font-size: 12px; white-space: pre-wrap; }
.sticky-action {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  background: white; color: var(--ink); padding: 8px 10px; border-radius: 6px; margin-top: 12px; border: 1px solid var(--line);
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--paper); }
.login-card { width: min(400px, 100%); }
.login-card .brand img { height: 40px; }
.demo-box { margin-top: 12px; padding: 8px 10px; background: #fafbfc; border: 1px solid var(--line); border-radius: 4px; font-size: 12px; }
.toast { position: fixed; right: 12px; top: 56px; z-index: 30; max-width: 360px; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side { width: 100%; height: auto; position: relative; flex-basis: auto; }
  .side nav { flex-direction: row; overflow-x: auto; }
  .side nav a { white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; }
  .side nav a.active { border-bottom-color: var(--accent); }
  .grid-2, .grid-3, .stats { grid-template-columns: 1fr 1fr; }
  .top-row, .sticky-action { flex-direction: column; align-items: stretch; }
  .who-name { display: none; }
}
@media (max-width: 640px) {
  .stats, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .main { padding: 12px; }
}
@media print {
  .side, .topbar, .no-print, .toast, .bell { display: none !important; }
  .main { max-width: none; padding: 0; }
  body { background: white; }
}
