:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --text: #1b1b1b;
  --muted: #646464;
  --border: #e0e0dc;
  --brand: #c8101a;
  --brand-hover: #a60d15;
  --sidebar: #161616;
  --ok: #0f7a4f;
  --ok-bg: #dff3ea;
  --warn: #855600;
  --warn-bg: #fbeed2;
  --bad: #b3261e;
  --bad-bg: #fbe4e2;
  --chat: #e7ded3;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Segoe UI", system-ui, sans-serif;
}

h1 { margin: 0; font-size: 22px; }
h2 { margin: 0 0 12px; font-size: 16px; }
p { margin: 0; }
a { color: var(--brand); }

.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px 12px;
  background: var(--sidebar);
  color: #fff;
}

.brand { padding: 0 10px 20px; }
.brand strong { display: block; font-size: 23px; font-weight: 800; font-style: italic; letter-spacing: .5px; }
.brand em { color: #ff2b36; }
.brand span { color: #b5b5b5; font-size: 12px; }
.brand.dark-text em { color: var(--brand); }
.brand.dark-text span { color: var(--muted); }

#nav { display: grid; gap: 2px; }
#nav a { padding: 9px 12px; border-radius: 7px; color: #dcdcdc; text-decoration: none; font-weight: 500; }
#nav a:hover { background: #262626; color: #fff; }
#nav a.active { background: var(--brand); color: #fff; }

.who { margin: auto 0 8px; padding: 0 10px; color: #b5b5b5; font-size: 13px; overflow-wrap: anywhere; }
.logout { background: transparent; border: 1px solid #3a3a3a; color: #cfcfcf; }

.content { max-width: 1180px; width: 100%; padding: 26px 30px 56px; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head p { color: var(--muted); }

.card {
  padding: 18px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tile span { display: block; color: var(--muted); font-size: 13px; }
.tile strong { display: block; margin-top: 2px; font-size: 26px; font-variant-numeric: tabular-nums; }
.tile small { color: var(--muted); }

.steps-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

.numbers { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.number-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; }
.number-item small { display: block; color: var(--muted); }

label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }

input:not([type=checkbox]):not([type=radio]):not(.sr-only), select, textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.check { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; color: var(--text); font-size: 14px; }
.check input { margin-top: 3px; accent-color: var(--brand); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.drop { position: relative; padding: 20px 14px; border: 1.5px dashed #c9c9c4; border-radius: 8px; text-align: center; cursor: pointer; }
.drop:hover, .drop.over, .drop:focus-within { border-color: var(--brand); color: var(--brand); }

button, .button {
  display: inline-block;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 7px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--brand); color: #fff; }
.primary:hover:not(:disabled) { background: var(--brand-hover); }
.secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.secondary:hover:not(:disabled) { border-color: var(--brand); }
.danger { background: var(--surface); border-color: var(--bad); color: var(--bad); }
.small { padding: 4px 9px; font-size: 12.5px; }
.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.hint { color: var(--muted); font-size: 13px; }
.msg { margin-top: 10px; font-size: 13px; }
.msg:empty { display: none; }
.msg.error, .error-text { color: var(--bad); }
.msg.ok { color: var(--ok); }
.notice { padding: 10px 12px; margin-bottom: 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 14px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: left; }
th, td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.link-row { cursor: pointer; }
tr.link-row:hover td { background: #fafaf8; }
.empty { padding: 26px; color: var(--muted); text-align: center; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.toolbar label { margin: 0; flex: 1 1 200px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 13px; }

.wizard { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
.wizard-side { position: sticky; top: 16px; }
.num-step { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; }

.list-picks { display: grid; gap: 2px; max-height: 190px; overflow: auto; margin: 4px 0 10px 24px; }
.list-picks .check { margin-bottom: 4px; }

.phone { padding: 12px; border-radius: 8px; background: var(--chat); }
.bubble { padding: 4px; border-radius: 8px; background: #fff; }
.bubble img { display: block; width: 100%; border-radius: 6px; }
.bubble p { margin: 6px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.bubble p:empty { display: none; }
.bubble .placeholder { padding: 28px 8px; color: var(--muted); font-size: 13px; text-align: center; }

.estimate { font-weight: 600; margin-bottom: 12px; }
.estimate:empty { display: none; }

.bar { height: 9px; border-radius: 5px; background: var(--bg); overflow: hidden; }
.bar div { height: 100%; background: var(--brand); transition: width .3s; }
.mini-bar { width: 120px; height: 6px; }

.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.template-card { display: flex; flex-direction: column; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.template-card img { width: 100%; height: 150px; object-fit: cover; border-radius: 6px; margin-bottom: 8px; }
.template-card h3 { margin: 0 0 4px; font-size: 15px; }
.template-card p { flex: 1; margin-bottom: 10px; color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

.summary { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; overflow-wrap: anywhere; }

dialog { width: min(460px, calc(100vw - 32px)); padding: 20px; border: 0; border-radius: 12px; }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.qr { display: block; width: min(264px, 100%); margin: 14px auto 0; }
.qr-status { margin-top: 12px; color: var(--muted); font-size: 14px; text-align: center; }

.toast { position: fixed; right: 18px; bottom: 18px; z-index: 10; max-width: 340px; padding: 10px 14px; border-radius: 8px; background: #222; color: #fff; font-size: 14px; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: var(--sidebar); }
.login-card { width: min(370px, 100%); padding: 26px; background: var(--surface); border-radius: 12px; }
.login-card .brand { padding: 0 0 18px; text-align: center; }

@media (max-width: 880px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 12px 16px; }
  .brand { padding: 0 0 8px; }
  .brand strong { font-size: 19px; }
  #nav { display: flex; overflow-x: auto; }
  #nav a { white-space: nowrap; }
  .who { margin: 8px 0 0; padding: 0; }
  .logout { position: absolute; top: 12px; right: 16px; margin: 0; padding: 4px 10px; }
  .content { padding: 18px 16px 44px; }
  .wizard, .row { grid-template-columns: minmax(0, 1fr); }
  .wizard-side { position: static; }
}
