/* ΣΤΟΑ · διαχειριστικό πωλήσεων. Τα χρώματα των τμημάτων είναι τα ίδια με των email (Report::COLORS). */
:root {
  --bg: #f4f6f9; --card: #ffffff; --ink: #1d2330; --muted: #5b6475; --line: #e3e7ee; --accent: #1f4e79;
  --accent-soft: #e8eff7; --up: #0f7a4f; --down: #b3261e; --warn-bg: #fff4e5; --ok-bg: #e9f6ef; --err-bg: #fdecea;
  --deli: #2a78d6; --food: #eb6834; --b2b: #1baf7a;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 10px; color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* top bar */
.top { background: var(--accent); color: #fff; }
.top .in { max-width: 1280px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; min-height: 52px; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .3px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brand img { display: block; height: 30px; width: auto; }
.auth .brand { flex-direction: column; gap: 6px; }
.auth .brand img { height: 60px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { color: #dce6f0; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav a.on { background: rgba(255, 255, 255, .18); color: #fff; }
.nav .sep { width: 1px; background: rgba(255, 255, 255, .25); margin: 6px 6px; }
.who { display: flex; gap: 10px; align-items: center; font-size: 13px; color: #dce6f0; }
.who form { margin: 0; }
.who button { background: none; border: 1px solid rgba(255, 255, 255, .4); color: #fff; border-radius: 6px; padding: 3px 9px; cursor: pointer; }

main { max-width: 1280px; margin: 0 auto; padding: 18px 16px 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } }

/* range bar */
.range { display: flex; flex-direction: column; gap: 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets a { text-decoration: none; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: #fff; font-size: 13px; }
.presets a:hover { border-color: var(--accent); }
.presets a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
input, select, button, textarea { font: inherit; }
input[type=date], input[type=text], input[type=email], input[type=password], select, textarea {
  border: 1px solid #cfd5df; border-radius: 6px; padding: 6px 8px; background: #fff; color: var(--ink); min-width: 0; }
/* several choices at once (the categories): the real <select multiple> is hidden, the list below replaces it */
.multi { position: relative; }
.multi-src { display: none; }
.multi-btn { width: 260px; max-width: 100%; text-align: left; border: 1px solid #cfd5df; border-radius: 6px; padding: 6px 24px 6px 8px;
  background: #fff url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%235b6475' d='M0 0h10L5 6z'/%3E%3C/svg%3E") no-repeat right 9px center/9px 6px;
  color: var(--ink); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-btn.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.multi-panel { display: none; position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: 320px; max-width: 86vw;
  background: #fff; border: 1px solid #cfd5df; border-radius: 8px; box-shadow: 0 6px 20px rgba(16, 24, 40, .16); padding: 8px; }
.multi.open .multi-panel { display: block; }
.multi-search { width: 100%; margin-bottom: 6px; }
.multi-clear { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0 0 6px; font-size: 12px; }
.multi-list { max-height: 260px; overflow-y: auto; }
.multi-list label { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 4px; color: var(--ink); font-size: 13px; cursor: pointer; }
.multi-list label:hover { background: var(--accent-soft); }
.multi-list input { margin: 0; }

.btn { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn.light { background: var(--accent-soft); color: var(--accent); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.danger { background: var(--down); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); border-top: 3px solid var(--accent); }
.kpi.deli { border-top-color: var(--deli); } .kpi.food { border-top-color: var(--food); } .kpi.b2b { border-top-color: var(--b2b); }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 22px; font-weight: 700; margin: 2px 0; white-space: nowrap; }
.kpi .s { font-size: 12px; color: var(--muted); }
.delta { font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 999px; white-space: nowrap; }
.delta.up { color: var(--up); background: var(--ok-bg); }
.delta.down { color: var(--down); background: var(--err-bg); }
.delta.flat { color: var(--muted); background: var(--bg); }

/* tables */
.scroll { overflow-x: auto; }
table.t { border-collapse: collapse; width: 100%; font-size: 13px; }
.t th, .t td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.t th { background: #f7f9fc; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
.t th.l, .t td.l { text-align: left; white-space: normal; }
.t tr:hover td { background: #fafbfd; }
.t tfoot td { font-weight: 700; background: #f2f5f9; }
.t th[data-sort] { cursor: pointer; user-select: none; }
.t th[data-sort]:hover { color: var(--accent); }
.t th.asc::after { content: " ▲"; } .t th.desc::after { content: " ▼"; }
/* the comparison: a block of columns per month, a two-row header, and the names stay in sight sideways */
.t.cmp thead tr:first-child th { top: 0; height: 44px; }
.t.cmp thead tr:nth-child(2) th { top: 44px; }
.t.cmp th.grp, .t.cmp td.grp { border-left: 2px solid var(--line); }
.t.cmp th.l, .t.cmp td.l { position: sticky; left: 0; z-index: 2; background: #fff; }
.t.cmp thead th.l { z-index: 4; background: #f7f9fc; }
.t.cmp tfoot td.l { background: #f2f5f9; }
.t.cmp thead th { z-index: 3; }

.bar { height: 6px; background: var(--accent-soft); border-radius: 3px; min-width: 40px; }
.bar i { display: block; height: 6px; background: var(--accent); border-radius: 3px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bg); color: var(--muted); }
.tag.deli { background: #e6f0fb; color: var(--deli); } .tag.food { background: #fdeee7; color: #b9481b; } .tag.b2b { background: #e5f6ef; color: #12805a; }
.tag.ok { background: var(--ok-bg); color: var(--up); } .tag.error { background: var(--err-bg); color: var(--down); } .tag.running { background: var(--warn-bg); color: #8a5300; }

.chart { position: relative; height: 280px; }
.chart.tall { height: 360px; }
.note { background: var(--warn-bg); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px; }
.ok { background: var(--ok-bg); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.err { background: var(--err-bg); color: var(--down); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }

/* sign in */
.auth { max-width: 380px; margin: 9vh auto; padding: 0 16px; }
.auth .card { padding: 24px; }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.auth input { width: 100%; }
.auth .brand { color: var(--accent); font-size: 18px; margin-bottom: 14px; }

/* settings */
.settings { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); gap: 8px 14px; align-items: center; }
.settings input { width: 100%; }
.settings .hint { grid-column: 2; font-size: 11px; color: var(--muted); margin-top: -6px; }
@media (max-width: 700px) { .settings { grid-template-columns: minmax(0, 1fr); } .settings .hint { grid-column: 1; } }
details summary { cursor: pointer; color: var(--accent); }

/* pivot (PivotTable.js) */
#pivot { overflow-x: auto; }
/* the result scrolls in its own box, so the headers and the first column stay visible */
.pvtRendererArea { overflow: auto; max-height: calc(100vh - 270px); }
.pvtRendererArea .pvtTable thead th { position: sticky; top: 0; z-index: 3; background: #fff; }
/* fallback if the script does not run: the second header row sits under the first */
.pvtRendererArea .pvtTable thead tr:nth-child(2) th { top: 26px; }
.pvtRendererArea .pvtTable tbody th:first-child { position: sticky; left: 0; z-index: 2; background: #fff; }
.pvtRendererArea .pvtTable thead th:first-child { z-index: 4; }
.pvtRendererArea .pvtTable tbody tr:hover th:first-child { background: #f4f7fb; }
/* full screen for the pivot card */
.card.full { position: fixed; inset: 8px; z-index: 50; margin: 0; overflow: auto; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
.card.full .pvtRendererArea { max-height: calc(100vh - 190px); }
.pvtUi { font-size: 12px; }
.pvtTable { font-size: 12px !important; }

/* phones: the brand above, the menu and the presets scroll sideways instead of wrapping into many rows */
@media (max-width: 700px) {
  .top .in { flex-direction: column; align-items: stretch; gap: 4px; padding: 8px 16px; }
  .nav { flex-wrap: nowrap; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .who { justify-content: space-between; }
  .presets { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .presets a { white-space: nowrap; }
  main { padding: 12px 12px 32px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi .v { font-size: 18px; }
}
