/* ---------- Pound Store CRM ---------- */
:root {
  /* Brand colours from the Pound Store logo */
  --green: #1a7c38;
  --green-dark: #10521f;
  --green-light: #e7f4ea;
  --gold: #ffd400;       /* logo yellow */
  --gold-dark: #e6bf00;
  --ink: #161616;        /* logo black */
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f6f2;
  --card: #ffffff;
  --red: #e01f1f;        /* logo red */
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
h1, h2, h3 { margin: 0; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, #ffe14d 0%, var(--gold) 45%, var(--gold-dark) 100%);
}
.login-card {
  background: var(--card); border-radius: 16px; padding: 40px 36px;
  width: 360px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  border-top: 6px solid var(--red);
  text-align: center;
}
.login-logo {
  width: 110px; height: 110px; margin: 0 auto 14px; border-radius: 50%;
  object-fit: cover; display: block;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.login-card h1 { font-size: 22px; color: var(--green-dark); }
.login-sub { color: var(--muted); margin: 6px 0 24px; }
.login-card form { text-align: left; }
.login-card label { display: block; margin-bottom: 14px; font-weight: 600; color: var(--ink); }
.login-card input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.login-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-light); }
.login-error {
  background: #fdecea; color: var(--red); border-radius: 8px;
  padding: 8px 12px; margin-bottom: 12px; font-size: 13px;
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent; border-radius: 8px; padding: 8px 16px;
  font-weight: 600; background: #eef2f6; color: var(--ink);
}
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); filter: none; }
.btn-gold { background: var(--gold); color: #111; }
.btn-gold:hover { background: var(--gold-dark); filter: none; }
.btn-danger { background: #fdecea; color: var(--red); }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.25); color: #e9f5ee; }
.btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }

/* ---------- Layout ---------- */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0; background: linear-gradient(180deg, #1d1d1d, #0d0d0d);
  color: #e8e8e8; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  border-right: 4px solid var(--gold);
}
.brand { display: flex; gap: 12px; align-items: center; padding: 16px 18px 13px; border-bottom: 1px solid rgba(255,212,0,.25); }
.brand-logo {
  width: 46px; height: 46px; border-radius: 50%; object-fit: cover; display: block;
  background: var(--gold);
}
.brand-name { font-weight: 700; font-size: 16px; color: var(--gold); }
.brand-sub { font-size: 11.5px; color: #bdbdbd; letter-spacing: .5px; }

.nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-heading { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); opacity: .8; padding: 12px 12px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px;
  color: #e8e8e8; text-decoration: none; margin: 1px 0; font-size: 13.5px;
}
.nav-item:hover { background: rgba(255,212,0,.14); }
.nav-item.active { background: var(--gold); color: #111; font-weight: 700; }
.nav-icon { width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,212,0,.25); }
.user-badge { margin-bottom: 10px; font-size: 12.5px; line-height: 1.5; }
.user-badge b { color: #fff; display: block; font-size: 13.5px; }
.role-chip {
  display: inline-block; background: var(--gold); color: #111; border-radius: 20px;
  font-size: 10.5px; font-weight: 700; padding: 1px 10px; letter-spacing: .5px; margin-top: 3px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 3px solid var(--red); padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 5;
}
.topbar h2 { font-size: 18px; color: var(--green-dark); }
.topbar-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.topbar-controls select, .topbar-controls input {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.content { padding: 24px; max-width: 1280px; width: 100%; }

/* ---------- Cards / KPIs ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.card h3 { font-size: 15px; color: var(--green-dark); margin-bottom: 14px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--green);
  border-radius: var(--radius); padding: 16px 18px;
}
.kpi.gold { border-left-color: var(--gold); }
.kpi.red { border-left-color: var(--red); }
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 4px; color: var(--ink); }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; background: #fff; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
table.grid th {
  background: var(--green); color: #fff; font-size: 12px; font-weight: 600;
  white-space: nowrap; position: sticky; top: 0;
}
table.grid td { font-size: 13px; }
table.grid tr:nth-child(even) td { background: #fafcfb; }
table.grid input, table.grid select {
  width: 100%; min-width: 70px; border: 1px solid transparent; background: transparent;
  padding: 4px 6px; border-radius: 5px;
}
table.grid input:focus { border-color: var(--green); background: #fff; outline: none; }
table.grid td.calc { background: var(--green-light) !important; font-weight: 600; text-align: right; white-space: nowrap; }
table.grid td.num input { text-align: right; }
table.grid .wide { min-width: 160px; }
table.grid tfoot td { background: var(--green-dark) !important; color: #fff; font-weight: 700; }
table.grid td.rownum { color: var(--muted); text-align: center; width: 34px; }
.row-del { background: none; border: none; color: #b6c2cf; font-size: 15px; padding: 0 4px; }
.row-del:hover { color: var(--red); }

.table-actions { display: flex; gap: 10px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.save-info { font-size: 12px; color: var(--muted); margin-left: auto; }

/* fields row above tables */
.fields-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.field input:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px var(--green-light); }
.field.readonly input { background: var(--green-light); font-weight: 700; border-color: transparent; }

/* ---------- P&L specials ---------- */
.pnl-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.pnl-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; text-align: center; }
.pnl-box .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.pnl-box .val { font-size: 18px; font-weight: 700; margin-top: 4px; }
.pnl-box.hl { background: var(--green); color: #fff; }
.pnl-box.hl .lbl { color: #cfe8da; }
.partner-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.partner-card { border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 8px; padding: 12px; background: #fff; }
.partner-card input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; margin-top: 4px; }
.partner-share { font-size: 18px; font-weight: 700; color: var(--green-dark); margin-top: 8px; }
.partner-pct { font-size: 11px; color: var(--muted); }

/* ---------- Chart ---------- */
.chart-wrap { overflow-x: auto; }
.bar-label { font-size: 11px; fill: var(--muted); }
.bar-value { font-size: 11px; font-weight: 700; fill: var(--ink); }

/* ---------- Misc ---------- */
.empty {
  text-align: center; color: var(--muted); padding: 40px 20px;
  border: 2px dashed var(--line); border-radius: var(--radius); background: #fff;
}
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.green { background: var(--green-light); color: var(--green-dark); }
.badge.gold { background: #fff5bf; color: #7a6300; }
/* Report completion */
.comp-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.comp-row:last-child { border-bottom: none; }
.comp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.comp-count { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.comp-count.ok { color: var(--green-dark); }
.progress-track { height: 10px; background: #eef1ee; border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--gold); border-radius: 6px; transition: width .3s; }
.progress-fill.full { background: var(--green); }
.comp-missing { margin-top: 8px; font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip-missing {
  background: #fdecea; color: var(--red); border-radius: 12px; padding: 1px 9px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}

.copy-bar {
  background: #fff5bf; border: 1px solid var(--gold); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px; color: #5c4a00;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 100;
}
.toast.ok { background: var(--green-dark); }
.toast.err { background: var(--red); }
.modal-back {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; padding: 24px; width: 440px; max-width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { color: var(--green-dark); margin-bottom: 16px; }
.modal .field { margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.leader-list { list-style: none; padding: 0; margin: 0; }
.leader-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.leader-list li:last-child { border-bottom: none; }
.leader-list b { display: block; }
.leader-list span { color: var(--muted); font-size: 12.5px; }

textarea.suggest-box { min-height: 180px; resize: vertical; }

/* ---------- Print report ---------- */
.print-section { page-break-after: always; }
.print-cover {
  text-align: center; padding: 90px 20px; background: var(--gold);
  color: #111; border-radius: var(--radius);
  border: 6px solid var(--red); outline: 10px solid var(--gold);
}
.print-cover .big-logo {
  width: 190px; height: 190px; margin: 0 auto 24px; border-radius: 50%;
  object-fit: cover; display: block; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.print-cover h1 { font-size: 34px; letter-spacing: 2px; color: var(--green-dark); }
.print-cover .sub { color: #6b1010; font-weight: 600; }
@media print {
  .sidebar, .topbar, .table-actions, .no-print, .toast { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { border: none; padding: 8px 0; }
  table.grid th { background: var(--green) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-cover { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@page { size: A4; margin: 12mm; }

@media (max-width: 860px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 4px solid var(--gold); }
  .nav { max-height: 260px; }
  .content { padding: 14px; }
  .cash-cols { grid-template-columns: 1fr !important; }
  .topbar { padding: 10px 14px; }
  .print-cover { padding: 50px 14px; }
}
