/* ============================================================
   Prime55 — Demo dashboard styles
   ============================================================ */

body.dash { background: var(--gray-100); }

.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--ink-900); color: var(--gray-300);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  padding: 22px 16px;
}
.sidebar .logo { color: #fff; padding: 6px 8px 22px; }
.sidebar .logo b { color: var(--green-300); }
.side-section { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: #5d6f65; padding: 18px 12px 8px; font-weight: 700; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r-sm); font-size: 0.95rem; font-weight: 500; color: var(--gray-300); transition: background .15s, color .15s; }
.side-nav a svg { width: 19px; height: 19px; opacity: .9; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active { background: var(--green-600); color: #fff; box-shadow: var(--sh-glow); }
.side-foot { margin-top: auto; padding: 14px 12px 4px; }
.side-loc { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: var(--r-md); padding: 14px; }
.side-loc .lab { font-size: 0.72rem; color: #5d6f65; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.side-loc select { width: 100%; margin-top: 8px; background: var(--ink-800); color: #fff; border: 1px solid rgba(255,255,255,.12); border-radius: var(--r-sm); padding: 9px 10px; font: inherit; font-size: 0.92rem; }
.side-help { margin-top: 12px; display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: #8aa093; padding: 10px 12px; }
.side-help .av { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,var(--green-400),var(--green-700)); color:#fff; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: .9rem; }

/* ---------- Main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--white); border-bottom: 1px solid var(--line); padding: 16px 32px; display: flex; align-items: center; justify-content: space-between; gap: 20px; position: sticky; top: 0; z-index: 30; }
.topbar .crumbs h1 { font-size: 1.3rem; }
.topbar .crumbs p { font-size: 0.88rem; color: var(--text-soft); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.demo-badge { background: var(--amber-100); color: var(--amber-600); font-size: 0.76rem; font-weight: 700; padding: 6px 12px; border-radius: var(--r-pill); text-transform: uppercase; letter-spacing: .05em; }
.range-toggle { display: inline-flex; background: var(--gray-100); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px; }
.range-toggle button { padding: 7px 14px; border-radius: var(--r-pill); font-size: 0.86rem; font-weight: 600; color: var(--gray-500); }
.range-toggle button.active { background: var(--white); color: var(--ink-900); box-shadow: var(--sh-sm); }

.content { padding: 28px 32px 48px; }

/* ---------- KPI cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; box-shadow: var(--sh-sm); position: relative; overflow: hidden; }
.kpi .top { display: flex; align-items: center; justify-content: space-between; }
.kpi .lab { font-size: 0.88rem; color: var(--text-soft); font-weight: 600; }
.kpi .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.kpi .ic svg { width: 18px; height: 18px; }
.kpi .ic.green { background: var(--mint-100); color: var(--green-700); }
.kpi .ic.amber { background: var(--amber-100); color: var(--amber-600); }
.kpi .ic.blue { background: #e2eefc; color: var(--blue-500); }
.kpi .val { font-family: var(--font-display); font-size: 2.2rem; font-weight: 800; letter-spacing: -0.03em; margin-top: 14px; line-height: 1; }
.kpi .val small { font-size: 1.1rem; color: var(--text-soft); font-weight: 700; }
.kpi .sub { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 0.86rem; }
.kpi .delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.kpi .delta.down { color: var(--green-600); }   /* cost down = good */
.kpi .delta.up { color: var(--red-500); }
.kpi .delta svg { width: 14px; height: 14px; }
.kpi .muted { color: var(--text-soft); }
.kpi .bar { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; }
.kpi .bar.good { background: var(--green-500); }
.kpi .bar.watch { background: var(--amber-500); }
.kpi .bar.over { background: var(--red-500); }

/* prime cost hero kpi */
.kpi.hero-kpi { background: linear-gradient(135deg, var(--green-700), var(--green-600)); color: #fff; border-color: transparent; }
.kpi.hero-kpi .lab, .kpi.hero-kpi .muted { color: #cdeadd; }
.kpi.hero-kpi .ic { background: rgba(255,255,255,.15); color: #fff; }
.kpi.hero-kpi .target { font-size: 0.8rem; color: #cdeadd; margin-top: 12px; }
.kpi.hero-kpi .gauge { height: 7px; border-radius: 99px; background: rgba(255,255,255,.2); margin-top: 8px; overflow: hidden; }
.kpi.hero-kpi .gauge i { display: block; height: 100%; border-radius: 99px; background: #fff; }

/* ---------- Panels grid ---------- */
.grid { display: grid; gap: 18px; margin-top: 18px; }
.grid.cols-3-2 { grid-template-columns: 1.55fr 1fr; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-sm); padding: 20px 22px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.panel-head h3 { font-size: 1.08rem; }
.panel-head p { font-size: 0.85rem; color: var(--text-soft); margin-top: 2px; }
.legend { display: flex; gap: 14px; font-size: 0.82rem; color: var(--text-soft); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.chart-box { position: relative; height: 300px; margin-top: 8px; }
.chart-box.sm { height: 230px; }

/* ---------- Logs table ---------- */
.logs-table { width: 100%; border-collapse: collapse; }
.logs-table th { text-align: left; font-size: 0.76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-400); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.logs-table th.r, .logs-table td.r { text-align: right; }
.logs-table td { padding: 13px 12px; border-bottom: 1px solid var(--gray-100); font-size: 0.92rem; }
.logs-table tbody tr:hover { background: var(--mint-50); }
.logs-table .date { font-weight: 600; color: var(--ink-900); }
.logs-table .src { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 0.82rem; }
.logs-table .src svg { width: 14px; height: 14px; color: var(--green-500); }
.logs-table .tnum { font-variant-numeric: tabular-nums; }
.logs-table .pc { font-weight: 800; font-family: var(--font-display); }
.pc.good { color: var(--green-600); } .pc.watch { color: var(--amber-600); } .pc.over { color: var(--red-500); }

/* ---------- Alerts ---------- */
.alert-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--gray-100); }
.alert-item:last-child { border-bottom: none; }
.alert-item .dot { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.alert-item .dot.over { background: var(--red-100); color: var(--red-600); }
.alert-item .dot.watch { background: var(--amber-100); color: var(--amber-600); }
.alert-item .dot.good { background: var(--mint-100); color: var(--green-700); }
.alert-item .dot svg { width: 18px; height: 18px; }
.alert-item .txt b { font-size: 0.94rem; }
.alert-item .txt p { font-size: 0.86rem; color: var(--text-soft); margin-top: 2px; }
.alert-item .txt time { font-size: 0.78rem; color: var(--gray-400); }

/* ---------- Log via text button + modal ---------- */
.btn-sms { background: var(--green-600); color: #fff; box-shadow: var(--sh-glow); }
.btn-sms:hover { background: var(--green-700); transform: translateY(-1px); }
.modal-scrim { position: fixed; inset: 0; background: rgba(8,20,14,.55); backdrop-filter: blur(3px); display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal-scrim.open { display: flex; }
.modal { background: var(--white); border-radius: var(--r-xl); width: 420px; max-width: 100%; box-shadow: var(--sh-lg); overflow: hidden; }
.modal-head { background: var(--ink-900); color: #fff; padding: 18px 22px; display: flex; align-items: center; gap: 12px; }
.modal-head .av { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg,var(--green-500),var(--green-700)); display: grid; place-items: center; }
.modal-head .av svg { width: 20px; height: 20px; color: #fff; }
.modal-head .nm { font-family: var(--font-display); font-weight: 700; }
.modal-head .st { font-size: 0.78rem; color: var(--green-300); }
.modal-head .x { margin-left: auto; color: #8aa093; font-size: 1.4rem; line-height: 1; }
.modal-body { padding: 22px; }
.modal-body .hint { font-size: 0.88rem; color: var(--text-soft); margin-bottom: 14px; }
.fld { margin-bottom: 14px; }
.fld label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.fld input { width: 100%; padding: 12px 14px; border: 1px solid var(--gray-300); border-radius: var(--r-sm); font: inherit; font-size: 1rem; }
.fld input:focus { outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(43,197,135,.2); }
.modal-preview { background: #243029; color: #e9f2ec; border-radius: 16px 16px 16px 5px; padding: 12px 14px; font-size: 0.9rem; margin-bottom: 16px; display: none; }
.modal-preview.show { display: block; }
.modal-preview b.ok { color: var(--green-300); } .modal-preview b.warn { color: var(--amber-400); } .modal-preview b.bad { color: #ff9ea1; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid.cols-3-2, .grid.cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; }
  .sidebar .logo { padding: 6px 8px; }
  .side-section, .side-foot, .side-help { display: none; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-nav a { padding: 8px 12px; }
  .side-nav a span.lbl { display: none; }
  .topbar { padding: 14px 18px; flex-wrap: wrap; }
  .content { padding: 18px; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr; }
  .range-toggle { display: none; }
}

/* ---------- Views / nav switching ---------- */
.view[hidden] { display: none; }
.kpis.kpis-3 { grid-template-columns: repeat(3, 1fr); }

/* search box in panel head */
.dash-search {
  width: 260px; max-width: 50vw; padding: 9px 14px; border: 1px solid var(--gray-300);
  border-radius: var(--r-pill); font: inherit; font-size: 0.9rem; background: var(--gray-100); color: var(--ink-900);
}
.dash-search:focus { outline: none; border-color: var(--green-500); background: #fff; box-shadow: 0 0 0 3px rgba(43,197,135,.16); }
.table-foot { margin-top: 14px; font-size: 0.85rem; color: var(--text-soft); }

/* ---------- Locations view ---------- */
.loc-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.loc-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--sh-sm); border-top: 4px solid var(--gray-300); }
.loc-card.good { border-top-color: var(--green-500); }
.loc-card.watch { border-top-color: var(--amber-500); }
.loc-card.over { border-top-color: var(--red-500); }
.loc-card .lc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.loc-card .lc-name { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.loc-card .lc-prime { font-family: var(--font-display); font-weight: 800; font-size: 2.4rem; letter-spacing: -0.03em; margin: 14px 0 2px; line-height: 1; }
.loc-card .lc-prime.good { color: var(--green-600); } .loc-card .lc-prime.watch { color: var(--amber-600); } .loc-card .lc-prime.over { color: var(--red-500); }
.loc-card .lc-target { font-size: 0.82rem; color: var(--text-soft); }
.loc-card .lc-rows { margin-top: 16px; border-top: 1px solid var(--gray-100); padding-top: 14px; display: flex; flex-direction: column; gap: 9px; }
.loc-card .lc-rows div { display: flex; justify-content: space-between; font-size: 0.9rem; }
.loc-card .lc-rows span { color: var(--text-soft); }
.loc-card .lc-rows b { font-variant-numeric: tabular-nums; color: var(--ink-900); }

/* ---------- Settings view ---------- */
.set-panel h3 { font-size: 1.1rem; margin-bottom: 4px; }
.set-hint { font-size: 0.88rem; color: var(--text-soft); margin-bottom: 18px; }
.set-field { display: block; margin-bottom: 16px; }
.set-field span { display: block; font-size: 0.82rem; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.set-field input { width: 140px; padding: 11px 14px; border: 1px solid var(--gray-300); border-radius: var(--r-sm); font: inherit; font-size: 1.1rem; font-weight: 700; }
.set-field input:focus { outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(43,197,135,.16); }
.set-saved { display: inline-block; margin-left: 12px; color: var(--green-600); font-weight: 600; font-size: 0.9rem; }
.set-saved[hidden] { display: none; }
.set-toggle { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--gray-100); font-size: 0.95rem; color: var(--gray-700); cursor: pointer; }
.set-toggle:last-child { border-bottom: none; }
.set-toggle input { width: 18px; height: 18px; accent-color: var(--green-600); }
.set-phone { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 700; color: var(--green-700); background: var(--mint-50); border: 1px solid var(--mint-100); border-radius: var(--r-sm); padding: 14px 16px; text-align: center; }
.set-sub { font-size: 0.82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-400); margin: 20px 0 12px; }
.set-senders { display: flex; flex-direction: column; gap: 10px; }
.set-senders li { display: flex; align-items: center; gap: 12px; font-size: 0.92rem; }
.set-senders .av { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,var(--green-400),var(--green-700)); color: #fff; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 0.82rem; flex: none; }
.set-senders b { display: block; color: var(--ink-900); font-size: 0.94rem; }
.set-senders em { font-style: normal; color: var(--text-soft); font-size: 0.82rem; }
.set-senders .add { color: var(--green-600); cursor: pointer; font-weight: 600; }
.set-senders .add .av { background: var(--mint-100); color: var(--green-700); font-size: 1.2rem; }
.set-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--gray-100); font-size: 0.94rem; }
.set-row:last-child { border-bottom: none; }
.set-row span { color: var(--text-soft); }
.set-link { color: var(--green-600); font-weight: 600; }
.set-link:hover { text-decoration: underline; }

@media (max-width: 1080px) {
  .kpis.kpis-3 { grid-template-columns: 1fr; }
  .loc-cards { grid-template-columns: 1fr; }
}
