:root {
  --orange: #ff8a00;
  --orange-dark: #b85a00;
  --orange-soft: #ffebd1;
  --orange-tint: #fff6ea;
  --dark: #15171d;
  --text: #15171d;
  --muted: #6b6559;
  --faint: #a8a396;
  --border: #ece6db;
  --surface: #f7f3ec;
  --bg: #fffbf5;
  --white: #fff;
  --green: #21c16b;
  --green-soft: #e4f8ec;
  --red: #ff4d4f;
  --red-soft: #ffeded;
  --blue: #4d88ff;
  --blue-soft: #e8f0ff;
  --radius: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Nunito", system-ui, sans-serif; color: var(--text); background: var(--bg); font-size: 15px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--orange-dark); }
.boot { padding: 40px; color: var(--muted); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--white); border: 1px solid var(--border); border-radius: 24px; padding: 32px; box-shadow: 0 20px 40px rgba(21,23,29,.08); display: grid; gap: 14px; }
.login-card img { width: 72px; height: 72px; justify-self: center; }
.login-card h1 { margin: 0; text-align: center; font-size: 24px; font-weight: 900; }
.login-card p { margin: 0; text-align: center; color: var(--muted); }

/* layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--dark); color: var(--white); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 20px; padding: 0 8px 18px; }
.brand img { width: 40px; height: 40px; }
.brand small { display: block; font-size: 11px; letter-spacing: .12em; color: var(--orange); font-weight: 800; }
.nav { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; color: #c9c4b8; background: none; border: 0; cursor: pointer; text-align: left; font-weight: 700; }
.nav:hover { background: #262a35; color: var(--white); }
.nav.active { background: var(--orange); color: var(--dark); }
.nav .count { margin-left: auto; background: var(--red); color: var(--white); border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 800; }
.side .spacer { flex: 1; }
.who { font-size: 13px; color: #a8a396; padding: 8px 12px; }
.main { padding: 28px 32px 60px; min-width: 0; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.head h1 { margin: 0; font-size: 28px; font-weight: 900; flex: 1; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 800; cursor: pointer; background: var(--orange); color: var(--dark); white-space: nowrap; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--white); border: 1.5px solid var(--border); }
.btn.dark { background: var(--dark); color: var(--white); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
input, select, textarea { border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--white); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: 0; border-color: var(--orange); }
.error { color: var(--red); font-weight: 700; font-size: 14px; }
.ok { color: var(--green); font-weight: 700; font-size: 14px; }
.muted { color: var(--muted); }

/* cards */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card h2 { margin: 0 0 12px; font-size: 17px; font-weight: 900; }
.kpi b { display: block; font-size: 32px; font-weight: 900; line-height: 1.1; }
.kpi span { color: var(--muted); font-weight: 700; font-size: 13px; }
.kpi.accent { background: var(--orange); border-color: var(--orange); }
.kpi.accent span { color: var(--dark); }
.bar { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 10px; margin: 8px 0; font-weight: 700; font-size: 14px; }
.bar .track { height: 10px; border-radius: 5px; background: var(--surface); overflow: hidden; }
.bar .fill { height: 100%; background: var(--orange); border-radius: 5px; }
.bar b { text-align: right; }
.recent { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 12px; align-items: center; font-size: 14px; }
.recent .muted { white-space: nowrap; }

/* tables */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type="search"] { flex: 1; min-width: 200px; }
.table-wrap { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 900px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 14px; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td select, td input { padding: 6px 8px; border-radius: 10px; font-size: 13px; width: 100%; }
td select { min-width: 150px; }
.plan-cell { min-width: 120px; }
.comment-cell { min-width: 180px; max-width: 280px; }
td .note { min-width: 160px; }
.phone { font-weight: 800; white-space: nowrap; }
.links { display: flex; gap: 8px; font-size: 13px; font-weight: 700; }
.code { font-family: "JetBrains Mono", monospace; font-weight: 600; letter-spacing: .02em; background: var(--surface); border-radius: 8px; padding: 3px 7px; white-space: nowrap; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.s-new { background: var(--red-soft); color: #c42b2d; }
.s-contacted { background: var(--blue-soft); color: #2f5fc4; }
.s-invoiced { background: var(--orange-soft); color: var(--orange-dark); }
.s-paid { background: #fff3c4; color: #8a6d00; }
.s-access { background: var(--green-soft); color: #128048; }
.s-lost { background: var(--surface); color: var(--muted); }
.yes { color: var(--green); font-weight: 800; }
.no { color: var(--faint); }

/* code dialog */
dialog { border: 0; border-radius: 24px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 30px 60px rgba(21,23,29,.25); }
dialog::backdrop { background: rgba(21,23,29,.5); }
.dialog { padding: 24px; display: grid; gap: 14px; }
.dialog h2 { margin: 0; font-size: 20px; font-weight: 900; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.row > * { flex: 1 1 0; min-width: 0; }
.field input, .field select { width: 100%; }
.issued { background: var(--orange-tint); border: 1.5px solid var(--orange); border-radius: 16px; padding: 14px; display: grid; gap: 10px; }
.issued .code { font-size: 18px; text-align: center; background: var(--white); padding: 10px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .brand { padding: 0 8px 0 0; }
  .side .spacer, .who { display: none; }
  .main { padding: 20px 16px 40px; }
  .kpis, .two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
