/* ═══════════════════════════════════════════════
   HISHAB — styles.css  v3
   Hard-reset everything so no browser/cache
   default can override layout.
═══════════════════════════════════════════════ */

/* ── Tokens ── */
:root{
  --navy:#0f172a; --blue:#0f64c8; --teal:#0d8292;
  --orange:#ff7900; --green:#087443; --red:#c93832;
  --ink:#1e293b; --muted:#64748b; --line:#e2e8f0;
  --soft:#f8fafc; --white:#fff;
  --shadow:0 1px 3px rgba(0,0,0,.07),0 4px 16px rgba(0,0,0,.06);
  --sidebar-w:220px;
}

/* ── Hard reset ── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}
html,body{height:100%;}
body{background:#f1f5f9;color:var(--ink);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  font-size:14px;line-height:1.5;}
button{font:inherit;cursor:pointer;}
a{text-decoration:none;color:inherit;}
svg{display:block;flex-shrink:0;}
input,select,textarea{font:inherit;}
h1,h2,h3{margin:0;line-height:1.2;}

/* ── App shell ── */
.app-shell{display:flex;min-height:100vh;}

/* ══════════════════════════════════════════════
   SIDEBAR  — desktop fixed left panel
══════════════════════════════════════════════ */
.sidebar{
  width:var(--sidebar-w);flex-shrink:0;
  background:var(--navy);
  position:fixed;top:0;left:0;bottom:0;
  display:flex;flex-direction:column;
  overflow-y:auto;overflow-x:hidden;
  z-index:40;
  transition:transform .25s ease;
}
.sidebar-top{padding:22px 14px 16px;flex:1;}

/* Brand */
.brand{display:flex;align-items:center;gap:10px;margin-bottom:28px;}
.brand-mark{
  width:34px;height:34px;border-radius:9px;
  background:var(--orange);color:#fff;
  font-size:17px;font-weight:800;
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;
}
.brand-text{display:flex;flex-direction:column;min-width:0;}
.brand-name{font-size:16px;font-weight:800;color:#fff;white-space:nowrap;}
.brand-sub{font-size:10px;color:#94a3b8;white-space:nowrap;}

/* Nav items — CRITICAL: row layout, fixed icon size */
.sidebar-nav{display:flex;flex-direction:column;gap:3px;}

.nav-item,a.nav-item{
  /* layout */
  display:flex !important;
  flex-direction:row !important;
  align-items:center !important;
  gap:10px !important;
  /* sizing */
  width:100%;
  padding:10px 12px;
  border-radius:9px;
  /* text */
  font-size:13px;font-weight:500;
  color:#94a3b8;
  /* reset */
  border:0;background:transparent;
  text-align:left;
  transition:background .15s,color .15s;
  white-space:nowrap;
}
.nav-item:hover,a.nav-item:hover{background:rgba(255,255,255,.08);color:#e2e8f0;}
.nav-item.active,a.nav-item.active{background:rgba(15,100,200,.3);color:#fff;font-weight:600;}

/* Force icon size — prevents SVG from stretching */
.nav-icon{width:16px !important;height:16px !important;flex-shrink:0 !important;}
.nav-item span{flex:1;overflow:hidden;text-overflow:ellipsis;}

/* Sidebar bottom */
.sidebar-bottom{
  padding:14px;
  border-top:1px solid rgba(255,255,255,.07);
}
.sidebar-status{
  display:flex;align-items:center;gap:7px;
  font-size:11px;color:#94a3b8;margin-bottom:5px;
}
.status-dot{width:7px;height:7px;border-radius:50%;background:#22c55e;flex-shrink:0;}
.muted-text{color:#475569 !important;}

/* ══════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════ */
.main-content{
  flex:1;
  margin-left:var(--sidebar-w);
  min-width:0;
  padding:26px 30px 40px;
}

/* ── Topbar ── */
.topbar{
  display:flex;justify-content:space-between;align-items:center;
  gap:12px;margin-bottom:24px;flex-wrap:wrap;
}
.topbar-left{display:flex;align-items:center;gap:12px;}
.topbar-right{display:flex;align-items:center;gap:10px;}
.eyebrow{color:#0284c7;font-size:10px;letter-spacing:.13em;font-weight:800;
  margin-bottom:3px;text-transform:uppercase;display:block;}
h1{font-size:24px;font-weight:800;color:var(--ink);}

.hamburger{
  display:none;
  border:0;background:transparent;
  padding:6px;border-radius:8px;color:var(--ink);
}

/* User chip */
.user-chip{
  display:flex;align-items:center;gap:8px;
  background:#fff;border:1px solid var(--line);
  border-radius:10px;padding:6px 12px;
  box-shadow:var(--shadow);cursor:default;
}
.user-avatar{
  width:28px;height:28px;border-radius:50%;
  background:var(--blue);color:#fff;
  font-weight:700;font-size:12px;
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;
}
.user-info{display:flex;flex-direction:column;}
.user-name{font-size:13px;font-weight:600;line-height:1.2;color:var(--ink);}
.user-role{font-size:11px;color:var(--muted);}

/* ── Buttons ── */
.primary-btn{
  border:0;background:var(--orange);color:#fff;
  font-weight:700;border-radius:10px;padding:11px 18px;
  cursor:pointer;font-size:14px;
  box-shadow:0 4px 14px rgba(255,121,0,.28);
  white-space:nowrap;transition:filter .15s;
  display:inline-flex;align-items:center;gap:6px;
}
.primary-btn:hover{filter:brightness(.93);}
.full-width{width:100%;margin-top:6px;justify-content:center;}

.icon-btn{
  border:0;background:#f1f5f9;border-radius:8px;
  width:30px;height:30px;
  display:flex;align-items:center;justify-content:center;
  font-size:15px;transition:background .15s;
}
.icon-btn:hover{background:var(--line);}
.icon-btn.danger:hover{background:#fee2e2;}
.icon-btn.close-x{border-radius:50%;font-size:20px;background:#f1f5f9;}

/* ── View toggle ── */
.view{display:none;}
.active-view{display:block;}

/* ══════════════════════════════════════════════
   HERO CARD
══════════════════════════════════════════════ */
.hero-card{
  background:linear-gradient(125deg,#1e3a5f 0%,#0f64c8 55%,#0d8292 100%);
  color:#fff;border-radius:18px;
  padding:26px 28px;
  box-shadow:0 8px 32px rgba(15,100,200,.28);
  margin-bottom:16px;
  display:flex;justify-content:space-between;align-items:center;gap:20px;
  overflow:hidden;
}
.hero-card-left{flex:1;min-width:0;}
.hero-card .label{opacity:.8;font-size:13px;font-weight:500;display:block;margin-bottom:6px;}
.hero-value{font-size:36px;font-weight:800;margin-bottom:6px;letter-spacing:-.5px;}
.hero-meta{font-size:13px;opacity:.85;}
.hero-card-right{width:150px;flex-shrink:0;opacity:.8;}
.sparkline{width:100%;height:65px;display:block;}

.chg-badge{
  display:inline-block;font-size:11px;font-weight:600;
  margin-top:4px;padding:2px 8px;border-radius:20px;
}
.chg-badge.green{background:rgba(34,197,94,.2);color:#bbf7d0;}
.chg-badge.red{background:rgba(239,68,68,.2);color:#fecaca;}

/* ══════════════════════════════════════════════
   METRIC GRID
══════════════════════════════════════════════ */
.metric-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-bottom:20px;}
.metric-card{
  background:#fff;border:1px solid var(--line);border-radius:14px;
  padding:16px;box-shadow:var(--shadow);
  display:flex;gap:12px;align-items:flex-start;
}
.metric-icon{
  width:36px;height:36px;border-radius:10px;
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;
}
.metric-icon.green{background:#dcfce7;color:var(--green);}
.metric-icon.red{background:#fee2e2;color:var(--red);}
.metric-icon.blue{background:#dbeafe;color:var(--blue);}
.metric-icon.teal{background:#ccfbf1;color:var(--teal);}
.metric-icon.orange{background:#ffedd5;color:var(--orange);}
.metric-label{font-size:11px;color:var(--muted);font-weight:500;margin-bottom:2px;}
.metric-value{font-weight:800;font-size:20px;}

/* ══════════════════════════════════════════════
   SECTION TITLE & BUSINESS CARDS
══════════════════════════════════════════════ */
.section-title{
  display:flex;justify-content:space-between;align-items:center;
  margin:20px 0 10px;
}
.section-title h2{font-size:16px;font-weight:700;}
.view-all-link{font-size:13px;color:var(--blue);cursor:pointer;font-weight:500;}
.view-all-link:hover{text-decoration:underline;}

.business-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;}
.business-card{
  background:#fff;border:1px solid var(--line);
  border-radius:14px;overflow:hidden;box-shadow:var(--shadow);
}
.business-head{
  display:flex;justify-content:space-between;align-items:center;
  color:#fff;padding:14px 16px;font-size:16px;font-weight:700;
}
.business-head.isp{background:linear-gradient(120deg,#1d4ed8,#0f64c8);}
.business-head.cable{background:linear-gradient(120deg,#0e7490,#0d8292);}
.business-chart{height:48px;overflow:hidden;background:#f8fafc;}
.mini-spark{width:100%;height:48px;display:block;}
.business-body{padding:12px 16px;}
.business-line{
  display:flex;justify-content:space-between;align-items:center;
  border-bottom:1px solid var(--line);padding:8px 0;font-size:13px;
}
.business-line:last-child{border-bottom:0;}

/* ══════════════════════════════════════════════
   QUICK STATS
══════════════════════════════════════════════ */
.quick-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;}
.quick-card{
  background:#fff;border:1px solid var(--line);
  border-radius:14px;padding:16px;box-shadow:var(--shadow);
}
.quick-icon{
  width:36px;height:36px;border-radius:10px;
  display:flex;align-items:center;justify-content:center;
  margin-bottom:10px;
}
.quick-label{font-size:11px;color:var(--muted);font-weight:500;margin-bottom:3px;}
.quick-value{font-size:20px;font-weight:800;margin-bottom:2px;}
.quick-sub{font-size:11px;color:var(--muted);}

/* ══════════════════════════════════════════════
   AMOUNTS / STATUS BADGES
══════════════════════════════════════════════ */
.amount{font-weight:700;}
.income{color:var(--green);}
.expense{color:var(--red);}
.net{color:var(--blue);}
.status{padding:3px 9px;border-radius:20px;font-size:11px;font-weight:700;}
.status.income{background:#dcfce7;color:var(--green);}
.status.expense{background:#fee2e2;color:var(--red);}

/* ══════════════════════════════════════════════
   PANELS & TABLES
══════════════════════════════════════════════ */
.panel{
  background:#fff;border:1px solid var(--line);
  border-radius:14px;padding:18px;
  box-shadow:var(--shadow);margin-bottom:14px;
}
.panel-header{
  display:flex;justify-content:space-between;align-items:center;
  gap:12px;margin-bottom:14px;flex-wrap:wrap;
}
.panel-header h2{font-size:16px;font-weight:700;}
.filter-row{display:flex;gap:8px;flex-wrap:wrap;}
.filter-row select,
.modal input,
.modal select,
.modal textarea{
  border:1px solid var(--line);border-radius:8px;
  padding:9px 11px;font:inherit;font-size:13px;
  background:#fff;color:var(--ink);
}
.filter-row select:focus,
.modal input:focus,
.modal select:focus,
.modal textarea:focus{
  outline:0;border-color:var(--blue);
  box-shadow:0 0 0 3px rgba(15,100,200,.1);
}
.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;}
.data-table{width:100%;border-collapse:collapse;font-size:13px;min-width:480px;}
.data-table th{
  text-align:left;color:var(--muted);font-size:11px;
  text-transform:uppercase;letter-spacing:.05em;
  background:#f8fafc;padding:10px 12px;
  white-space:nowrap;font-weight:600;
}
.data-table td{padding:11px 12px;border-bottom:1px solid var(--line);}
.data-table tr:last-child td{border-bottom:0;}
.empty{padding:32px;text-align:center;color:var(--muted);}

/* ══════════════════════════════════════════════
   REPORTS
══════════════════════════════════════════════ */
.report-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-bottom:14px;}
.bar-chart{height:200px;display:flex;align-items:flex-end;gap:10px;padding:10px 4px 0;}
.bar-col{flex:1;display:flex;flex-direction:column;align-items:center;gap:6px;height:100%;justify-content:flex-end;}
.bars{height:165px;display:flex;align-items:flex-end;gap:4px;}
.bar{width:18px;border-radius:5px 5px 0 0;}
.bar.income-bar{background:var(--green);}
.bar.expense-bar{background:var(--red);opacity:.7;}
.bar-label{font-size:10px;color:var(--muted);}
.legend{font-size:11px;color:var(--muted);}
.legend i{display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:3px;}
.legend .income-dot{background:var(--green);}
.legend .expense-dot{background:var(--red);}
.summary-row{display:flex;justify-content:space-between;padding:10px 0;border-bottom:1px solid var(--line);font-size:14px;}
.summary-row:last-child{border-bottom:0;font-weight:800;font-size:16px;}

/* ══════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════ */
.modal-backdrop{
  position:fixed;inset:0;background:rgba(15,23,42,.55);
  display:flex;align-items:center;justify-content:center;
  padding:16px;z-index:100;
}
.modal-backdrop[hidden]{display:none;}
.modal{
  background:#fff;border-radius:18px;width:min(460px,100%);
  padding:24px;box-shadow:0 24px 70px rgba(0,0,0,.22);
  display:flex;flex-direction:column;gap:14px;
  max-height:90vh;overflow-y:auto;
}
.modal-header{display:flex;justify-content:space-between;align-items:flex-start;}
.modal h2{font-size:19px;}
.modal label{font-size:13px;font-weight:600;display:flex;flex-direction:column;gap:5px;}
.muted{color:var(--muted);font-weight:400;}
.segmented{
  display:grid;grid-template-columns:1fr 1fr;gap:4px;
  background:#f1f5f9;padding:4px;border-radius:10px;
}
.segmented label{display:block;}
.segmented input{display:none;}
.segmented span{display:block;text-align:center;padding:9px;border-radius:7px;color:var(--muted);cursor:pointer;font-size:13px;}
.segmented input:checked+span{background:var(--blue);color:#fff;font-weight:700;}
.type-toggle input:checked+span.income-text{background:#dcfce7;color:var(--green);}
.type-toggle input:checked+span.expense-text{background:#fee2e2;color:var(--red);}

/* ══════════════════════════════════════════════
   SIDEBAR OVERLAY & BOTTOM TABS
══════════════════════════════════════════════ */
.sidebar-overlay{
  display:none;position:fixed;inset:0;
  background:rgba(0,0,0,.4);z-index:30;
}
/* Bottom tabs hidden on desktop */
.bottom-tabs{display:none;}

/* ══════════════════════════════════════════════
   MOBILE  ≤ 768px
══════════════════════════════════════════════ */
@media(max-width:768px){
  /* Sidebar becomes a slide-in drawer */
  .sidebar{transform:translateX(-100%);}
  .sidebar.open{transform:translateX(0);}
  .sidebar-overlay.visible{display:block;}

  .main-content{margin-left:0;padding:18px 14px 80px;}
  .hamburger{display:flex;}

  /* Show bottom tab bar */
  .bottom-tabs{
    display:flex;
    position:fixed;bottom:0;left:0;right:0;
    background:var(--navy);
    border-top:1px solid rgba(255,255,255,.08);
    padding:6px 4px max(6px,env(safe-area-inset-bottom));
    z-index:50;
  }
  .bottom-tabs .nav-item{
    flex:1;
    flex-direction:column !important;
    gap:3px !important;
    padding:7px 4px !important;
    font-size:10px !important;
    align-items:center !important;
    justify-content:center;
    border-radius:8px;
  }
  .bottom-tabs .nav-icon{width:20px !important;height:20px !important;}

  .hero-card-right{display:none;}
  .hero-value{font-size:28px;}
  .metric-grid{grid-template-columns:1fr 1fr;}
  .business-grid{grid-template-columns:1fr;}
  .report-grid{grid-template-columns:1fr;}
  .quick-grid{grid-template-columns:repeat(2,1fr);}
  .filter-row{flex-direction:column;}
  .filter-row select{width:100%;}
  .topbar{gap:8px;}
  .user-chip .user-info{display:none;}
  h1{font-size:20px;}
}

@media(max-width:400px){
  .metric-grid{grid-template-columns:1fr;}
  .quick-grid{grid-template-columns:1fr;}
  .hero-value{font-size:22px;}
}
