:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e6eaf0;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-soft: #eff4ff;
  --primary-ink: #ffffff;
  --danger: #dc2626;
  --ok: #059669;
  --warn-bg: #fffbeb;
  --warn-ink: #92400e;
  --err-bg: #fef2f2;
  --ok-bg: #ecfdf5;
  --side-bg: #0b1220;
  --side-ink: #cbd5e1;
  --side-muted: #64748b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .16);
  --side-w: 248px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f1a; --surface: #111827; --surface-2: #0f1624; --text: #e5e7eb; --muted: #94a3b8; --line: #1f2a3c;
    --primary: #3b82f6; --primary-2: #60a5fa; --primary-soft: #14223d;
    --warn-bg: #2a2110; --warn-ink: #fbbf24; --err-bg: #2a1215; --ok-bg: #0c2a20;
    --side-bg: #070b14;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; margin: .1rem 0 .5rem; }
h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; margin: 1.6rem 0 .7rem; }
.card h2:first-child, details h2 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .72rem; }
.mono { font-family: ui-monospace, "JetBrains Mono", "Cascadia Mono", Consolas, monospace; font-size: .88em; }
.strong { font-weight: 700; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
.empty { padding: 1.5rem 0; text-align: center; }
.ic { width: 20px; height: 20px; flex: none; }

/* ---------- Shell ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side-bg); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 14px; z-index: 40; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: .7rem; color: #fff; padding: 4px 6px 18px; }
.logo:hover { color: #fff; }
.logo-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #3b82f6, #6366f1); color: #fff; box-shadow: 0 6px 18px rgba(59, 130, 246, .4); }
.logo strong { display: block; font-size: 1rem; letter-spacing: .02em; }
.logo small { display: block; color: var(--side-muted); font-size: .76rem; }
.new-btn { margin: 0 4px 16px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a, .side-foot a, .side-link { display: flex; align-items: center; gap: .75rem; padding: .62rem .75rem; border-radius: 10px; color: var(--side-ink); font-size: .8rem; font-weight: 600; letter-spacing: .04em; background: none; border: 0; font-family: inherit; width: 100%; text-align: left; cursor: pointer; }
.side-nav a:hover, .side-foot a:hover, .side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-nav a.on, .side-foot a.on { background: rgba(59, 130, 246, .16); color: #fff; box-shadow: inset 3px 0 0 #3b82f6; }
.side-nav a.on .ic { color: #60a5fa; }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; flex-direction: column; gap: 2px; }
.side-link span { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--side-muted); }
.scrim { display: none; }

.has-shell .topbar, .has-shell .wrap { margin-left: var(--side-w); }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .6rem; padding: 10px 28px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.menu-btn { display: none; }
.tabs-bar { display: flex; gap: .45rem; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.tabs-bar::-webkit-scrollbar { display: none; }
.tab-chip { --c: var(--muted); display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .85rem; border-radius: 999px; border: 1px solid var(--line);
  font-size: .74rem; font-weight: 700; letter-spacing: .04em; color: var(--text); white-space: nowrap; background: var(--surface); transition: all .15s; }
.tab-chip::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--c); }
.tab-chip.all::before { background: conic-gradient(#0b7a3e 0 33%, #c2410c 0 66%, #1d4ed8 0); }
.tab-chip:hover { color: var(--text); border-color: var(--c); }
.tab-chip.on { background: var(--c); border-color: var(--c); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--c) 35%, transparent); }
.tab-chip.on::before { background: rgba(255, 255, 255, .85); }
.tab-chip.all.on { --c: var(--text); color: var(--surface); }
.wrap { max-width: 1320px; padding: 24px 28px 6rem; }
.bottom-nav { display: none; }

/* ---------- Generic ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.actions-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; white-space: nowrap; min-height: 40px; transition: all .15s; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.btn .ic { width: 18px; height: 18px; }
.btn:hover { color: var(--text); border-color: color-mix(in srgb, var(--muted) 50%, var(--line)); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.ghost { background: none; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); box-shadow: none; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { padding: .25rem .55rem; min-height: 0; font-size: .82rem; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.link { background: none; border: 0; color: var(--primary); font: inherit; cursor: pointer; padding: 0; }
form.inline { display: inline; }
.flash { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; background: var(--ok-bg); border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent); color: color-mix(in srgb, var(--ok) 70%, var(--text)); font-weight: 500; }
.flash.error { background: var(--err-bg); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: color-mix(in srgb, var(--danger) 75%, var(--text)); }
.flash.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn-ink) 25%, transparent); color: var(--warn-ink); }
.badge { display: inline-flex; align-items: center; padding: .12rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); vertical-align: middle; letter-spacing: .01em; }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.badge.st-issued { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.st-draft { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.badge.st-cancelled { background: var(--err-bg); color: var(--danger); border-color: transparent; text-decoration: line-through; }
.dot { --c: #999; display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--c); margin-right: .45rem; vertical-align: middle; flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
.chip { display: inline-block; padding: .08rem .45rem; border: 1px solid var(--line); border-radius: 6px; margin: .2rem .25rem 0 0; font-size: .78rem; background: var(--surface-2); }

/* ---------- Forms ---------- */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .55rem .7rem; width: 100%; min-height: 42px; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--muted) 40%, var(--line)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent); }
input[type=checkbox], input[type=radio] { width: 1.05rem; height: 1.05rem; min-height: 0; accent-color: var(--primary); box-shadow: none; }
input[type=color] { padding: .15rem; width: 3rem; }
input[readonly] { background: var(--surface-2); }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
label > input, label > select, label > textarea { font-weight: 400; font-size: .95rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; color: var(--text); font-size: .88rem; }
label small { font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.2rem; }
.form-grid .span2, .form-grid fieldset { grid-column: 1 / -1; }
.form-grid.view > div { font-size: .95rem; padding: .2rem 0; }
.lbl { font-size: .74rem; font-weight: 700; color: var(--muted); margin-bottom: .15rem; text-transform: uppercase; letter-spacing: .05em; }
fieldset.addr { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .7rem .8rem .8rem; margin: 0; display: grid; grid-template-columns: 2fr .7fr .8fr 1.5fr; gap: .55rem; background: var(--surface-2); }
fieldset.addr legend { font-size: .8rem; font-weight: 700; color: var(--muted); padding: 0 .35rem; }
.short { max-width: 7rem; }
.checks { display: flex; flex-direction: column; justify-content: center; gap: .5rem; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1 1 280px; width: auto; padding-left: 2.4rem; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat .8rem center / 17px; }
.filters select { width: auto; }
.inline-label { flex-direction: row; align-items: center; gap: .4rem; }
.inline-label input { width: auto; }
.row-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.row-form > input, .row-form > select { width: auto; flex: 1 1 8rem; }
.row-form > input.short { flex: 0 0 5.5rem; }
details.settings summary { cursor: pointer; list-style: none; }
details.settings summary::-webkit-details-marker { display: none; }
details.settings summary h2 { display: inline; }
details.settings summary::after { content: "▾"; float: right; color: var(--muted); transition: transform .2s; }
details.settings[open] summary::after { transform: rotate(180deg); }
details.settings[open] summary { margin-bottom: 1rem; }
.danger-zone { margin-top: 1.5rem; border: 1px dashed color-mix(in srgb, var(--danger) 40%, var(--line)); border-radius: var(--radius); padding: .8rem 1.1rem; }
.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; box-shadow: var(--shadow); }
.card .table-wrap { border: 0; margin: 0 -1.2rem 1rem; border-radius: 0; box-shadow: none; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: .75rem .9rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
table.list td { padding: .75rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list.compact td { padding: .5rem .9rem; }
table.list tr:last-child td { border-bottom: 0; }
table.list .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.list input { min-height: 34px; padding: .3rem .5rem; }
tr.row-link { cursor: pointer; transition: background .12s; }
tr.row-link:hover td { background: var(--primary-soft); }
tr.inactive td { opacity: .5; }

/* ---------- Dashboard ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin: 1.2rem 0 1.6rem; }
.stat { --c: var(--primary); position: relative; display: block; color: var(--text); margin: 0; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.stat::after { content: ""; position: absolute; right: -24px; top: -24px; width: 90px; height: 90px; border-radius: 50%; background: color-mix(in srgb, var(--c) 10%, transparent); }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.stat:hover { color: var(--text); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat.attention { --c: #f59e0b; }
.stat-title { font-weight: 600; font-size: .85rem; color: var(--muted); }
.stat-num { font-size: 2.1rem; font-weight: 800; line-height: 1.15; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: .15rem 0; }

/* ---------- Document form ---------- */
.lines-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.lines-head h2 { margin: 0; }
.line { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .7rem .8rem; margin-bottom: .55rem; transition: background .3s, border-color .2s; background: var(--surface); }
.line:hover { border-color: color-mix(in srgb, var(--primary) 30%, var(--line)); }
.line.flashrow { background: var(--primary-soft); }
.line-main { display: flex; align-items: center; gap: .7rem; }
.line-desc { flex: 1; min-width: 0; }
.line-qty { display: flex; align-items: center; gap: .4rem; }
.line-qty .qty { width: 8rem; text-align: right; font-weight: 700; font-size: 1rem; }
.line-qty .unit { color: var(--muted); font-size: .82rem; min-width: 2.6rem; }
.qty-ro { display: inline-block; min-width: 4rem; text-align: right; font-weight: 800; font-size: 1.05rem; }
.line-notes { margin-top: .5rem; min-height: 34px; padding: .35rem .6rem; font-size: .86rem; border-style: dashed; background: transparent; }
.serials:empty { display: none; }
.serials { margin-top: .55rem; }
.serials textarea { min-height: 5rem; }
.serial-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .2rem .8rem; max-height: 280px; overflow: auto; padding: .5rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.serial-list .serial-filter { grid-column: 1 / -1; margin-bottom: .3rem; }
.serial-opt { flex-direction: row; align-items: center; gap: .45rem; font-weight: 400; color: var(--text); font-size: .86rem; }
.seg { display: flex; gap: 1rem; margin-bottom: .5rem; }
.seg label { flex-direction: row; align-items: center; gap: .35rem; color: var(--text); }
.add-line { position: relative; margin-top: .8rem; }
.add-line input { padding-left: 2.4rem; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E") no-repeat .8rem center / 17px; border-style: dashed; border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.dropdown { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 360px; overflow: auto; margin-top: 6px; }
.dropdown button { display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left; padding: .6rem .8rem; border: 0; border-bottom: 1px solid var(--line); background: none; font: inherit; font-size: .9rem; color: var(--text); cursor: pointer; }
.dropdown button.hl, .dropdown button:hover { background: var(--primary-soft); }
.pad { padding: .7rem .8rem; }
.sticky-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); padding: .8rem 0; border-top: 1px solid var(--line); z-index: 10; }
.mydata { position: relative; }
.mydata.ok { border-left: 4px solid var(--ok); }
.mydata.pending { border-left: 4px solid #f59e0b; }
.serial-chips { margin-top: .25rem; }

.login-box { max-width: 400px; margin: 10vh auto; padding: 2rem; }
.login-box h1 { font-size: 1.5rem; }
.login-box form { display: flex; flex-direction: column; gap: .9rem; margin-top: 1rem; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .has-shell .topbar, .has-shell .wrap { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(2, 6, 23, .45); z-index: 35; }
  .menu-btn { display: grid; flex: none; }
  .topbar { padding: 8px 14px; }
  .wrap { padding: 16px 16px calc(6rem + env(safe-area-inset-bottom)); }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--muted); font: 700 .62rem/1.2 var(--font); letter-spacing: .04em; background: none; border: 0; cursor: pointer; border-radius: 10px; }
  .bottom-nav a.on { color: var(--primary); }
  .bottom-nav a.on .ic { background: var(--primary-soft); border-radius: 999px; padding: 2px 12px; width: 44px; height: 26px; }
  .sticky-actions { bottom: calc(62px + env(safe-area-inset-bottom)); }
  .form-grid { grid-template-columns: 1fr; }
  fieldset.addr { grid-template-columns: 1fr 1fr; }
  .line-main { flex-wrap: wrap; }
  .line-desc { flex-basis: calc(100% - 3rem); }
  .line-qty { margin-left: auto; }
  h1 { font-size: 1.35rem; }
  .filters > * { flex: 1 1 100%; }
  .inline-label input { flex: 1; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
  .stat-num { font-size: 1.7rem; }
}

/* φύρα στη γραμμή καταγραφής */
label.waste { flex-direction: row; align-items: center; gap: .5rem; margin-top: .5rem; justify-content: flex-end; }
label.waste input { width: 7rem; text-align: right; }
.bad { outline: 2px solid #dc2626 !important; background: #fef2f2 !important; }
