:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1b2433;
  --muted: #5d6b80;
  --line: #dfe4ec;
  --brand: #1f4e8c;
  --brand-ink: #ffffff;
  --brand-soft: #e8eff9;
  --ok: #1d7a46;
  --ok-soft: #e4f4ea;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --bad: #b3261e;
  --bad-soft: #fde8e6;
  --info-soft: #eef1f6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161e; --card: #19202b; --ink: #e6ebf2; --muted: #9aa7b9; --line: #2b3544;
    --brand: #6f9fe0; --brand-ink: #0d1520; --brand-soft: #1d2a3d;
    --ok: #6fcf97; --ok-soft: #173225; --warn: #f0b860; --warn-soft: #3a2c12;
    --bad: #f28b82; --bad-soft: #3d1d1b; --info-soft: #1f2733;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11161e; --card: #19202b; --ink: #e6ebf2; --muted: #9aa7b9; --line: #2b3544;
  --brand: #6f9fe0; --brand-ink: #0d1520; --brand-soft: #1d2a3d;
  --ok: #6fcf97; --ok-soft: #173225; --warn: #f0b860; --warn-soft: #3a2c12;
  --bad: #f28b82; --bad-soft: #3d1d1b; --info-soft: #1f2733;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Noto Sans Armenian", "Segoe UI", system-ui, -apple-system, sans-serif;
}
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
[hidden] { display: none !important; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px;
  padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand small { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; padding-left: 10px; border-left: 1px solid var(--line); }
.logo-img { display: block; height: 24px; width: auto; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav a {
  padding: 7px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500;
}
nav a.on { background: var(--brand-soft); color: var(--brand); }
nav a .badge { margin-left: 4px; }
.who { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.loading { padding: 60px; text-align: center; color: var(--muted); }

/* cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }

/* forms */
label { display: block; font-size: 13px; color: var(--muted); font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 4px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type=checkbox] { width: auto; margin: 0 6px 0 0; vertical-align: -2px; }
.check { display: flex; align-items: center; color: var(--ink); font-size: 14px; }
button, .btn {
  font: inherit; font-weight: 600; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink);
  border-radius: 8px; padding: 8px 16px; cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap;
}
button.ghost, .btn.ghost { background: transparent; color: var(--brand); }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button.link { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 500; }
button:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
button.sm, .btn.sm { padding: 4px 10px; font-size: 13px; }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--info-soft); white-space: nowrap; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--brand-soft); }
td.lot { font-weight: 700; white-space: nowrap; }
td .name { font-weight: 600; }
td.namecell { min-width: 240px; }
td .brandline { color: var(--muted); font-size: 13px; }
details.spec summary { cursor: pointer; color: var(--brand); font-size: 13px; margin-top: 2px; }
details.spec p { margin: 6px 0 0; font-size: 13px; color: var(--muted); max-width: 560px; white-space: pre-wrap; }
td input.qty { width: 92px; text-align: right; }
tfoot td { font-weight: 600; background: var(--info-soft); }

/* badges & notes */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--info-soft); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.note { border-radius: 8px; padding: 10px 14px; margin: 0 0 14px; font-size: 14px; background: var(--info-soft); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.ok { background: var(--ok-soft); color: var(--ok); }
ul.warns { margin: 4px 0 0; padding-left: 18px; color: var(--warn); font-size: 12px; }
.extra { color: var(--warn); font-size: 12px; font-weight: 600; }
.zero { color: var(--muted); }

/* contract cards (buyer) */
.ccard { display: block; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.ccard:hover { border-color: var(--brand); }
.ccard .no { font-weight: 700; font-size: 15px; word-break: break-word; }
.ccard .meta { color: var(--muted); font-size: 13px; margin-top: 6px; }
.bar { height: 6px; border-radius: 6px; background: var(--info-soft); margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); }
.section-title { margin: 22px 0 10px; font-size: 14px; font-weight: 600; color: var(--muted); text-transform: none; }

/* login */
.login { max-width: 380px; margin: 8vh auto; }
.login-logo { display: block; width: 150px; height: auto; margin: -8px auto 6px; }
.login h1 { text-align: center; }
.login form > * + * { margin-top: 12px; }
.login button { width: 100%; }

/* order bar */
.orderbar { position: sticky; bottom: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 14px; box-shadow: 0 -2px 12px rgba(20,30,50,.08); display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.orderbar textarea { min-height: 40px; height: 40px; }
.orderbar .grow { flex: 1; min-width: 220px; }

/* admin editor */
.lotedit td { padding: 6px; }
.lotedit input, .lotedit select, .lotedit textarea { padding: 6px 8px; font-size: 13px; }
.lotedit textarea { min-height: 54px; }
.lotedit .w-lot { width: 70px; }
.lotedit .w-num { width: 100px; }
.lotedit .w-unit { width: 70px; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 8px; font-weight: 500; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); z-index: 50; }
#toast.on { opacity: 1; }
#toast.err { background: var(--bad); color: #fff; }

@media (max-width: 760px) {
  .top { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .brand small { display: none; }
  .who { order: 2; margin-left: auto; }
  nav { order: 3; flex-basis: 100%; }
  main { padding: 16px; }
  h1 { font-size: 19px; }
  th, td { padding: 8px; }
  .orderbar { position: static; }
}
