/* τιμά — χειροποίητο CSS v2, mobile-first, χωρίς frameworks.
   Πιστή υλοποίηση mockup.html — παλέτα, pill/btn/card/doc στυλ, mobile chrome. */
:root {
  --bg: #f6f6f2;
  --card: #ffffff;
  --ink: #16211c;
  --muted: #5d6a63;
  --line: #e4e7e0;
  --brand: #0e7a5f;
  --brand-dark: #0b5c47;
  --brand-soft: #e7f3ee;
  --amber: #9a6b00;
  --amber-soft: #fbf3dd;
  --amber-line: #e5d9b8;
  --err: #b3372f;
  --err-soft: #fbeaea;
  --side-bg: #101815;
  --side-ink: #9db3a8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 33, 28, .05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 14.5px; line-height: 1.55; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.inline { display: inline; }
code { background: #eef0ec; padding: .1rem .35rem; border-radius: 5px; font-size: .88em; }
.empty { color: var(--muted); text-align: center; padding: 2rem 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.lmini { display: none; }

/* ── Frame: sidebar (desktop) / topbar+tabbar (mobile) ─── */
.app { display: flex; min-height: 100vh; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side {
  width: 216px; background: var(--side-bg); color: var(--side-ink);
  padding: 22px 14px; flex-shrink: 0; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.logo, .wordmark { font-size: 21px; font-weight: 700; color: #fff; letter-spacing: -.01em; }
.logo { display: block; padding: 0 10px 20px; }
.logo:hover, .wordmark:hover { text-decoration: none; }
.logo b, .wordmark b { color: #2fbf98; }
.nav a {
  display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px;
  color: var(--side-ink); font-weight: 500; margin-bottom: 2px; min-height: 40px;
}
.nav a.on { background: #1c2b24; color: #fff; }
.nav a:hover { background: #18231e; text-decoration: none; }
.side-foot { margin-top: auto; padding: 10px; }

.topbar {
  display: none; position: sticky; top: 0; z-index: 20;
  background: var(--side-bg); color: #fff;
  align-items: center; justify-content: space-between;
  padding: 8px 14px; min-height: 56px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar .wordmark { font-size: 19px; color: #fff; }

.tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--line);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 11.5px; font-weight: 600;
  padding: 7px 0; border-radius: 8px; min-height: 52px; justify-content: center;
}
.tabbar a.on { color: var(--brand); background: var(--brand-soft); }
.tabbar a:hover { text-decoration: none; }
.tabbar .tic { font-size: 16px; }

.main { flex: 1; padding: 22px 20px 40px; width: 100%; max-width: 1060px; }

/* ── Pills ─────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px;
  white-space: nowrap;
}
.ok { background: var(--brand-soft); color: var(--brand); }
.pend { background: var(--amber-soft); color: var(--amber); }
.draft { background: #eef0ec; color: #6b756e; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--brand); color: #fff; border: 1px solid var(--brand);
  border-radius: 8px; padding: 9px 16px; font-weight: 600; font-size: 13.5px;
  cursor: pointer; text-decoration: none; font-family: inherit; line-height: 1.25;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: #c9cec4; background: #fbfbf9; }
.btn.warn { background: #fff; color: var(--amber); border-color: var(--amber-line); }
.btn.warn:hover { background: var(--amber-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-plus { padding: 7px 15px; font-size: 18px; line-height: 1; }

/* ── Flashes ───────────────────────────────────────────── */
.flash { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 13.5px; }
.flash-ok { background: var(--brand-soft); color: var(--brand-dark); }
.flash-err { background: var(--err-soft); color: var(--err); }

/* ── Head / stats ──────────────────────────────────────── */
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
h1 { font-size: 21px; font-weight: 650; margin-bottom: 4px; letter-spacing: -.01em; }
.sub { color: var(--muted); }
.headbtns { display: flex; gap: 10px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { padding: 16px 18px; }
.stat .k { font-size: 12.5px; color: var(--muted); letter-spacing: .02em; }
.stat .v { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 500; }

/* ── Cards & tables ────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.narrow { max-width: 560px; }
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 12px; color: var(--muted); text-align: left; font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--line); letter-spacing: .03em;
}
td { padding: 11px 14px; border-bottom: 1px solid #eef1ea; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.inv-table tbody tr { cursor: pointer; }
.inv-table tbody tr:hover { background: #fafbf8; }
.row-go { color: var(--muted); width: 30px; }
.mini-mark { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── Forms ─────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.fcard { padding: 20px; }
.field { margin-bottom: 14px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fbfbf9; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid rgba(14, 122, 95, .35); border-color: var(--brand); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.radio-row { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 8px; }
.radio, .check { font-weight: 500; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.radio input, .check input { width: auto; }
.new-client { background: var(--brand-soft); border-radius: 8px; padding: 14px; margin: -4px 0 14px; }
.new-client label { color: var(--brand-dark); }

/* γραμμές τιμολογίου */
.lineitem {
  display: grid; grid-template-columns: 1fr 70px 90px 96px 34px; gap: 8px;
  align-items: center; margin-bottom: 8px;
}
.lineitem.linehead { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.lineitem.linehead span { display: block; }
.lineitem input, .lineitem select { padding: 8px 9px; }
.rm {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 14px; width: 34px; height: 34px; border-radius: 6px;
}
.rm:hover { background: var(--err-soft); color: var(--err); }
.exwrap { grid-column: 1 / -1; }
.exwrap select { background: var(--amber-soft); }
.addline { margin-top: 6px; }
.addline a { color: var(--brand); font-size: 13px; font-weight: 600; }

/* sidebar σύνολα */
.sidecol { position: sticky; top: 20px; }
.tot { padding: 18px 20px; }
.tot .r { display: flex; justify-content: space-between; padding: 5px 0; font-variant-numeric: tabular-nums; }
.tot .g { font-size: 19px; font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.tot .g span:last-child { color: var(--brand); }
.sidebtns { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.sidebtns .btn { width: 100%; }
.sidehint { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.6; }

/* ── Action row (doc) ──────────────────────────────────── */
.actionrow { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

/* ── Doc (A4-ish sheet) ────────────────────────────────── */
.docwrap { }
.doc {
  max-width: 760px; margin: 0 auto; background: #fff; border: 1px solid var(--line);
  padding: 44px 48px; box-shadow: 0 2px 10px rgba(22, 33, 28, .06);
}
.dochead { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 26px; }
.co h2 { font-size: 17px; }
.co p { color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.doc h3 { font-size: 15px; letter-spacing: .12em; margin-bottom: 3px; }
.doc h3.doc-title-cap { text-transform: uppercase; }
.docmeta { text-align: right; font-size: 12.5px; color: var(--muted); line-height: 1.7; min-width: 200px; }
.docmeta b { color: var(--ink); }
.client {
  margin: 18px 0 24px; padding: 14px 16px; background: #f8f9f5;
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
}
.doc table { font-size: 13px; }
.doc th { background: #f8f9f5; }
.doc td, .doc th { padding: 9px 12px; }
.doc .grand td { font-size: 15px; font-weight: 700; border-top: 2px solid var(--ink); }
.doc .vrow td { color: var(--muted); }
.pay { margin-top: 20px; font-size: 12.5px; color: var(--muted); }
.aade {
  margin-top: 24px; border-top: 1px dashed var(--line); padding-top: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  font-size: 12px; color: var(--muted);
}
.ok-ink { color: var(--brand); }
.amber-ink { color: var(--amber); }
.mut-ink { color: var(--muted); }
.qr {
  width: 54px; height: 54px; flex-shrink: 0;
  background: repeating-conic-gradient(#16211c 0 25%, #fff 0 50%) 50% / 12px 12px;
  border: 1px solid var(--line);
}

/* ── myDATA panel ──────────────────────────────────────── */
.panel-title { font-size: 17px; font-weight: 650; margin: 4px 0 14px; }
.panel-grid { margin-bottom: 26px; }
.steps { padding: 8px 22px 18px; }
.step { display: flex; gap: 14px; padding: 13px 0; border-bottom: 1px solid #eef1ea; }
.step:last-child { border: 0; }
.dot {
  width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.dot-pend { background: #eef0ec; color: #6b756e; }
.dot-err { background: var(--err-soft); color: var(--err); }
.step b { display: block; font-size: 13.5px; }
.step span { font-size: 12.5px; color: var(--muted); }
.step .err-text { color: var(--err); font-weight: 500; }
.markbox {
  margin-top: 16px; padding: 14px 16px; background: var(--brand-soft);
  border-radius: 8px; font-size: 12.5px; color: var(--brand-dark);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.markbox .qr { border-color: rgba(14, 122, 95, .25); }

/* ── Clients ───────────────────────────────────────────── */
.newclient { padding: 0; margin-bottom: 18px; }
.newclient summary {
  cursor: pointer; font-weight: 600; font-size: 13.5px; padding: 14px 18px;
  color: var(--brand); list-style: none;
}
.newclient summary::-webkit-details-marker { display: none; }
.newclient summary::before { content: "＋ "; }
.ncform { padding: 0 18px 18px; }
.cl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.clc { padding: 16px 18px; }
.clc b { font-size: 14px; }
.clc .afm { font-size: 12px; color: var(--muted); margin: 2px 0 10px; }
.clc .sum { display: flex; justify-content: space-between; font-size: 13px; border-top: 1px solid var(--line); padding-top: 9px; }
.clact { margin-top: 10px; }

/* ── XML preview ───────────────────────────────────────── */
.xml-view {
  background: #101815; color: #cfe0d7; border-radius: 8px;
  padding: 16px 18px; overflow-x: auto; font-size: 12px; line-height: 1.55;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre;
}

/* ── Auth (login/register) ─────────────────────────────── */
.auth-body { background: var(--side-bg); }
.auth-wrap { display: flex; min-height: 100vh; }
.auth-brand {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 48px; color: var(--side-ink); gap: 18px; max-width: 480px;
  background: var(--side-bg);
}
.auth-brand .logo { padding: 0; font-size: 30px; }
.auth-brand-tag { font-size: 15px; line-height: 1.6; }
.auth-brand-points { list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; }
.auth-brand-points li::before { content: "✓ "; color: #2fbf98; font-weight: 700; }
.auth-main { flex: 1.2; display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 20px; }
.auth-sub { margin-bottom: 18px; }
.auth-btn { width: 100%; margin-top: 6px; }
.auth-switch { margin-top: 16px; font-size: 13px; color: var(--muted); text-align: center; }

/* ── User chip (sidebar bottom & topbar) ───────────────── */
.uchip { padding: 10px 10px 12px; margin-bottom: 10px; border-top: 1px solid #1c2b24; }
.uchip-hello { font-size: 12px; color: var(--side-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 6px; }
.uchip-hello b { color: #fff; font-weight: 600; }
.uchip-out {
  background: none; border: 1px solid #2a3a32; color: var(--side-ink);
  border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.uchip-out:hover { background: #18231e; color: #fff; }
.uchip-top { display: flex; align-items: center; gap: 8px; padding: 0; margin: 0; border: 0; }
.uchip-top .uchip-hello { margin: 0; max-width: 150px; }

/* ══════════════ MOBILE (≤900px) ══════════════ */
@media (max-width: 900px) {
  .side { display: none; }
  .topbar { display: flex; }
  .tabbar { display: flex; }
  .main { padding: 16px 14px calc(92px + env(safe-area-inset-bottom)); }
  h1 { font-size: 19px; }
  input, select { font-size: 16px; }  /* ≥16px — κανένα iOS zoom */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .rm { width: 44px; height: 44px; }

  /* stats: μία στήλη */
  .stats { grid-template-columns: 1fr; gap: 10px; margin-bottom: 16px; }
  .stat { padding: 14px 16px; }
  .stat .v { font-size: 22px; }

  /* πίνακας τιμολογίων → κάρτες */
  .inv-table thead { display: none; }
  .inv-table tbody, .inv-table tr, .inv-table td { display: block; width: 100%; }
  .inv-table tbody { padding: 8px; }
  .inv-table tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 10px 12px; margin-bottom: 8px; background: #fff; box-shadow: var(--shadow);
  }
  .inv-table td { padding: 0; border: 0; font-variant-numeric: tabular-nums; }
  .inv-table td[data-label="ΑΑ"] { order: 1; color: var(--muted); font-size: 12px; font-weight: 600; width: auto; }
  .inv-table td[data-label="ΗΜ/ΝΙΑ"] { order: 2; color: var(--muted); font-size: 12px; width: auto; }
  .inv-table td[data-label="ΠΕΛΑΤΗΣ"] { order: 3; flex-basis: 100%; font-weight: 600; font-size: 14px; }
  .inv-table td[data-label="ΣΥΝΟΛΟ"] { order: 4; margin-left: auto; font-weight: 700; font-size: 14.5px; text-align: right; }
  .inv-table td[data-label="ΚΑΤΑΣΤΑΣΗ"] { order: 5; flex-basis: 100%; }
  .inv-table .row-go { display: none; }

  /* νέο τιμολόγιο: μία στήλη, σύνολα → sticky bottom bar */
  .grid { grid-template-columns: 1fr; }
  .sidecol {
    position: sticky; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 15;
    background: var(--bg); padding: 10px 0 4px; margin-top: 4px;
  }
  .sidecol .tot { padding: 10px 16px; box-shadow: 0 -2px 12px rgba(22, 33, 28, .10); border-radius: 12px; }
  .sidecol .tot .r { padding: 2px 0; font-size: 13px; }
  .sidecol .tot .g { font-size: 16px; margin-top: 2px; padding-top: 6px; }
  .sidecol .sidehint { display: none; }
  .lineitem, .lineitem.linehead { display: block; }
  .lineitem.linehead { display: none; }
  .lineitem {
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px; margin-bottom: 10px; background: #fff;
  }
  .lmini { display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
  .lineitem input, .lineitem select { margin-bottom: 10px; }
  .lineitem .rm { float: right; margin: -6px -8px 0 0; }
  .exwrap { margin-bottom: 2px; }
  .addline a {
    display: block; text-align: center; border: 1px dashed var(--line);
    border-radius: 8px; padding: 13px; background: #fff;
  }
  .row2 { grid-template-columns: 1fr; gap: 0; }

  /* doc view: το φύλλο χωράει στην οθόνη με εσωτερική κύλιση */
  .headbtns .btn { min-height: 40px; padding: 7px 12px; }
  .docwrap { max-height: calc(100dvh - 240px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .doc { padding: 20px 18px; }
  .dochead { flex-direction: column; gap: 12px; margin-bottom: 18px; }
  .docmeta { text-align: left; }
  .doc h3 { font-size: 13px; }
  .co h2 { font-size: 15px; }
  .doc table { font-size: 12.5px; }
  .doc td, .doc th { padding: 7px 8px; }
  .doc .grand td { font-size: 14px; }
  .qr { width: 44px; height: 44px; background-size: 10px 10px; }
  .aade { font-size: 11.5px; }

  /* clients: μία στήλη */
  .cl { grid-template-columns: 1fr; }

  /* xml */
  .xml-view { font-size: 11px; padding: 12px; }

  /* auth: στήλη, συμπτυγμένο brand panel */
  .auth-wrap { flex-direction: column; }
  .auth-brand { max-width: none; padding: 26px 20px 14px; gap: 8px; justify-content: flex-start; }
  .auth-brand .logo { font-size: 24px; }
  .auth-brand-points { display: none; }
  .auth-brand-tag { font-size: 13.5px; }
  .auth-main { padding: 16px 14px 40px; align-items: flex-start; }

  /* user chip στο topbar: μόνο Έξοδος — το email κρύβεται για χώρο */
  .uchip-top .uchip-hello { display: none; }
}

/* ══════════════ PRINT (A4) ══════════════ */
@media print {
  body { background: #fff; }
  .no-print, .side, .topbar, .tabbar, .flash, .actionrow, .sidecol { display: none !important; }
  .main { padding: 0; max-width: none; }
  .docwrap { max-height: none !important; overflow: visible !important; }
  .doc { border: 0; box-shadow: none; max-width: none; padding: 0; }
  .grid { grid-template-columns: 1fr; }
  @page { size: A4; margin: 18mm; }
}

/* ── Φόρμα τιμολογίου: segmented radio πελάτη, χαρακτηρισμοί, πεδία Β2Β ── */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 10px; }
.seg label {
  position: relative; display: flex; align-items: center; justify-content: center;
  gap: 8px; border: 1px solid var(--line); border-radius: 8px;
  background: #fbfbf9; padding: 12px 8px; font-size: 13.5px; font-weight: 600;
  color: var(--muted); cursor: pointer; min-height: 48px; text-align: center;
  margin: 0; line-height: 1.3;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
input.input-err, select.input-err { border-color: var(--err); background: var(--err-soft); }
.cls-wrap { grid-column: 1 / -1; }
.cls-wrap select.income-sel { background: #f2f6f3; font-size: 13px; }
.aade-sub { font-size: 12.5px; }
#b2b-fields .new-client { margin: 0 0 14px; }
@media (max-width: 640px) {
  .cls-wrap select.income-sel { width: 100%; }
  .seg { grid-template-columns: 1fr; }
  .seg label { min-height: 52px; }
}
