/* =========================================================
   Λογιστήριο Τσιανάκας Κωνσταντίνος – στυλ εφαρμογής
   ========================================================= */

:root {
  --bg:        #eef2f7;
  --panel:     #ffffff;
  --panel-2:   #f8fafc;
  --ink:       #0f172a;
  --ink-soft:  #334155;
  --muted:     #6b7a90;
  --line:      #e2e8f0;
  --line-soft: #eef2f7;
  --primary:   #1d4ed8;
  --primary-d: #1a3fb0;
  --good:      #047857;
  --good-bg:   #ecfdf5;
  --danger:    #dc2626;
  --danger-bg: #fef2f2;
  --warn:      #b45309;
  --warn-bg:   #fffbeb;
  --radius:    12px;
  --shadow:    0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* ------------------------- Δομή ------------------------- */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 258px;
  flex: 0 0 258px;
  background: #0f1d3a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
}

.brand-mark {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border-radius: 11px;
  background: linear-gradient(140deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(29, 78, 216, .45);
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { color: #fff; font-size: 15px; letter-spacing: .02em; }
.brand-text span { font-size: 11.5px; color: #93a4bd; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #c3cfe2;
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .13s, color .13s;
}
.nav-item .ico { width: 18px; text-align: center; opacity: .85; font-size: 13px; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.is-active { background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(29, 78, 216, .4); }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, .09);
  padding-top: 14px;
}
.foot-links { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.linkbtn {
  background: none; border: 0; padding: 4px 2px;
  color: #93a4bd; font: inherit; font-size: 12.5px;
  text-align: left; cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: rgba(147, 164, 189, .4);
}
.linkbtn:hover { color: #fff; }
.sidebar-foot .hint { color: #7b8ba5; }

.hint { font-size: 11.5px; color: var(--muted); margin: 0; line-height: 1.5; }

/* ------------------------- Κύριο τμήμα ------------------------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 20px 26px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 21px; }
.subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.period { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.period label {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted); font-weight: 500;
}
.period input[type="date"] {
  font: inherit; font-size: 13px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
}
.period-presets { display: flex; gap: 5px; }
.chip {
  font: inherit; font-size: 12px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .13s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

.content { padding: 22px 26px 60px; flex: 1; }

.view { display: none; }
.view.is-active { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ------------------------- Κάρτες ------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #fff, var(--panel-2));
}
.card-head h2 { font-size: 15px; }
.head-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.card-foot {
  padding: 11px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel-2);
  font-size: 13px;
  color: var(--ink-soft);
}
.card-foot b { color: var(--ink); }

.badge {
  font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  background: var(--warn-bg); color: var(--warn);
  border: 1px solid #fde68a;
}

/* ------------------------- Τύπος πελάτη ------------------------- */

.kind {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 650;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.kind-pro { background: #eef4ff; color: #1d4ed8; border-color: #c7d7f5; }
.kind-private { background: #f1f5f9; color: #475569; border-color: #dbe3ec; }
.sub-kind { margin-top: 4px; }

/* ------------------------- Ομάδες πελατών ------------------------- */

.table-groups .group { margin-bottom: 20px; }
.table-groups .group:last-child { margin-bottom: 0; }

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, #fff, var(--panel-2));
}
.group-pro .group-head { background: linear-gradient(180deg, #f7faff, #eef4ff); border-color: #d7e3f8; }
.group-private .group-head { background: linear-gradient(180deg, #fafbfc, #f1f5f9); }

.group-title { display: flex; align-items: center; gap: 9px; }
.group-count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.group-total { font-size: 12.5px; color: var(--muted); }
.group-total b { font-size: 14px; font-variant-numeric: tabular-nums; }

.table-groups .table-wrap {
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background: #fff;
}
.group-pro .table-wrap { border-color: #d7e3f8; }
.table-groups table.table th { background: var(--panel-2); }

.group-empty {
  margin: 0;
  padding: 16px 15px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

/* Επιλογή τύπου πελάτη στη φόρμα */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented span {
  display: block;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  transition: all .13s;
  line-height: 1.3;
}
.segmented b { display: block; font-size: 13.5px; font-weight: 650; color: var(--ink); }
.segmented small { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.segmented input:checked + span {
  border-color: var(--primary);
  background: #f3f7ff;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}
.segmented input:checked + span b { color: var(--primary); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* KPI */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--primary);
}
.kpi.kpi-good::before { background: var(--good); }
.kpi.kpi-warn::before { background: var(--warn); }
.kpi.kpi-danger::before { background: var(--danger); }
.kpi .kpi-label {
  font-size: 12px; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; color: var(--muted);
}
.kpi .kpi-value {
  font-size: 25px; font-weight: 700; margin-top: 6px;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.kpi .kpi-note { font-size: 12px; color: var(--muted); margin-top: 3px; }

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}
.panels .card { margin-bottom: 0; }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .span-2 { grid-column: span 1; } }

/* ------------------------- Πίνακες ------------------------- */

.table-wrap { overflow-x: auto; max-height: none; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table th {
  font-size: 11.5px; font-weight: 650; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
  background: var(--panel-2);
  position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
.table tbody tr:hover { background: #f7faff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact th, .table.compact td { padding: 7px 12px; font-size: 13px; }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.th-num { text-align: right; }
.money-pos { color: var(--warn); font-weight: 650; }
.money-zero { color: var(--good); font-weight: 600; }
.money-paid { color: var(--good); font-weight: 600; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 26px 14px !important; font-style: italic; }
.client-link { color: var(--primary); font-weight: 600; text-decoration: none; cursor: pointer; }
.client-link:hover { text-decoration: underline; }
tr.is-inactive td { opacity: .55; }

.dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.dot-on { background: #10b981; }
.dot-off { background: #cbd5e1; }

/* ------------------------- Φόρμες ------------------------- */

.form-card .card-head { background: #fff; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 13px 15px;
  padding: 17px 18px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.field.wide { grid-column: span 2; }
@media (max-width: 700px) { .field.wide { grid-column: span 1; } }

.input, .field input, .field select, .field textarea {
  font: inherit;
  font-size: 13.5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  transition: border-color .13s, box-shadow .13s;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .13);
}
.readonly { background: var(--panel-2) !important; font-weight: 650; color: var(--primary); }
.input.search { min-width: 190px; }
select.input { min-width: 150px; }

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 9px;
  padding-top: 3px;
}

.switch {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--ink-soft); cursor: pointer;
  grid-column: 1 / -1;
}

/* ------------------------- Κουμπιά ------------------------- */

.btn {
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .13s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(29, 78, 216, .3); }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { border-color: #b9c6da; color: var(--ink); background: var(--panel-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-block { width: 100%; }
.btn-mini {
  font-size: 12px; padding: 4px 9px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  cursor: pointer; font-family: inherit; font-weight: 500;
}
.btn-mini:hover { border-color: var(--primary); color: var(--primary); }
.btn-mini.danger:hover { border-color: var(--danger); color: var(--danger); }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }

.iconbtn {
  border: 0; background: none; font-size: 16px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 5px 8px; border-radius: 7px;
}
.iconbtn:hover { background: var(--panel-2); color: var(--ink); }

/* ------------------------- Παράθυρα ------------------------- */

.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 18px;
  overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 100%; max-width: 560px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .3);
  animation: pop .18s ease-out;
}
.modal-wide { max-width: 940px; }
.modal-small { max-width: 420px; }
@keyframes pop { from { opacity: 0; transform: translateY(-10px) scale(.99); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h2 { font-size: 16px; }
.confirm-text { padding: 18px; margin: 0; color: var(--ink-soft); }
.modal-small .form-actions { padding: 0 18px 18px; }

/* ------------------------- Καρτέλα πελάτη ------------------------- */

.statement { padding: 18px; }
.st-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 18px; flex-wrap: wrap;
  padding-bottom: 14px; border-bottom: 2px solid var(--ink);
  margin-bottom: 16px;
}
.st-head h3 { font-size: 19px; }
.st-office { text-align: right; font-size: 12.5px; color: var(--muted); }
.st-office strong { display: block; color: var(--ink); font-size: 13.5px; }
.st-meta { font-size: 13px; color: var(--ink-soft); margin: 4px 0 0; }
.st-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-bottom: 18px;
}
.st-box {
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  background: var(--panel-2);
}
.st-box span { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.st-box b { font-size: 18px; font-variant-numeric: tabular-nums; }
.st-box.total { background: #0f1d3a; border-color: #0f1d3a; }
.st-box.total span { color: #93a4bd; }
.st-box.total b { color: #fff; }
.st-box.total.debt b { color: #fca5a5; }
.st-box.total.clear b { color: #6ee7b7; }
.st-section { margin-top: 20px; }
.st-section h4 {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 0 0 8px;
}
.st-note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

.st-section table.table.compact tfoot td {
  border-top: 2px solid var(--ink);
  background: var(--panel-2);
  font-weight: 600;
}
.st-section table.table.compact .row-strong td { background: #f8fafc; }

/* Τελικό αποτέλεσμα */
.st-final {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 22px;
  padding: 14px 18px;
  border-radius: 12px;
  background: #0f1d3a;
  color: #fff;
}
.st-final span { font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: #93a4bd; }
.st-final b { font-size: 24px; font-variant-numeric: tabular-nums; }
.st-final.clear b { color: #6ee7b7; }
.st-final.debt b { color: #fca5a5; }

.st-sign {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 34px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

/* Κουμπιά μήνα */
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav .input { width: auto; font-size: 14px; padding: 7px 10px; }
.month-nav .iconbtn { font-size: 20px; font-weight: 700; padding: 4px 10px; }

.row-click { cursor: pointer; }
.row-click:hover { background: #f0f6ff !important; }
.month-link { color: var(--primary); font-weight: 600; }
.row-click:hover .month-link { text-decoration: underline; }

/* ------------------------- Ειδοποιήσεις ------------------------- */

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #0f1d3a; color: #fff;
  padding: 11px 20px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .3);
  z-index: 200; animation: pop .16s ease-out;
  max-width: 90vw;
}
.toast[hidden] { display: none; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--good); }

/* ------------------------- Μικρές οθόνες ------------------------- */

.menu-btn { display: none; }
.topbar-title { min-width: 0; }
.only-mobile { display: none; }

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
  .sidebar { width: 224px; flex: 0 0 224px; padding: 18px 13px; }
  .content { padding: 18px; }
  .topbar { padding: 16px 18px 14px; }
}

/* ---------- Κινητά ---------- */
@media (max-width: 760px) {
  body { font-size: 15px; }

  .app { display: block; }

  /* ===== Το πλαϊνό μενού γίνεται κάτω μπάρα ===== */
  .sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: auto;
    width: 100%;
    flex: none;
    height: auto;
    padding: 0 0 env(safe-area-inset-bottom);
    gap: 0;
    overflow: visible;
    border-top: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 -6px 20px rgba(2, 8, 23, .28);
    z-index: 60;
  }

  .brand { display: none; }

  .nav {
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 5px 3px;
  }
  /* Στο κινητό η κάτω μπάρα κρατά τα 5 βασικά· τα άλλα είναι στο μενού ☰ */
  .nav-item[data-mobile="0"] { display: none; }
  .only-mobile { display: block; }
  .nav-item {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 1px;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    border-radius: 11px;
    min-height: 54px;
  }
  .nav-item .ico { font-size: 17px; line-height: 1; }
  .nav-item.is-active { background: var(--primary); box-shadow: none; }

  /* ===== Οι ενέργειες ανοίγουν πάνω από την μπάρα ===== */
  .sidebar-foot {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(64px + env(safe-area-inset-bottom));
    margin: 0;
    padding: 15px 15px 17px;
    gap: 10px;
    background: #16264c;
    border-top: 1px solid rgba(255, 255, 255, .14);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -14px 34px rgba(2, 8, 23, .5);
    transform: translateY(125%);
    transition: transform .24s cubic-bezier(.32, .72, 0, 1);
    max-height: 78vh;
    overflow-y: auto;
    z-index: 59;
  }
  .sidebar-foot.is-open { transform: translateY(0); }
  .sidebar-foot .hint { display: none; }
  .user-box { padding: 10px 12px; font-size: 13.5px; }
  .foot-links { margin-top: 2px; }
  .linkbtn { font-size: 13px; padding: 7px 2px; }

  /* ===== Πάνω μπάρα ===== */
  /* Στο κινητό ΔΕΝ είναι κολλημένη: το φίλτρο περιόδου είναι ψηλό και θα έτρωγε
     την οθόνη. Η πλοήγηση γίνεται από την κάτω μπάρα που είναι πάντα ορατή. */
  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 11px 14px 13px;
    position: static;
  }
  .topbar h1 { font-size: 17.5px; }
  .subtitle { display: none; }

  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
    color: var(--ink);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
  }
  .menu-btn.is-open { background: var(--primary); border-color: var(--primary); color: #fff; }

  .period { grid-column: 1 / -1; width: 100%; gap: 9px; }
  .period label {
    flex: 1 1 130px;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    font-size: 11px;
  }
  .period input[type="date"] { width: 100%; font-size: 15px; padding: 9px 10px; }
  .period-presets { width: 100%; gap: 6px; }
  .period-presets .chip { flex: 1 1 auto; padding: 10px 8px; font-size: 12.5px; min-height: 40px; }

  .content { padding: 14px 14px calc(88px + env(safe-area-inset-bottom)); }

  /* ===== Δείκτες ===== */
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 12px 13px; border-radius: 11px; }
  .kpi .kpi-label { font-size: 10px; }
  .kpi .kpi-value { font-size: 18px; margin-top: 4px; }
  .kpi .kpi-note { font-size: 10.5px; line-height: 1.4; }

  .panels { grid-template-columns: 1fr; gap: 14px; }
  .span-2 { grid-column: span 1; }

  /* ===== Πίνακες → κάρτες ===== */
  .table-wrap { overflow: visible; }
  table.table thead { display: none; }
  table.table, table.table tbody, table.table tr, table.table td { display: block; width: 100%; }
  table.table tr {
    border: 1px solid var(--line);
    border-radius: 12px;
    margin: 0 0 10px;
    padding: 3px 0;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
  }
  table.table tr:hover { background: #fff; }
  table.table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    padding: 8px 13px;
    border: 0;
    text-align: right;
    font-size: 14px;
    line-height: 1.4;
  }
  table.table td + td { border-top: 1px solid var(--line-soft); }
  table.table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
  }
  table.table td:not([data-label])::before { content: none; }
  table.table td.empty {
    display: block;
    text-align: center;
    padding: 22px 14px;
    color: var(--muted);
    font-style: italic;
  }
  table.table td.empty::before { content: none; }
  table.table.compact td { padding: 7px 12px; font-size: 13.5px; }

  .row-actions { justify-content: flex-end; gap: 8px; padding: 10px 13px 6px; }
  .row-actions::before { content: none; }
  .btn-mini { min-height: 38px; padding: 8px 14px; font-size: 13px; border-radius: 9px; }

  /* ===== Φόρμες ===== */
  .card { border-radius: 13px; margin-bottom: 14px; }
  .card-head { padding: 12px 14px; }
  .card-head h2 { font-size: 14px; }
  .head-actions { width: 100%; gap: 8px; }
  .head-actions > .input, .head-actions > .btn { flex: 1 1 100%; }
  .input.search, select.input { min-width: 0; width: 100%; }
  .card-foot { padding: 11px 14px; font-size: 12.5px; }

  .form-grid { grid-template-columns: 1fr; gap: 12px; padding: 15px 14px 17px; }
  .field.wide { grid-column: span 1; }
  .field > span { font-size: 12.5px; }
  /* 16px: αποτρέπει το αυτόματο ζουμ του iOS όταν πατάς σε πεδίο */
  .input, .field input, .field select, .field textarea { font-size: 16px; padding: 11px 12px; min-height: 46px; }
  .field select, .inline-field select { min-height: 46px; }
  .readonly { font-size: 16px; }
  .switch { font-size: 14px; padding: 4px 0; }

  .form-actions { flex-direction: column-reverse; gap: 8px; }
  .form-actions .btn { width: 100%; }

  .btn { min-height: 46px; font-size: 15px; }
  .btn-block { min-height: 48px; }
  .chip { min-height: 40px; }

  /* Στο κινητό η επιλογή τύπου μπαίνει η μία κάτω από την άλλη */
  .segmented { grid-template-columns: 1fr; }
  .segmented span { padding: 12px 13px; }
  .kind { font-size: 11px; padding: 3px 8px; }

  /* Οι ομάδες πελατών σε κινητό */
  .table-groups .group { margin-bottom: 16px; }
  .group-head {
    border-radius: 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 10px;
    padding: 10px 13px;
  }
  .group-pro .group-head { border-color: #d7e3f8; }
  .table-groups .table-wrap { border: 0; background: none; border-radius: 0; }
  .group-empty { border-radius: 12px; border-top: 1px solid var(--line); }

  /* ===== Παράθυρα: φύλλο από κάτω ===== */
  .modal { padding: 0; align-items: flex-end; }
  .modal-box {
    max-width: none;
    border-radius: 18px 18px 0 0;
    max-height: 93vh;
    overflow-y: auto;
  }
  .modal-head { position: sticky; top: 0; background: #fff; z-index: 3; padding: 14px; }
  .modal-head h2 { font-size: 15.5px; }
  .statement { padding: 14px 13px 20px; }
  .st-head { flex-direction: column; gap: 10px; padding-bottom: 12px; }
  .st-head h3 { font-size: 17px; }
  .st-office { text-align: left; }
  .st-summary { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
  .st-summary .st-box.total { grid-column: 1 / -1; }
  .st-box { padding: 10px 12px; }
  .st-box b { font-size: 16px; }
  .st-section { margin-top: 16px; }
  .st-section h4 { font-size: 11.5px; }
  .st-final { padding: 12px 14px; margin-top: 18px; }
  .st-final b { font-size: 20px; }
  .st-final span { font-size: 11.5px; }
  .st-sign { flex-direction: column; gap: 8px; margin-top: 26px; }
  .month-nav { width: 100%; }
  .month-nav .input { flex: 1; font-size: 15px; }
  .month-nav .iconbtn { font-size: 22px; padding: 6px 14px; }

  /* ===== Λοιπά ===== */
  .auth { padding: 14px; }
  .auth-card { max-width: none; border-radius: 15px; }
  .auth-card h2 { font-size: 17px; }
  .auth-form { padding: 14px 16px 18px; }
  .toast {
    left: 12px; right: 12px; bottom: calc(78px + env(safe-area-inset-bottom));
    transform: none; max-width: none; text-align: center;
  }
  .badge { font-size: 11px; }
}

/* ---------- Πολύ στενές οθόνες ---------- */
@media (max-width: 380px) {
  .nav-item { font-size: 9.5px; }
  .nav-item .ico { font-size: 15px; }
  .kpis { grid-template-columns: 1fr; }
  .kpi .kpi-value { font-size: 20px; }
  .st-summary { grid-template-columns: 1fr; }
}

/* ---------- Οριζόντια θέση σε κινητό: λιγότερο κατακόρυφος χώρος ---------- */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 480px) {
  .sidebar-foot { max-height: 88vh; }
  .modal-box { max-height: 96vh; }
}

/* ------------------------- Οθόνη σύνδεσης ------------------------- */

.app[hidden] { display: none; }

.auth {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1100px 600px at 50% -10%, #1e3a8a 0%, #0f1d3a 55%, #0a1428 100%);
  overflow-y: auto;
}
.auth[hidden] { display: none; }

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 30px 70px rgba(2, 8, 23, .55);
  overflow: hidden;
  animation: pop .22s ease-out;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 20px;
  background: #0f1d3a;
  color: #fff;
}
.auth-brand .brand-text strong { color: #fff; font-size: 15px; }
.auth-brand .brand-text span { font-size: 11.5px; color: #93a4bd; }

.auth-card h2 { font-size: 18px; padding: 20px 20px 0; }
.auth-hint { margin: 5px 0 0; padding: 0 20px; font-size: 13px; color: var(--muted); }
.auth-form { padding: 16px 20px 20px; grid-template-columns: 1fr; }
.auth-form .field.wide { grid-column: span 1; }
.auth-error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 13px;
}
.auth-error[hidden] { display: none; }

.auth-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 11px 13px;
  border-radius: 8px;
  background: var(--warn-bg);
  border: 1px solid #fde68a;
  color: var(--warn);
  font-size: 12.5px;
  line-height: 1.55;
}
.auth-note[hidden] { display: none; }
.auth-note code {
  display: inline-block;
  margin-top: 5px;
  padding: 3px 7px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #fde68a;
  font-size: 12px;
}

/* ------------------------- Χρήστης ------------------------- */

.user-box {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
  font-size: 12.5px;
  color: #dbe4f0;
}
.user-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { margin-left: auto; font-size: 10.5px; color: #93a4bd; text-transform: uppercase; letter-spacing: .04em; }
.user-box .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }

/* ------------------- Καταστάσεις & προτεραιότητες ------------------ */

.pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 650;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.st-open    { background: #eef4ff; color: #1d4ed8; border-color: #c7d7f5; }
.st-doing   { background: #fff7ed; color: #b45309; border-color: #fed7aa; }
.st-waiting { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.st-done    { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.st-closed  { background: #f1f5f9; color: #475569; border-color: #dbe3ec; }
.st-cancelled, .st-noshow { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.st-paid    { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.st-partial { background: #fff7ed; color: #b45309; border-color: #fed7aa; }
.st-overdue { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.pr-high   { color: #b91c1c; font-weight: 650; }
.pr-normal { color: var(--ink-soft); }
.pr-low    { color: var(--muted); }

.who { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.who .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }

tr.is-overdue td { background: #fffafa; }

.day-sep td {
  background: var(--panel-2) !important;
  font-weight: 650;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

/* Γρήγορες ενέργειες κατάστασης μέσα στον πίνακα */
.status-actions { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: wrap; }

/* Το κρύβουμε από όποιον δεν είναι διαχειριστής */
body:not(.is-admin) .admin-only { display: none !important; }

/* ------------------- Τύπος πελάτη ------------------- */

.kind {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 650;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.kind-pro { background: #eef4ff; color: #1d4ed8; border-color: #c7d7f5; }
.kind-private { background: #f1f5f9; color: #475569; border-color: #dbe3ec; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented span {
  display: block;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  transition: all .13s;
  line-height: 1.3;
}
.segmented b { display: block; font-size: 13.5px; font-weight: 650; color: var(--ink); }
.segmented small { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.segmented input:checked + span {
  border-color: var(--primary);
  background: #f3f7ff;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}
.segmented input:checked + span b { color: var(--primary); }

/* ------------------- Ομάδες πελατών ------------------- */

.table-groups .group { margin-bottom: 20px; }
.table-groups .group:last-child { margin-bottom: 0; }

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, #fff, var(--panel-2));
}
.group-pro .group-head { background: linear-gradient(180deg, #f7faff, #eef4ff); border-color: #d7e3f8; }
.group-private .group-head { background: linear-gradient(180deg, #fafbfc, #f1f5f9); }
.group-title { display: flex; align-items: center; gap: 9px; }
.group-count { font-size: 12px; color: var(--muted); font-weight: 500; }

.table-groups .table-wrap {
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background: #fff;
}
.group-pro .table-wrap { border-color: #d7e3f8; }
.group-empty {
  margin: 0;
  padding: 16px 15px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

/* ------------------------- Μικρά στοιχεία φόρμας ------------------------- */

.inline-field { display: flex; gap: 6px; align-items: stretch; }
.inline-field select { flex: 1; min-width: 0; }
.btn-mini.plus {
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  padding: 0 11px;
  color: var(--primary);
  border-color: #c7d7f5;
  background: #f3f7ff;
}
.btn-mini.plus:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

.kpi.kpi-spent::before { background: #7c3aed; }
.kpi.kpi-profit::before { background: #0891b2; }

.bar {
  height: 8px;
  min-width: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, #c4b5fd, #7c3aed);
}

/* ------------------------- Εκτύπωση ------------------------- */

/* Περιθώρια σελίδας */
@page { margin: 12mm; }

@media print {
  /* Το πλαίσιο της εφαρμογής δεν εκτυπώνεται ποτέ: αυτό που τυπώνεται είναι
     το παράθυρο (καρτέλα πελάτη / κατάσταση μήνα). Χωρίς αυτό, το .app κρατά
     το min-height:100vh και βγάζει μια ΟΛΟΚΛΗΡΗ ΚΕΝΗ ΠΡΩΤΗ ΣΕΛΙΔΑ. */
  html, body { height: auto !important; min-height: 0 !important; background: #fff; }
  body { font-size: 12px; }

  .app, .auth, .sidebar, .topbar, .no-print, .toast, .menu-btn { display: none !important; }

  .modal { position: static; inset: auto; background: none; padding: 0; display: block; overflow: visible; }
  .modal[hidden] { display: none !important; }
  .modal-box {
    max-width: none;
    max-height: none;
    overflow: visible;
    box-shadow: none;
    border-radius: 0;
    animation: none;
    width: auto;
  }
  .statement { padding: 0; }

  /* Στην εκτύπωση οι πίνακες μένουν κανονικοί πίνακες, όχι κάρτες */
  table.table { display: table !important; width: 100%; }
  table.table thead { display: table-header-group !important; }
  table.table tbody { display: table-row-group !important; }  table.table tr {
    display: table-row !important;
    border: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
  table.table th, table.table td {
    display: table-cell !important;
    text-align: left;
    border-bottom: 1px solid #cbd5e1 !important;
    padding: 5px 8px !important;
    font-size: 11px;
  }
  table.table td::before { content: none !important; }
  table.table td.num, table.table th.th-num { text-align: right !important; }
  table.table th { background: #f1f5f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.table tfoot { display: table-footer-group !important; }
  table.table tfoot td { border-top: 2px solid #0f172a !important; }

  /* Μη σπάει η κεφαλίδα από τα περιεχόμενά της */
  .st-head { page-break-after: avoid; page-break-inside: avoid; }
  .st-summary { page-break-inside: avoid; }
  .st-section { page-break-inside: auto; }
  .st-section h4 { page-break-after: avoid; }
  .st-final, .st-sign { page-break-inside: avoid; }
  .st-section table.table thead { display: table-header-group !important; }

  .st-box.total, .st-final { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .st-final { page-break-before: avoid; }
  a[href]::after { content: none !important; }
}
