/* =====================================================================
   style.css : poore DCF Sale CRM ka rang-roop (Apps Script ki Style.html jaisa)
   Rang badalne ho to sirf neeche :root wale rang badlo.
   ===================================================================== */
:root {
  --page: #f3f5fa;  --card: #ffffff;  --line: #e3e8f2;  --zebra: #f8faff;
  --ink: #17213a;   --ink-2: #4c5873; --muted: #8a93a8;
  --navy: #1e2f5c;  --navy-2: #2a3f78;
  --accent: #c2410c; --accent-2: #ea580c;
  --brown: #7a3410; --gold: #fcd34d; --gold-bg: #fff7e0;
  --up: #138a52;    --up-bg: #dcf5e7;
  --down: #c62f2f;  --down-bg: #fde7e7;
  --series-1: #2a78d6; --series-2: #eb6834;
}

/* ===================== DHANCHA ===================== */
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink);
       font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; }
main { margin-left: 232px; padding: 20px 26px 50px; }

/* ===================== SIDEBAR ===================== */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 232px; overflow-y: auto; padding: 16px 12px;
           background: linear-gradient(180deg, #16234a 0%, #1e2f5c 55%, #3a2a5e 100%); color: #dfe5f5;
           display: flex; flex-direction: column; gap: 3px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px;
         margin: 2px 6px 14px; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: #aeb9d6; }
.logo { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 800;
        background: linear-gradient(135deg, var(--accent-2), #f59e0b); color: #fff; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8f9cc0; margin: 12px 8px 4px; }
.nav { display: flex; align-items: center; gap: 9px; color: #dfe5f5; text-decoration: none; padding: 9px 11px;
       border-radius: 8px; }
.nav:hover { background: rgba(255, 255, 255, .08); }
.nav.active { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 600; }
.ico { width: 20px; text-align: center; }
.side-foot { margin-top: auto; font-size: 11px; color: #aeb9d6; padding: 10px 8px 0; }

/* ===================== UPAR KI PATTI + FILTER ===================== */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.page-head h1 { margin: 0; font-size: 24px; }
.period { color: var(--ink-2); font-size: 13px; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; background: var(--card);
           border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-2); }
select, input[type=date], input[type=file], .search { font: inherit; padding: 7px 9px; border: 1px solid #cdd5e4;
       border-radius: 8px; background: #fff; color: var(--ink); }
select { min-width: 130px; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 2px 12px; }

/* ===================== BUTTON ===================== */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; padding: 8px 14px;
       border-radius: 8px; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.big { padding: 11px 22px; font-size: 15px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: #fff; border-color: #cdd5e4; color: var(--ink); }
.btn.excel { background: #157347; color: #fff; }
.btn.excel:hover { background: #0f5c38; }
.btn.pdf { background: #b42318; color: #fff; }
.btn.white { background: #fff; color: var(--ink); }
.btn.close-x { background: rgba(255, 255, 255, .15); color: #fff; font-size: 18px; padding: 4px 12px; }

/* ===================== KPI CARD ===================== */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px;
       border-top: 4px solid var(--navy-2); }
.kpi:nth-child(2) { border-top-color: #2a78d6; } .kpi:nth-child(3) { border-top-color: #1baf7a; }
.kpi:nth-child(4) { border-top-color: #eda100; } .kpi:nth-child(5) { border-top-color: #8b5cf6; }
.kpi:nth-child(6) { border-top-color: var(--down); }
.kpi.clickable { cursor: pointer; } .kpi.clickable:hover { box-shadow: 0 4px 14px rgba(30, 47, 92, .12); }
.kpi-label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.kpi-value { font-size: 25px; font-weight: 700; margin: 3px 0; font-variant-numeric: tabular-nums; }
.kpi-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.kpi-hint { font-size: 11px; color: var(--accent); margin-top: 4px; }
.chip { font-weight: 700; border-radius: 999px; padding: 1px 8px; background: #eef1f7; color: var(--ink-2); }
.chip.up { background: var(--up-bg); color: var(--up); }
.chip.down { background: var(--down-bg); color: var(--down); }

/* ===================== GRAPH ===================== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.chart-card { margin: 0; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card figcaption { font-weight: 700; margin-bottom: 8px; }
.chart-box { position: relative; }

/* ===================== TABLE ===================== */
.table-card { margin-bottom: 18px; padding: 12px 0 0; overflow: hidden; }
.table-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 0 16px 10px; }
.table-head h2 { font-size: 16px; margin: 0; }
.table-tools { display: flex; gap: 8px; align-items: center; }
.count { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.table-wrap { overflow: auto; max-height: 640px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; font-size: 13px; }
th { position: sticky; top: 0; z-index: 2; background: var(--navy); color: #fff; font-size: 11.5px;
     text-transform: uppercase; letter-spacing: .02em; padding: 9px 10px; text-align: left; white-space: nowrap; }
td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:nth-child(even) td { background: var(--zebra); }
tbody tr:hover td { background: #eef3ff; }
.num { text-align: right; }
.sn { width: 38px; text-align: center; color: var(--muted); }
.total-top td { position: sticky; top: 34px; z-index: 1; background: #101a36 !important; color: #fff; font-weight: 700; }
.up { color: var(--up); font-weight: 600; }
.down { color: var(--down); font-weight: 600; }
.total-top .up { color: #7ee2ad; } .total-top .down { color: #ff9b9b; }
a.drill { color: var(--accent); font-weight: 700; text-decoration: underline dotted; cursor: pointer; }
.total-top a.drill { color: var(--gold); }
.kv th { position: static; text-transform: none; width: 260px; }

/* ===================== IMPORT PAGE ===================== */
.upload { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.steps { margin: 0; padding-left: 20px; color: var(--ink-2); }
.check { display: flex; gap: 8px; align-items: center; }
.working { background: var(--gold-bg); border: 1px solid #f5d27a; padding: 10px 14px; border-radius: 8px; font-weight: 600; }
.alert { padding: 12px 16px; border-radius: 10px; font-weight: 700; margin-bottom: 14px; }
.alert.ok { background: var(--up-bg); color: var(--up); }
.alert.err { background: var(--down-bg); color: var(--down); }

/* ===================== POPUP ===================== */
.modal-back { position: fixed; inset: 0; background: rgba(15, 20, 40, .55); z-index: 50; display: grid;
              place-items: center; padding: 24px; }
.modal-back[hidden] { display: none; }
.modal { background: #fff; border-radius: 14px; width: min(1250px, 100%); max-height: 92vh; display: flex;
         flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.modal-head { background: linear-gradient(90deg, #6b2d0c, var(--brown)); color: #fff; padding: 14px 18px;
              display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-title { font-size: 18px; font-weight: 800; }
.modal-sub { color: var(--gold); font-size: 12px; font-weight: 600; }
.modal-actions { display: flex; gap: 8px; }
.modal-bar { background: var(--gold-bg); padding: 10px 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search.wide { width: min(420px, 100%); }
.pill { border: 1px solid #f2c14e; background: #fff8e1; color: #7a4b00; border-radius: 999px; padding: 4px 12px;
        font-weight: 700; font-size: 13px; }
.modal-body { overflow: auto; padding: 0 18px; flex: 1; }
.modal-body th { background: var(--navy); }
.modal-foot { padding: 10px 18px; display: flex; justify-content: flex-end; border-top: 1px solid var(--line); }

/* ===================== PRINT (popup ka PDF) ===================== */
@media print {
  body.printing > *:not(main), body.printing main > *:not(#modal) { display: none !important; }
  body.printing main { margin: 0; padding: 0; }
  body.printing .modal-back { position: static; background: none; padding: 0; display: block; }
  body.printing .modal { box-shadow: none; max-height: none; width: 100%; }
  body.printing .modal-actions, body.printing .modal-foot, body.printing #mSearch { display: none; }
  body.printing .modal-body { overflow: visible; }
  body.printing th { position: static; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 1000px) {
  .sidebar { position: static; width: auto; }
  main { margin-left: 0; padding: 14px; }
  .charts { grid-template-columns: 1fr; }
}

/* Popup ke andar upar wali Σ TOTAL line */
.popup-total td { background: #101a36 !important; color: #fff; }

/* KPI card ke neeche: Pichhla aur Kul badlaav */
.kpi-trend { display: flex; gap: 12px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line);
             font-size: 12px; color: var(--muted); }
.kpi-trend span { white-space: nowrap; }
.kpi-trend b { font-weight: 700; }

/* ===================== LOGIN PAGE ===================== */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px;
              background: linear-gradient(135deg, #16234a 0%, #1e2f5c 55%, #3a2a5e 100%); }
.login-box { width: min(380px, 100%); background: #fff; border-radius: 16px; padding: 26px 26px 18px;
             display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.login-box h1 { margin: 4px 0 0; font-size: 22px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.login-brand small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.login-box label, .form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px;
                                      color: var(--ink-2); font-weight: 600; }
.login-box input, .form-grid input, .inline input { font: inherit; padding: 9px 10px; border: 1px solid #cdd5e4;
                                                    border-radius: 8px; color: var(--ink); }
.login-box .btn { justify-content: center; margin-top: 4px; }
.login-box .alert { margin: 0; font-size: 13px; }
.login-note { margin: 0; color: var(--ink-2); font-size: 13px; }
.login-note.small { font-size: 11.5px; color: var(--muted); text-align: center; }

/* ===================== USERS / PASSWORD PAGE ===================== */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px;
             align-items: end; margin-bottom: 16px; }
.form-grid h2 { grid-column: 1 / -1; margin: 0; font-size: 16px; }
.inline { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline input { padding: 5px 8px; width: 150px; }
.side-user { margin: 10px 6px 0; padding: 10px; border-radius: 8px; background: rgba(255, 255, 255, .08);
             color: #fff; font-weight: 600; font-size: 13px; }
.side-user small { display: block; font-weight: 400; color: #aeb9d6; font-size: 11px; }
