/* =====================================================================
   Unico Sales Dashboard — styles
   Brand: yellow #ffd200 · ink #14151a · white
   ===================================================================== */
:root {
  --yellow: #ffd200;
  --yellow-dark: #e6bd00;
  --ink: #14151a;
  --ink-2: #2a2c33;
  --muted: #6b7280;
  --line: #e6e8ec;
  --bg: #f5f6f8;
  --card: #ffffff;
  --danger: #d92d20;
  --danger-bg: #fef3f2;
  --warn: #b25e00;
  --success: #067647;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16,18,25,.08), 0 6px 20px rgba(16,18,25,.06);
  --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; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
img { max-width: 100%; }

/* ---------- Buttons ---------- */
.btn { border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; font-weight: 600;
  cursor: pointer; background: var(--ink); color: #fff; transition: .15s; line-height: 1; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--yellow); color: var(--ink); }
.btn.primary:hover { background: var(--yellow-dark); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: #cfd3da; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger.ghost { background: #fff; color: var(--danger); border-color: #f3c0bb; }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; padding: 12px; }
.btn:disabled { opacity: .6; cursor: default; transform: none; }
.icon-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg); }
.linklike { background: none; border: none; color: var(--muted); cursor: pointer; text-decoration: underline; padding: 4px; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.row-end { display: flex; justify-content: flex-end; align-items: center; }
.gap { gap: 10px; }
.center { text-align: center; }

/* ---------- Topbar / nav ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  background: var(--ink); color: #fff; padding: 10px 18px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 34px; height: 34px; }
.brand-name { font-weight: 700; font-size: 15px; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav-btn { display: flex; align-items: center; gap: 7px; background: transparent; border: none; color: #c9cbd2;
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.nav-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-btn.active { background: var(--yellow); color: var(--ink); }
.nav-icon { font-size: 15px; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 13px; color: #c9cbd2; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; background: #3a3d46; color: #cfd3da; }
.role-badge.admin { background: var(--yellow); color: var(--ink); }

.view { padding: 18px; max-width: 1400px; margin: 0 auto; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(1200px 600px at 50% -200px, #fff6cc, var(--bg)); }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  padding: 34px 30px; width: 100%; max-width: 400px; text-align: center; }
.auth-logo { width: 64px; height: 64px; margin-bottom: 10px; }
.auth-title { font-size: 22px; margin: 4px 0; }
.auth-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.auth-step { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; }
.auth-input:focus { outline: 2px solid var(--yellow); border-color: var(--yellow); }
.otp { letter-spacing: 8px; font-size: 20px; text-align: center; font-weight: 700; }
.auth-hint, .auth-sent { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
.auth-sent b { color: var(--ink); }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }

/* ---------- Panels / cards ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel-title { margin: 0 0 12px; font-size: 15px; }

/* ---------- Filter bars ---------- */
.filter-bar, .board-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.search { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-width: 120px; }
.search:focus { outline: 2px solid var(--yellow); border-color: var(--yellow); }
.inline-field { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); font-weight: 600; }

/* ---------- Kanban board ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.column { background: #eef0f3; border-radius: var(--radius); width: 270px; flex: 0 0 270px; display: flex; flex-direction: column; max-height: calc(100vh - 200px); }
.column-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 6px; }
.col-title { font-weight: 700; font-size: 13.5px; }
.col-count { background: #fff; border-radius: 20px; padding: 1px 9px; font-size: 12px; font-weight: 700; color: var(--muted); }
.col-sub { padding: 0 12px 6px; font-size: 12px; color: var(--success); font-weight: 700; }
.column-body { padding: 6px 10px 12px; overflow-y: auto; flex: 1; min-height: 40px; display: flex; flex-direction: column; gap: 9px; }
.lead-card { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(16,18,25,.05); transition: .12s; }
.lead-card:hover { border-color: var(--yellow); transform: translateY(-1px); }
.lead-card.leak { border-left: 4px solid var(--danger); }
.lc-name { font-weight: 700; font-size: 14px; }
.lc-company { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.lc-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.lc-value { font-weight: 700; color: var(--success); font-size: 13px; }
.chip { font-size: 11px; background: #f0f1f4; color: var(--ink-2); padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.chip.subtle { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.lc-reps { font-size: 11.5px; color: var(--muted); margin-top: 7px; }
.lc-flags { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.flag { font-size: 11px; color: var(--danger); background: var(--danger-bg); padding: 2px 7px; border-radius: 6px; font-weight: 600; }
.drag-ghost { opacity: .4; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(16,18,25,.5); display: grid; place-items: center;
  z-index: 50; padding: 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 480px; box-shadow: var(--shadow); max-height: 92vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer { display: flex; align-items: center; gap: 10px; padding-top: 16px; margin-top: 8px; border-top: 1px solid var(--line); }
.confirm-msg { margin: 0 0 18px; line-height: 1.5; }

/* ---------- Lead form ---------- */
.form-section { margin-bottom: 18px; }
.form-section-title { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.wide { grid-column: 1 / -1; }
.field-hint { font-size: 11px; color: var(--muted); }
.field input, .field select, .field textarea, .activity-form input {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--yellow); border-color: var(--yellow); }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.check input { width: auto; }
.earn-row { flex-direction: row; align-items: center; justify-content: space-between; background: #fffbe6;
  border: 1px solid var(--yellow); border-radius: 9px; padding: 9px 11px; }
.earn-preview { font-weight: 800; color: var(--ink); font-size: 15px; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.log-count { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
.log-table th, .metric-table th { text-align: left; padding: 9px 10px; border-bottom: 2px solid var(--line);
  cursor: pointer; white-space: nowrap; color: var(--ink-2); position: sticky; top: 0; background: #fff; }
.metric-table th { cursor: default; }
.log-table td, .metric-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.log-table tbody tr { cursor: pointer; }
.log-table tbody tr:hover { background: #fffbe6; }
.num { text-align: right; }
.leak-row { background: var(--danger-bg); }
.leak-row:hover { background: #fde3e0 !important; }

/* ---------- KPI grid ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: #fafbfc; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.kpi-val { font-size: 22px; font-weight: 800; }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi.warn { background: #fff8ef; border-color: #ffd9a8; }
.kpi.warn .kpi-val { color: var(--warn); }
.kpi.danger { background: var(--danger-bg); border-color: #f5c2bc; }
.kpi.danger .kpi-val { color: var(--danger); }

/* ---------- Goal bar ---------- */
.goal-row { margin-top: 14px; }
.goal-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.goal-bar { height: 12px; background: #eceef1; border-radius: 20px; overflow: hidden; }
.goal-fill { height: 100%; background: linear-gradient(90deg, var(--yellow), var(--yellow-dark)); border-radius: 20px; transition: width .4s; }
.goal-currency { font-size: 18px; font-weight: 700; }

/* ---------- Charts ---------- */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-box { position: relative; height: 260px; }

/* ---------- Projection ---------- */
.assume-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.assume-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.assume-input, .assume-ro { padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-weight: 700; }
.assume-ro { background: #f5f6f8; color: var(--muted); }
.scenario-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.scenario { border-radius: 14px; padding: 18px; text-align: center; border: 2px solid var(--line); background: #fafbfc; }
.scenario.expected { border-color: var(--yellow); background: #fffdf2; }
.scenario.worst { border-color: #f5c2bc; }
.scenario.best { border-color: #b7e4c7; }
.scen-title { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.scen-rev { font-size: 26px; font-weight: 800; margin: 8px 0 2px; }
.scen-label { font-size: 11px; color: var(--muted); }
.scen-cash { margin-top: 8px; font-weight: 700; }
.scen-note { margin-top: 4px; font-size: 11px; color: var(--muted); }

/* ---------- Admin ---------- */
.cell-input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; width: 100%; min-width: 80px; }
.admin-table td { vertical-align: middle; }

/* ---------- Toast ---------- */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 12px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none;
  transition: .25s; z-index: 100; box-shadow: var(--shadow); max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.success { background: var(--success); }
#toast.error { background: var(--danger); }
#toast.info { background: var(--ink); }

/* ---------- Loading / fallback ---------- */
.center-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; }
.spin-logo { width: 54px; height: 54px; animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.err { background: #fff; border: 1px solid var(--line); padding: 10px; border-radius: 8px; font-size: 12px; max-width: 90vw; overflow: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .chart-row { grid-template-columns: 1fr; }
  .scenario-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .brand-name { display: none; }
  .user-name { display: none; }
  .view { padding: 12px; }
  .nav-label { display: none; }
  .nav-btn { padding: 8px 12px; }
  .nav-icon { font-size: 18px; }
}
@media (max-width: 520px) {
  .kpi-grid, .assume-grid { grid-template-columns: 1fr 1fr; }
  .kpi-val { font-size: 18px; }
}
