/* JustGigs dashboard — modern SaaS / fintech theme */

:root {
  --accent: #6366f1;
  --accent-weak: #eef0ff;
  --c-green: #16a34a;
  --c-cyan: #0891b2;
  --c-pink: #db2777;
  --c-amber: #d97706;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fbfbfe;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --border: #e9ecf3;
  --border-2: #eef1f6;
  --track: #eef1f6;
  --track-strong: #cbd5e1;

  --up-bg: #e8f7ee; --up-fg: #15803d;
  --down-bg: #fdecec; --down-fg: #dc2626;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 4px 16px rgba(16, 24, 40, 0.06);

  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

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

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
/* ---------------- Login (PIN) ---------------- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; font-family: var(--font); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 38px 34px; width: min(380px, 100%); box-shadow: 0 24px 60px rgba(16, 24, 40, 0.12); display: flex; flex-direction: column; align-items: center; text-align: center; }
.login-logo { height: 34px; width: auto; margin-bottom: 24px; }
.login-title { font-size: 19px; font-weight: 750; margin: 0 0 4px; color: var(--ink); }
.login-sub { font-size: 13px; color: var(--ink-3); margin: 0 0 22px; }
.login-input { width: 100%; padding: 14px 16px; font-size: 20px; letter-spacing: 0.18em; text-align: center; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); color: var(--ink); outline: none; font-family: var(--font); box-sizing: border-box; }
.login-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.login-btn { width: 100%; margin-top: 14px; padding: 13px; font-size: 15px; font-weight: 650; border: 0; border-radius: 11px; background: var(--accent); color: #fff; cursor: pointer; font-family: var(--font); }
.login-btn:hover { background: #5457e6; }
.login-btn:disabled { opacity: 0.6; cursor: default; }
.login-err { margin-top: 16px; font-size: 13px; color: var(--down-fg); background: var(--down-bg); padding: 10px 12px; border-radius: 9px; width: 100%; box-sizing: border-box; }

.brand { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); padding: 4px 8px 22px; }
.brand span { color: var(--accent); }
.brand i { color: var(--accent); font-style: normal; }
.brand-logo { height: 30px; width: auto; display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--ink-2); font-weight: 500; cursor: pointer;
  text-decoration: none; font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
}
.nav-item .ic { width: 18px; text-align: center; color: var(--ink-3); font-size: 14px; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.nav-item.active .ic { color: var(--accent); }
.side-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); }
.side-foot-title { font-weight: 600; font-size: 13px; }
.side-foot-sub { color: var(--ink-3); font-size: 12px; }

/* ---------------- Main / topbar ---------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 28px;
  background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.tabs { display: flex; gap: 4px; background: var(--track); padding: 4px; border-radius: 10px; }
.tab {
  border: 0; background: transparent; padding: 7px 16px; border-radius: 7px;
  font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; font-family: var(--font);
}
.tab.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.ranges { display: flex; gap: 2px; background: var(--track); padding: 3px; border-radius: 9px; }
.range-pill {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 6px;
  font-weight: 600; font-size: 12px; color: var(--ink-2); cursor: pointer; font-family: var(--font);
}
.range-pill.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 20px;
}
.status-badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.status-badge.live { background: var(--up-bg); color: var(--up-fg); }
.status-badge.live .dot { background: var(--c-green); box-shadow: 0 0 0 3px rgba(22,163,74,0.15); }
.status-badge.demo { background: #fff4e5; color: var(--c-amber); }
.status-badge.demo .dot { background: var(--c-amber); }
.updated { font-size: 12px; color: var(--ink-3); }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); width: 32px; height: 32px;
  border-radius: 9px; cursor: pointer; font-size: 15px; color: var(--ink-2);
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--accent); }
.icon-btn.spin { animation: spin 0.5s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner { display: none; margin: 14px 28px 0; padding: 10px 14px; border-radius: 10px; font-size: 13px; }
.banner.show { display: block; }
.banner.warn { background: #fff4e5; color: var(--c-amber); border: 1px solid #ffe2b8; }
.banner.info { background: var(--accent-weak); color: var(--accent); border: 1px solid #dfe2ff; }

/* Tab views — hide every view except the active tab's (shown elements keep their natural display) */
body:not([data-tab="overview"]) .view-overview,
body:not([data-tab="finances"]) .view-finances,
body:not([data-tab="payments"]) .view-payments,
body:not([data-tab="workers"]) .view-workers { display: none; }

.workers-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }

/* ---------------- Collections worklist ---------------- */
.collections-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.collections-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.seg-toggle { display: inline-flex; background: var(--track); padding: 3px; border-radius: 9px; }
.seg-toggle button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 6px;
  font-weight: 600; font-size: 12.5px; color: var(--ink-2); cursor: pointer; font-family: var(--font);
}
.seg-toggle button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filter-input {
  font-family: var(--font); font-size: 13px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; outline: none;
}
.filter-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
#pay-search { flex: 1; min-width: 220px; }
#pay-company { max-width: 220px; }
.filter-date { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.filter-date .filter-input { padding: 7px 8px; }
.filter-clear {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  border-radius: 9px; padding: 8px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: var(--font);
}
.filter-clear:hover { background: var(--surface-2); color: var(--accent); }

.collections-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.collections-table th.sortable:hover { color: var(--accent); }
.collections-table th .arrow { color: var(--accent); margin-left: 3px; }
.collections-table td { vertical-align: top; }
.col-company { font-weight: 600; }
.col-unit { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 400; margin-top: 1px; }
.col-mgr { font-size: 12.5px; }
.col-phone { display: block; font-size: 12px; color: var(--accent); text-decoration: none; margin-top: 1px; }
.col-phone:hover { text-decoration: underline; }
.age-pill { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12.5px; }
.age-old { color: var(--down-fg); }
.age-mid { color: var(--c-amber); }
.collections-foot { margin-top: 10px; font-size: 12px; color: var(--ink-3); }
.collections-table tbody tr { cursor: pointer; }
.collections-table tbody tr:hover { background: var(--surface-2); }

/* ---------------- Gig detail modal ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: 0 24px 60px rgba(16, 24, 40, 0.28);
  width: min(760px, 100%); max-height: 86vh; overflow: auto; position: relative; padding: 24px 26px;
}
.modal-close {
  position: absolute; top: 14px; right: 16px; border: 0; background: var(--track);
  width: 30px; height: 30px; border-radius: 8px; font-size: 18px; line-height: 1; cursor: pointer; color: var(--ink-2);
}
.modal-close:hover { background: var(--border); color: var(--ink); }
.gig-modal-head h2 { margin: 0 30px 2px 0; font-size: 18px; font-weight: 700; }
.gig-modal-head .sub { color: var(--ink-3); font-size: 13px; }
.gig-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 14px 0 18px; }
.gig-meta div { font-size: 13px; }
.gig-meta .lbl { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; display: block; }
.gig-meta .val { font-weight: 600; }
.gig-shifts-title { font-size: 13px; font-weight: 650; color: var(--ink-2); margin: 6px 0 8px; }
.tick { color: var(--c-green); font-weight: 700; }
.cross { color: var(--down-fg); font-weight: 700; }

/* Standalone gig detail page */
.gigpage-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.gigpage-body { padding: 24px 28px 48px; max-width: 900px; margin: 0 auto; }
.shift-row { cursor: pointer; }
.shift-row:hover { background: var(--surface-2); }

/* single shift detail popup */
#shift-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 210; display: flex; align-items: center; justify-content: center; padding: 20px; }
#shift-modal[hidden] { display: none; }
.shift-card { background: var(--surface); border-radius: 14px; padding: 22px 24px; width: min(440px, 100%); max-height: 86vh; overflow: auto; position: relative; box-shadow: 0 24px 60px rgba(16, 24, 40, 0.28); }
.modal-x { position: absolute; top: 12px; right: 14px; border: 0; background: var(--track); width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 17px; color: var(--ink-2); }
.modal-x:hover { background: var(--border); color: var(--ink); }
.shift-title { font-size: 17px; font-weight: 700; margin: 0 28px 12px 0; }
.shift-row-d { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--border-2); font-size: 13px; }
.shift-row-d .k { color: var(--ink-3); }
.shift-row-d .v { font-weight: 600; text-align: right; }
.shift-id { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--ink-3); word-break: break-all; }
.shift-id b { color: var(--ink-2); }
.gigpage-actions { display: flex; align-items: center; gap: 10px; }
.btn-primary {
  border: 0; background: var(--accent); color: #fff; font-family: var(--font);
  font-weight: 650; font-size: 13px; padding: 9px 16px; border-radius: 9px; cursor: pointer;
}
.btn-primary:hover { background: #5457e6; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.toggle-hidden { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; user-select: none; }
.row-muted { opacity: 0.5; }

/* ---------------- Gig summary bill (on-screen preview + A4 print) ---------------- */
#print-area { display: none; }

/* bill visuals — shared by the preview sheet and the printed page */
.pdf-page { color: #111; }
.pdf-top { display: flex; align-items: center; justify-content: space-between; }
.pdf-h1 { font-size: 24px; font-weight: 800; color: #111; }
.pdf-logo { height: 30px; width: auto; }
.pdf-gigid { font-size: 13px; color: #222; margin: 12px 0 18px; }
.pdf-sec { font-size: 15px; font-weight: 800; color: #111; margin: 16px 0 10px; }
.pdf-line { display: flex; align-items: center; gap: 9px; font-size: 13px; color: #222; margin: 7px 0; }
.pdf-ic { width: 17px; height: 17px; color: #5c30d8; flex: none; }
.pdf-biz { font-size: 13.5px; color: #111; margin-top: 6px; }
.pdf-overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 18px; margin-top: 6px; }
.pdf-overview .ov { display: flex; flex-direction: column; gap: 16px; padding-bottom: 6px; border-bottom: 2px solid #111; }
.pdf-overview .ov-l { font-size: 13px; color: #333; }
.pdf-overview .ov-v { font-size: 17px; font-weight: 700; color: #111; min-height: 20px; }
.pdf-cont { font-size: 12px; color: #555; font-weight: 600; border-bottom: 1px solid #ccc; padding-bottom: 6px; margin-bottom: 10px; }
.pdf-table { width: 100%; border-collapse: collapse; margin-top: 18px; font-size: 12.5px; }
.pdf-table th, .pdf-table td { border: 1px solid #c9c9cf; padding: 8px 10px; text-align: center; }
.pdf-table th { background: #fff; font-weight: 800; color: #111; }
.pdf-table td:first-child, .pdf-table th:first-child { text-align: left; }
.pdf-footer { margin-top: 20px; border-top: 1px solid #d0d0d0; padding-top: 12px; text-align: center; }
.pdf-disclaimer { font-size: 10.5px; font-weight: 700; color: #333; line-height: 1.55; margin: 0 0 8px; }
.pdf-bank { font-size: 11px; font-weight: 800; color: #111; margin: 0; }

/* preview modal */
#summary-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 200; display: flex; flex-direction: column; align-items: center; padding: 20px; overflow: auto; }
#summary-modal[hidden] { display: none; }
.summary-bar { width: min(794px, 100%); display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.summary-bar .title { color: #fff; font-weight: 700; font-size: 14px; }
.summary-bar .actions { display: flex; gap: 10px; }
.pdf-sheet { width: min(794px, 100%); background: #fff; border-radius: 8px; padding: 34px 38px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3); }
.pdf-sheet .pdf-page + .pdf-page { margin-top: 28px; padding-top: 24px; border-top: 1px dashed #ccc; }

@media print {
  @page { size: A4; margin: 14mm; }
  .gigpage, #summary-modal { display: none !important; }
  #print-area { display: block; }
  body { background: #fff; }
  .pdf-page { break-after: page; }
  .pdf-page:last-child { break-after: auto; }
}
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .pay-grid { grid-template-columns: 1fr; } }
#most-tbody td:first-child, #least-tbody td:first-child { color: var(--ink-3); font-variant-numeric: tabular-nums; width: 28px; }
#most-tbody td:nth-child(2), #least-tbody td:nth-child(2) { font-weight: 600; }

/* ---------------- Page ---------------- */
.page { padding: 24px 28px 48px; max-width: 1320px; }
.page-head { margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); font-size: 13.5px; }

/* KPI grid */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 27px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.demo-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c-amber); display: inline-block; }

.chip { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }
.chip-up { background: var(--up-bg); color: var(--up-fg); }
.chip-down { background: var(--down-bg); color: var(--down-fg); }
.chip-flat { background: var(--track); color: var(--ink-3); }

/* Panels */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.panel-head h3 { margin: 0; font-size: 13.5px; font-weight: 650; color: var(--ink-2); }
.panel-sub { font-size: 12px; color: var(--ink-3); }

/* Gigs by company */
.company-panel { margin-bottom: 18px; }
.company-body { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: center; }
.company-donut { display: grid; place-items: center; }
.donut-svg { width: 200px; height: 200px; }
.donut-value { font-size: 26px; font-weight: 750; fill: var(--ink); }
.donut-label { font-size: 11px; font-weight: 600; fill: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }

.company-list { display: flex; flex-direction: column; gap: 2px; }
.company-row {
  display: grid; grid-template-columns: 20px 12px 1.4fr 2fr auto auto; align-items: center; gap: 10px;
  padding: 7px 6px; border-radius: 8px;
}
.company-row:hover { background: var(--surface-2); }
.company-rank { font-size: 12px; color: var(--ink-3); font-weight: 600; text-align: center; }
.company-dot { width: 9px; height: 9px; border-radius: 50%; }
.company-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-bar { height: 7px; background: var(--track); border-radius: 6px; overflow: hidden; }
.company-bar span { display: block; height: 100%; border-radius: 6px; }
.company-vac { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-2); text-align: right; min-width: 56px; }
.company-pct { font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 700; text-align: right; min-width: 48px; }

/* Trend grid */
.trend-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 18px; }
.chart { width: 100%; }
.chart-svg { width: 100%; height: auto; display: block; }
.grid-line { stroke: var(--border-2); stroke-width: 1; }
.axis-label { fill: var(--ink-3); font-size: 10.5px; font-family: var(--font); }
.chart-empty { color: var(--ink-3); font-size: 13px; padding: 24px; text-align: center; }

/* Daily activity */
.activity-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-weight: 600; color: var(--ink-3); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.03em; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-2); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tr:last-child td { border-bottom: 0; }
.score-pill {
  display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 7px;
  border-radius: 7px; font-weight: 700; font-size: 12.5px;
}
.score-good { background: var(--up-bg); color: var(--up-fg); }
.score-mid { background: #fff4e5; color: var(--c-amber); }
.score-low { background: var(--down-bg); color: var(--down-fg); }

/* Responsive */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .trend-grid { grid-template-columns: 1fr; }
  .activity-grid { grid-template-columns: 1fr; }
  .company-body { grid-template-columns: 1fr; }
  .company-donut { margin-bottom: 8px; }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .company-row { grid-template-columns: 18px 10px 1fr auto auto; }
  .company-bar { display: none; }
}
