:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #6b7785;
  --line: #e3e7ec;
  --accent: #1f6feb;
  --accent-dark: #1a5fd0;
  --good: #1f9254;
  --warn: #b25e09;
  --bad: #c0392b;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 20px; }

.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { font-weight: 700; font-size: 18px; color: var(--ink); }
.brand span { color: var(--accent); }
.topbar nav { display: flex; gap: 18px; flex: 1; }
.topbar nav a { color: var(--muted); font-weight: 500; padding: 4px 0; border-bottom: 2px solid transparent; }
.topbar nav a.active, .topbar nav a:hover { color: var(--ink); border-color: var(--accent); text-decoration: none; }

main.wrap { padding-top: 28px; padding-bottom: 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; margin: 0; display: flex; align-items: center; gap: 10px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.sub { margin-top: 18px; }

.btn {
  display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font-size: 14px; cursor: pointer; font-weight: 500;
}
.btn:hover { border-color: #c9d1da; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--bad); border-color: #f0c9c4; }
.btn.tiny { padding: 2px 8px; font-size: 13px; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0; }
.link:hover { color: var(--ink); text-decoration: underline; }
.inline { display: inline; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 22px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
.num, th.num { text-align: right; }
.qty { width: 90px; }
.rate { width: 130px; }

.grid.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.card.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.card.stat strong { font-size: 22px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: #eef1f5; color: var(--muted); text-transform: capitalize; }
.pill.good { background: #e5f5ec; color: var(--good); }
.pill.warn { background: #fdf1e3; color: var(--warn); }
.pill.bad { background: #fbe9e7; color: var(--bad); }

.form label { display: block; margin-bottom: 14px; font-weight: 500; font-size: 14px; }
.form input, .form textarea, .form select, .search input, .search select {
  width: 100%; margin-top: 6px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
.form input:focus, .form textarea:focus, .form select:focus { outline: 2px solid #cfe0ff; border-color: var(--accent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.search { display: flex; gap: 10px; margin-bottom: 18px; }
.search input, .search select { margin-top: 0; max-width: 320px; }
.items input { width: 100%; margin-top: 0; }
.live-total { margin: 12px 0 18px; font-size: 14px; color: var(--muted); }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.flash.ok { background: #e5f5ec; color: #14663c; }
.flash.warn { background: #fdf1e3; color: #8a4a06; }
.flash.bad { background: #fbe9e7; color: #8f2b20; }

.auth { max-width: 380px; margin: 12vh auto 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.auth h1 { margin: 0 0 6px; font-size: 22px; }
.auth h1 span { color: var(--accent); }
.auth form { margin-top: 18px; }

.invoice-sheet { padding: 26px; }
.sheet-head { display: flex; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 16px; }
.sheet-head h2 { margin: 0 0 4px; }
.sheet-meta { text-align: right; }
.sheet-bill { margin-bottom: 16px; }
.sheet-bill p { margin: 4px 0 0; }
.totals { margin-left: auto; max-width: 320px; margin-top: 16px; }
.totals > div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.totals .grand { border-bottom: 0; font-size: 17px; padding-top: 10px; }
.notes { margin-top: 18px; font-size: 14px; }

.foot { border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 13px; padding: 14px 0; }

.sheet.print { background: #fff; max-width: 780px; margin: 30px auto; padding: 40px; border: 1px solid var(--line); border-radius: 10px; }
.sheet.print h1 { margin: 0 0 4px; font-size: 22px; }
body.bare { background: #fff; }

@media print {
  body { background: #fff; }
  .sheet.print { border: 0; margin: 0; padding: 0; max-width: none; }
  .topbar, .foot, .page-head .actions { display: none; }
}

/* ---------- StockDesk additions ---------- */
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 4px 0 18px; flex-wrap: wrap; }
.head h1 { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 4px 0 24px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.card strong { font-size: 22px; line-height: 1.2; }
.card .muted { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters input, .filters select { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.form.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form.grid2 .span2 { grid-column: 1 / -1; }
.form.grid2 .actions { margin-top: 8px; }
.kv { border-collapse: collapse; margin: 4px 0 22px; width: 100%; }
.kv th { width: 170px; padding: 8px 18px 8px 0; border-bottom: 1px solid var(--line); }
.kv td { padding: 8px 0; border-bottom: 1px solid var(--line); }
