/* ---- POS Distribution UI ---------------------------------------------- */
:root {
    --bg: #0f1720;
    --panel: #17212b;
    --panel-2: #1e2b38;
    --line: #2a3a49;
    --text: #e6edf3;
    --muted: #93a4b3;
    --accent: #e4002b;      /* JTI-ish red */
    --accent-2: #2f81f7;
    --ok: #3fb950;
    --warn: #d29922;
    --radical: #e4002b;
    --brandit: #2f81f7;
    --spc: #8957e5;
    --strategic: #3fb950;
    --prime: #58a6ff;
    --baseline: #d29922;
    --developing: #8b949e;
    --radius: 10px;
    --shadow: 0 6px 24px rgba(0,0,0,.35);
    --focus-ring: #2f81f766;   /* accent-2 @ 40% — 3px halo around focused controls */
    --gap-field: 16px;         /* vertical rhythm between stacked form controls */
}

* { box-sizing: border-box; }
/* Native widgets (date picker, number spinners, scrollbars) render dark. */
html { color-scheme: dark; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

/* ---- topbar ---- */
.topbar {
    display: flex; align-items: center; gap: 24px;
    padding: 10px 20px; background: var(--panel);
    border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
    font-size: 26px; color: var(--accent);
    background: #fff1; width: 40px; height: 40px; display: grid; place-items: center;
    border-radius: 9px;
}
.brand .title { font-weight: 700; font-size: 16px; }
.brand .subtitle { color: var(--muted); font-size: 12px; }

.batch-picker { display: flex; align-items: center; gap: 8px; }
.batch-picker label { color: var(--muted); font-size: 12px; }

.tabs { margin-left: auto; display: flex; gap: 8px; }
.tabs button {
    background: transparent; color: var(--muted); border: 0; padding: 9px 16px;
    border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.tabs button:hover { background: var(--panel-2); color: var(--text); }
.tabs button.active { background: var(--accent); color: #fff; }

select, textarea,
input[type=text], input[type=search], input[type=file],
input[type=password], input[type=email], input[type=number],
input[type=date], input[type=tel], input[type=url] {
    background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 8px; padding: 8px 10px; font: inherit; outline: none;
}

/* The ring is a box-shadow, not an outline: it paints outside the border box
   without taking layout space, so it never nudges neighbours. Every control
   below still needs a real gap around it, or the ring paints over whatever
   sits next to it. */
select:focus, textarea:focus, input:focus { border-color: var(--accent-2); }
select:focus-visible, textarea:focus-visible, input:focus-visible,
button:focus-visible, a.primary:focus-visible, .btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
}
/* Checkboxes/radios keep the native control but get the same ring. */
input[type=checkbox]:focus-visible, input[type=radio]:focus-visible {
    outline: 2px solid var(--accent-2); outline-offset: 2px; box-shadow: none;
}

/* ---- layout ---- */
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.hidden { display: none !important; }

.panel {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 20px; margin-bottom: 20px;
}
.panel.narrow { max-width: 720px; }
.panel h2 { margin: 0 0 14px; font-size: 15px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }

/* ---- summary cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px;
}
.card .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.card .v { font-size: 30px; font-weight: 700; margin-top: 6px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---- priority grid ---- */
.priority-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; }
.prio-card { border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; background: var(--panel-2); }
.prio-card .name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.prio-card .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.prio-card .big { font-size: 24px; font-weight: 700; margin: 6px 0 0; }
.prio-card .meta { color: var(--muted); font-size: 12px; }
.bar { height: 6px; border-radius: 4px; background: #ffffff14; margin-top: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; }

.dot.Strategic, .bar .Strategic { background: var(--strategic); }
.dot.Prime, .bar .Prime { background: var(--prime); }
.dot.Baseline, .bar .Baseline { background: var(--baseline); }
.dot.Developing, .bar .Developing { background: var(--developing); }

/* ---- agency grid ---- */
.agency-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; }
.agency-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--panel-2); }
.agency-card .ah { display: flex; align-items: baseline; justify-content: space-between; }
.agency-card .aname { font-weight: 700; font-size: 15px; }
.agency-card .atot { font-size: 26px; font-weight: 800; }
.agency-card.radical { border-top: 3px solid var(--radical); }
.agency-card.brandit { border-top: 3px solid var(--brandit); }
.agency-card.spc { border-top: 3px solid var(--spc); }
.agency-card .plist { margin-top: 10px; display: grid; gap: 4px; }
.agency-card .prow { display: flex; justify-content: space-between; font-size: 13px; }
.agency-card .prow .lbl { color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
table.grid td.num, table.grid th.num { text-align: right; }
table.grid tbody tr:hover, table.clickable tbody tr:hover { background: var(--panel-2); cursor: pointer; }
table.grid tfoot td { font-weight: 700; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.pill.Strategic { background: #3fb95022; color: var(--strategic); }
.pill.Prime { background: #58a6ff22; color: var(--prime); }
.pill.Baseline { background: #d2992222; color: var(--baseline); }
.pill.Developing { background: #8b949e22; color: var(--developing); }

/* ---- filters bar ---- */
.filters { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters .spacer { flex: 1; }
.filters .count { color: var(--muted); font-size: 13px; }
.filters #posSearch { min-width: 260px; }
.chk { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.pager button { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 14px; cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: default; }

/* ---- import ---- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 5px; }
.field input { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
/* a.primary too: reset.html's "Σύνδεση" is an <a>, which button.primary missed. */
button.primary, a.primary { background: var(--accent); color: #fff; border: 0; padding: 10px 20px; border-radius: 8px; font-weight: 700; cursor: pointer; text-decoration: none; }
button.primary:disabled { opacity: .5; }
/* .big was only ever defined under .prio-card, so .primary.big rendered normal-sized. */
.primary.big { display: block; width: 100%; padding: 12px 20px; text-align: center; }
.import-result { margin-top: 16px; padding: 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); }
.import-result.ok { border-color: #3fb95055; }
.import-result.err { border-color: #e4002b66; }
.import-result ul { margin: 8px 0 0; padding-left: 18px; color: var(--warn); font-size: 12.5px; }

/* ---- drawer ---- */
.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer-backdrop { position: absolute; inset: 0; background: #0008; }
.drawer-panel {
    position: absolute; right: 0; top: 0; height: 100%; width: min(560px, 96vw);
    background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow);
    padding: 22px; overflow-y: auto; animation: slidein .15s ease;
}
@keyframes slidein { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-close { position: absolute; top: 14px; right: 16px; background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }
.drawer h2 { margin: 0 6px 4px 0; font-size: 18px; }
.drawer .code { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.drawer h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 22px 0 10px; border-top: 1px solid var(--line); padding-top: 16px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
.edit-grid { display: grid; gap: 12px; }
.edit-grid label { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); }
.edit-grid input, .edit-grid textarea, .edit-grid select { width: 100%; }
.edit-grid textarea { min-height: 60px; resize: vertical; font: inherit; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.edit-grid .chk-row { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.edit-grid .chk-row input { width: auto; }

.constraint-list { display: grid; gap: 8px; }
.constraint {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
}
.constraint .ctype { font-weight: 700; }
.constraint .cdel { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; }
.constraint .cdel:hover { color: var(--accent); }
.add-constraint { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.add-constraint select, .add-constraint input { width: 100%; }
.add-constraint .full { grid-column: 1 / -1; }

.month-hist { font-size: 12.5px; }
.month-hist .mh { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.month-hist .mh .mper { font-weight: 700; width: 70px; }

.btnrow { display: flex; gap: 10px; margin-top: 14px; }
.btn { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- toast ---- */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
    padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 60;
    font-size: 13.5px;
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--accent); }

.empty { color: var(--muted); text-align: center; padding: 60px 20px; font-size: 15px; }

/* ---- auth pages ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px 24px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-brand .logo { color: var(--accent); font-size: 24px; background: #fff1; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 9px; }
.auth-brand .t { font-weight: 800; }
.auth-brand .s { color: var(--muted); font-size: 12px; }
.auth-card h2 { font-size: 18px; margin: 0 0 14px; }
.auth-hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; line-height: 1.5; }
/* display:block is load-bearing — .fld is a <label>, and vertical margins are
   ignored on inline boxes, so without it margin-bottom does nothing and the
   next control sits flush against the input. */
.auth-card .fld { display: block; margin-bottom: var(--gap-field); }
.auth-card .fld > span { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 5px; }
.auth-card .fld input { width: 100%; }
/* Clears the 3px focus ring of the field above. */
.auth-card .primary { display: block; width: 100%; margin-top: 6px; }
.auth-link { display: inline-block; margin-top: 12px; color: var(--accent-2); text-decoration: none; font-size: 13px; }
.auth-link:hover { text-decoration: underline; }
.auth-msg { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.auth-msg.ok { background: #3fb95018; border: 1px solid #3fb95044; }
.auth-msg.err { background: #e4002b18; border: 1px solid #e4002b55; color: #ffb3c0; }

/* ---- topbar user chip ---- */
.userbox { display: flex; align-items: center; gap: 10px; margin-left: 8px; }
.userbox .uname { color: var(--muted); font-size: 12.5px; }
.userbox .logout { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 12.5px; }
.userbox .logout:hover { border-color: var(--accent); }

/* ---- contextual help ---- */
.help-fab {
    position: fixed; right: 22px; bottom: 22px; z-index: 55;
    width: 48px; height: 48px; border-radius: 50%; border: 0;
    background: var(--accent-2); color: #fff; font-size: 24px; font-weight: 800;
    cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.help-fab:hover { filter: brightness(1.1); }
.help-modal { position: fixed; inset: 0; z-index: 70; }
.help-bg { position: absolute; inset: 0; background: #000a; }
.help-panel {
    position: absolute; right: 0; top: 0; height: 100%; width: min(560px, 96vw);
    background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow);
    padding: 24px 26px; overflow-y: auto; animation: slidein .15s ease;
}
.help-close { position: absolute; top: 14px; right: 16px; background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }
.help-panel h2 { margin: 0 40px 4px 0; font-size: 20px; }
.help-panel .help-intro { color: var(--muted); font-size: 13.5px; margin: 6px 0 18px; line-height: 1.55; }
.help-panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-2); margin: 20px 0 10px; }
.help-item { padding: 9px 0; border-bottom: 1px solid var(--line); display: grid; gap: 3px; }
.help-item .hi-term { font-weight: 700; font-size: 13.5px; }
.help-item .hi-desc { color: var(--muted); font-size: 13px; line-height: 1.5; }
.help-tip { margin-top: 16px; padding: 12px 14px; background: #2f81f715; border: 1px solid #2f81f733; border-radius: 9px; font-size: 12.5px; color: var(--text); line-height: 1.5; }
.help-tip b { color: var(--accent-2); }

/* ---- plan ---- */
.plan-controls { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.caps { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.caps-title { color: var(--muted); font-size: 12.5px; }
.caps label { display: inline-flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); }
.caps input { width: 62px; }
.plan-controls .primary { margin-left: auto; }
.plan-view-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.plan-view-controls h2 { margin: 0; }

.agency-tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 700; color: #fff; }
.agency-tag.radical { background: var(--radical); }
.agency-tag.brandit { background: var(--brandit); }
.agency-tag.spc { background: var(--spc); }

.card .delta { font-size: 12px; margin-top: 2px; }
.card .delta.ok { color: var(--ok); }
.card .delta.bad { color: var(--warn); }

.warn-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.warn-filters button {
    background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
    border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.warn-filters button.active { border-color: var(--accent-2); color: var(--text); }
.warn-list { display: grid; gap: 6px; max-height: 320px; overflow-y: auto; }
.warn-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    background: var(--panel-2); border: 1px solid var(--line); border-left-width: 3px;
    border-radius: 8px; font-size: 12.5px; cursor: pointer;
}
.warn-item.high { border-left-color: var(--accent); }
.warn-item.warn { border-left-color: var(--warn); }
.warn-item.info { border-left-color: var(--accent-2); }
.warn-item:hover { background: var(--line); }
.warn-item .wtype { font-weight: 700; min-width: 96px; }
.warn-item .wpos { color: var(--muted); }

.flagrow { box-shadow: inset 3px 0 0 var(--warn); }
.rowflash { animation: flash 1.2s ease; }
@keyframes flash { from { background: #d2992244; } to { background: transparent; } }

.mini { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; }
.mini:hover { color: var(--accent); }

.date-head td { background: var(--panel-2); font-weight: 700; color: var(--text); position: sticky; }

/* visit editor in drawer */
.ve-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ve-grid label { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); }
.ve-grid .full { grid-column: 1 / -1; }
.ve-grid input, .ve-grid select { width: 100%; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; background: #ffffff14; color: var(--muted); }
.chip.sb { background: #58a6ff22; color: var(--prime); }

/* ---- tab badge ---- */
.badge { display: inline-block; min-width: 18px; padding: 0 6px; height: 18px; line-height: 18px; text-align: center; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; margin-left: 4px; }

/* ---- reports queue ---- */
.report-queue { display: grid; gap: 10px; }
.report-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.report-card .rc-top { display: flex; align-items: baseline; gap: 10px; justify-content: space-between; }
.report-card .rc-pos { font-weight: 700; }
.report-card .rc-meta { color: var(--muted); font-size: 12px; }
.report-card .rc-comment { margin: 8px 0 10px; font-size: 13.5px; color: var(--text); font-style: italic; }
.report-card .rc-hint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hint-type { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.hint-type.prefer_daytime { background: #3fb95022; color: var(--strategic); }
.hint-type.exclude_day, .hint-type.exclude_daytime { background: #e4002b22; color: var(--accent); }
.hint-type.note { background: #8b949e22; color: var(--muted); }
.report-card select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; font: inherit; }
.report-card .rc-actions { display: flex; gap: 8px; margin-left: auto; }
.report-card .rc-actions .btn { padding: 6px 14px; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #06210d; }
.btn.danger { background: transparent; border-color: var(--accent); color: var(--accent); }
.conf { font-size: 11px; color: var(--muted); }
#rUploadForm { display: flex; gap: 10px; align-items: center; }
