* { margin:0; padding:0; box-sizing:border-box; font-family:'Segoe UI', Arial, sans-serif; }
body { background:#f1f3f7; color:#1f2937; }
a { text-decoration:none; color:inherit; }
.layout { display:flex; min-height:100vh; }

/* SIDEBAR */
.sidebar { width:230px; background:#0b1f3a; color:#cfd8e6; display:flex; flex-direction:column; flex-shrink:0; }
.brand { display:flex; align-items:center; gap:10px; padding:20px 18px; border-bottom:1px solid #1a2f52; }
.brand .drop { width:34px; height:34px; background:#2196f3; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:18px; }
.brand-text b { display:block; font-size:14px; color:#fff; letter-spacing:0.3px; }
.brand-text span { font-size:10px; color:#8fa3c4; letter-spacing:1px; }
.nav { flex:1; padding:10px 0; overflow-y:auto; }
.nav-item { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:11px 20px; color:#b9c4d9; font-size:13.5px; cursor:pointer; }
.nav-item:hover { background:#132a4d; color:#fff; }
.nav-item.active, .nav-item.open { background:#132a4d; color:#fff; font-weight:600; }
.nav-item .left { display:flex; align-items:center; gap:12px; }
.nav .icon { width:18px; text-align:center; }
.nav-item .chev { font-size:10px; transition:transform .15s; }
.nav-item.open .chev { transform:rotate(90deg); }
.submenu { max-height:0; overflow:hidden; background:#081729; transition:max-height .2s ease; }
.submenu.open { max-height:400px; }
.submenu a { display:block; padding:9px 20px 9px 50px; font-size:12.5px; color:#93a3c0; }
.submenu a:hover { color:#fff; }
.submenu a.active { color:#4da3ff; font-weight:700; }
.support { margin:14px; background:#0e2648; border-radius:8px; padding:14px; font-size:12px; color:#a9b7cf; }
.support b { color:#fff; font-size:13px; display:flex; gap:8px; align-items:center; margin-bottom:6px; }

/* MAIN */
.main { flex:1; display:flex; flex-direction:column; min-width:0; }
.topbar { background:#fff; display:flex; align-items:center; justify-content:space-between; padding:14px 26px; border-bottom:1px solid #e5e9f0; flex-wrap:wrap; gap:10px; }
.topbar-left { display:flex; align-items:center; gap:16px; }
.hamburger { font-size:20px; color:#334155; cursor:pointer; }
.topbar-left h1 { font-size:20px; font-weight:700; color:#111827; }
.topbar-right { display:flex; align-items:center; gap:14px; flex-wrap:wrap; }
.pill { display:flex; align-items:center; gap:8px; padding:8px 14px; border:1px solid #dbe2ea; border-radius:8px; font-size:13px; color:#374151; background:#fff; }
.whatsapp-btn { display:flex; align-items:center; gap:6px; padding:8px 14px; border:1px solid #25d366; border-radius:8px; color:#128c3e; font-size:13px; font-weight:600; background:#eafaf0; }
.bell { position:relative; font-size:18px; color:#374151; }
.bell .dot { position:absolute; top:-6px; right:-8px; background:#ef4444; color:#fff; font-size:10px; width:16px; height:16px; border-radius:50%; display:flex; align-items:center; justify-content:center; }
.profile { display:flex; align-items:center; gap:8px; }
.avatar { width:34px; height:34px; border-radius:50%; background:#cbd5e1; display:flex; align-items:center; justify-content:center; font-size:16px; }
.profile .name { font-size:13px; font-weight:600; color:#111827; }
.profile .role { font-size:11px; color:#6b7280; }

.content { padding:22px 26px; }

/* KPI CARDS */
.kpi-row { display:grid; grid-template-columns:repeat(6,1fr); gap:16px; margin-bottom:20px; }
@media (max-width:1300px){ .kpi-row{ grid-template-columns:repeat(3,1fr);} }
@media (max-width:760px){ .kpi-row{ grid-template-columns:repeat(2,1fr);} }
.kpi { border-radius:12px; padding:16px 18px; color:#fff; position:relative; overflow:hidden; min-height:110px; }
.kpi .label { font-size:13px; opacity:.92; font-weight:600; margin-bottom:10px; }
.kpi .value { font-size:24px; font-weight:800; display:flex; align-items:center; gap:8px; }
.kpi .sub { font-size:12px; margin-top:8px; opacity:.92; }
.kpi .icon-circle { position:absolute; right:14px; top:14px; width:40px; height:40px; border-radius:50%; background:rgba(255,255,255,.25); display:flex; align-items:center; justify-content:center; font-size:18px; }
.kpi.blue{background:linear-gradient(135deg,#2563eb,#1e4fd1);}
.kpi.green{background:linear-gradient(135deg,#16a34a,#0d8f43);}
.kpi.orange{background:linear-gradient(135deg,#f59e0b,#e88a00);}
.kpi.purple{background:linear-gradient(135deg,#8b5cf6,#7c3aed);}
.kpi.teal{background:linear-gradient(135deg,#14b8a6,#0d9488);}
.kpi.red{background:linear-gradient(135deg,#ef4444,#dc2626);}

.panel-row3 { display:grid; grid-template-columns: 1.3fr 1.5fr 1.3fr; gap:16px; margin-bottom:20px; }
.panel-row2 { display:grid; grid-template-columns: 1.5fr 1fr; gap:16px; margin-bottom:20px; }
.panel-row-bottom { display:grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap:16px; margin-bottom:20px;}
@media (max-width:1100px){ .panel-row3, .panel-row2, .panel-row-bottom { grid-template-columns:1fr; } }

.panel { background:#fff; border-radius:12px; padding:18px 20px; border:1px solid #edf0f4; }
.panel h3 { font-size:13.5px; letter-spacing:.5px; color:#374151; font-weight:700; margin-bottom:14px; display:flex; justify-content:space-between; align-items:center; }
.panel h3 a { font-size:12px; color:#2563eb; font-weight:600; }

.donut-wrap { display:flex; align-items:center; gap:18px; flex-wrap:wrap; }
.donut { position:relative; width:150px; height:150px; border-radius:50%; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.donut::before { content:""; position:absolute; width:92px; height:92px; background:#fff; border-radius:50%; }
.donut-center { position:relative; text-align:center; z-index:1; }
.donut-center .num { font-size:26px; font-weight:800; color:#111827; }
.donut-center .lbl { font-size:11px; color:#6b7280; }
.legend { font-size:12.5px; color:#374151; display:flex; flex-direction:column; gap:9px; }
.legend .row { display:flex; align-items:center; gap:8px; justify-content:space-between; width:190px; }
.legend .row .left { display:flex; align-items:center; gap:8px; }
.dot-sw { width:9px; height:9px; border-radius:50%; flex-shrink:0; }

.stat-boxes { display:flex; gap:10px; margin-bottom:14px; flex-wrap:wrap; }
.stat-box { flex:1; min-width:90px; background:#f8fafc; border:1px solid #edf0f4; border-radius:8px; padding:10px 12px; }
.stat-box .t { font-size:11.5px; color:#6b7280; margin-bottom:4px; }
.stat-box .v { font-size:16px; font-weight:800; color:#111827; }
.stat-box.growth .v { color:#16a34a; }
.stat-box.due .v { color:#ef4444; }
.chart-area { width:100%; height:150px; }

.pie-wrap { display:flex; align-items:center; gap:18px; flex-wrap:wrap; }
.pie { width:140px; height:140px; border-radius:50%; flex-shrink:0; }
.pie-legend { font-size:13px; color:#374151; display:flex; flex-direction:column; gap:12px; }
.pie-legend .row { display:flex; align-items:center; gap:8px; }
.pie-legend .val { font-weight:700; margin-left:4px; }

table { width:100%; border-collapse:collapse; font-size:12.5px; }
th { text-align:left; color:#6b7280; font-weight:600; padding:8px 6px; border-bottom:1px solid #eef1f5; font-size:11.5px; white-space:nowrap; }
td { padding:9px 6px; border-bottom:1px solid #f3f5f8; color:#1f2937; }
tr:hover td { background:#fafbfd; }
.status-badge { padding:3px 10px; border-radius:12px; font-size:11px; font-weight:700; }
.status-badge.green, .status-badge.paid, .status-badge.won, .status-badge.completed, .status-badge.accepted { background:#dcfce7; color:#16a34a; }
.status-badge.orange, .status-badge.pending, .status-badge.due { background:#fef3c7; color:#b45309; }
.status-badge.red, .status-badge.lost, .status-badge.rejected, .status-badge.cancelled { background:#fee2e2; color:#dc2626; }
.status-badge.blue, .status-badge.new { background:#dbeafe; color:#1d4ed8; }
.status-badge.purple { background:#ede9fe; color:#7c3aed; }
.call-icon, .wa-icon, .act-icon { display:inline-flex; width:26px; height:26px; border-radius:50%; align-items:center; justify-content:center; font-size:12px; margin-right:4px; cursor:pointer; border:none; }
.call-icon { background:#dbeafe; color:#2563eb; }
.wa-icon { background:#dcfce7; color:#16a34a; }
.edit-icon { background:#fef3c7; color:#b45309; }
.del-icon { background:#fee2e2; color:#dc2626; }

.mini-stats { display:flex; gap:8px; margin-bottom:14px; }
.mini-stat { flex:1; text-align:center; background:#f8fafc; border:1px solid #edf0f4; border-radius:8px; padding:8px 4px; }
.mini-stat .t { font-size:10.5px; color:#6b7280; }
.mini-stat .v { font-size:17px; font-weight:800; color:#111827; }
.svc-type-row { margin-bottom:8px; font-size:12px; color:#374151; }
.bar-bg { background:#eef1f5; border-radius:6px; height:7px; margin:4px 0; overflow:hidden; }
.bar-fill { height:100%; border-radius:6px; background:#2563eb; }
.bar-fill.green { background:#16a34a; }
.prod-row { display:flex; align-items:center; gap:8px; margin-bottom:10px; font-size:12.5px; color:#374151; }
.prod-row .pname { width:120px; flex-shrink:0; }
.prod-row .bar-bg { flex:1; }
.prod-row .pnum { width:22px; text-align:right; font-weight:700; color:#111827; }

.summary-row { display:flex; align-items:center; justify-content:space-between; padding:10px 0; border-bottom:1px solid #f3f5f8; font-size:13px; }
.summary-row:last-child { border-bottom:none; }
.summary-row .left { display:flex; align-items:center; gap:10px; color:#374151; font-weight:600; }
.sq-icon { width:30px; height:30px; border-radius:8px; display:flex; align-items:center; justify-content:center; font-size:14px; color:#fff; }
.summary-row .val { font-weight:800; color:#111827; }
.summary-row .val.red { color:#ef4444; }

.qa-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.qa-btn { display:flex; align-items:center; gap:8px; justify-content:center; padding:12px 8px; border-radius:8px; color:#fff; font-size:12.5px; font-weight:700; cursor:pointer; border:none; }
.qa1{background:#2563eb;} .qa2{background:#16a34a;} .qa3{background:#f59e0b;} .qa4{background:#7c3aed;} .qa5{background:#0891b2;} .qa6{background:#1d4ed8;}

footer.page-footer { text-align:center; padding:9px; font-size:10.5px; color:#9ca3af; }

/* Generic form/module page */
.page-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; flex-wrap:wrap; gap:10px; }
.page-head h2 { font-size:19px; color:#111827; }
.btn { display:inline-flex; align-items:center; gap:6px; padding:9px 16px; border-radius:8px; font-size:13px; font-weight:700; border:none; cursor:pointer; }
.btn-primary { background:#2563eb; color:#fff; }
.btn-green { background:#16a34a; color:#fff; }
.btn-outline { background:#fff; color:#374151; border:1px solid #dbe2ea; }
.form-panel { background:#fff; border-radius:12px; padding:22px; border:1px solid #edf0f4; max-width:720px; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:14px; }
@media (max-width:640px){ .form-row{ grid-template-columns:1fr; } }
.form-group label { display:block; font-size:12.5px; color:#374151; font-weight:600; margin-bottom:6px; }
.form-group input, .form-group select, .form-group textarea {
  width:100%; padding:10px 12px; border:1px solid #dbe2ea; border-radius:8px; font-size:13px; color:#1f2937; background:#fff;
}
.form-group textarea { resize:vertical; min-height:80px; }
.form-actions { display:flex; gap:10px; margin-top:8px; }
.alert { padding:12px 16px; border-radius:8px; font-size:13px; margin-bottom:16px; }
.alert-success { background:#dcfce7; color:#166534; border:1px solid #bbf7d0; }
.alert-error { background:#fee2e2; color:#991b1b; border:1px solid #fecaca; }
.filter-bar { display:flex; gap:10px; margin-bottom:16px; flex-wrap:wrap; }
.filter-bar select, .filter-bar input { padding:8px 12px; border:1px solid #dbe2ea; border-radius:8px; font-size:13px; }
.badge-count { background:#eef2ff; color:#4338ca; padding:2px 9px; border-radius:10px; font-size:11px; font-weight:700; }

/* =========================================================
   DASHBOARD ONE-SCREEN MODE
   Only applies when <body class="dashboard-page"> (set by index.php).
   All other module/report/form pages keep normal scrolling.
========================================================= */
html { height:100%; }
body.dashboard-page { overflow:visible; }
body.dashboard-page .layout { min-height:100vh; }
body.dashboard-page .sidebar { min-height:100vh; width:200px; }
body.dashboard-page .brand { padding:12px 14px; }
body.dashboard-page .brand .drop { width:26px; height:26px; font-size:13px; }
body.dashboard-page .brand-text b { font-size:12px; }
body.dashboard-page .brand-text span { font-size:8.5px; }
body.dashboard-page .nav { padding:4px 0; }
body.dashboard-page .nav-item, body.dashboard-page .nav a > .nav-item { padding:7px 14px; font-size:11.5px; }
body.dashboard-page .nav .icon { width:15px; font-size:12px; }
body.dashboard-page .support { margin:8px; padding:9px; font-size:10px; }
body.dashboard-page .support b { font-size:11px; }
body.dashboard-page .main { min-height:100vh; overflow:visible; }
body.dashboard-page .topbar { padding:9px 18px; }
body.dashboard-page .topbar-left h1 { font-size:15px; }
body.dashboard-page .pill, body.dashboard-page .whatsapp-btn { padding:5px 10px; font-size:11px; }
body.dashboard-page .avatar { width:26px; height:26px; font-size:13px; }
body.dashboard-page .profile .name { font-size:11px; }
body.dashboard-page .profile .role { font-size:9.5px; }
body.dashboard-page .content { padding:10px 16px; overflow:visible; display:flex; flex-direction:column; gap:9px; }

body.dashboard-page .kpi-row { display:grid; grid-template-columns:repeat(6,1fr); gap:10px; }
body.dashboard-page .kpi { border-radius:9px; padding:9px 12px; min-height:74px; }
body.dashboard-page .kpi .label { font-size:10.5px; margin-bottom:5px; }
body.dashboard-page .kpi .value { font-size:18px; gap:6px; }
body.dashboard-page .kpi .sub { font-size:9.5px; margin-top:4px; }
body.dashboard-page .kpi .icon-circle { right:9px; top:9px; width:26px; height:26px; font-size:12px; }

body.dashboard-page .panel-row3 { gap:10px; flex:1.15; min-height:0; }
body.dashboard-page .panel { border-radius:9px; padding:10px 13px; overflow:visible; display:flex; flex-direction:column; }
body.dashboard-page .panel h3 { font-size:10.5px; margin-bottom:8px; flex-shrink:0; }
body.dashboard-page .panel h3 a { font-size:10px; }

body.dashboard-page .donut-wrap { gap:12px; flex:1; min-height:0; }
body.dashboard-page .donut { width:96px; height:96px; }
body.dashboard-page .donut::before { width:58px; height:58px; }
body.dashboard-page .donut-center .num { font-size:17px; }
body.dashboard-page .donut-center .lbl { font-size:8px; }
body.dashboard-page .legend { font-size:10px; gap:5px; }
body.dashboard-page .legend .row { gap:6px; width:140px; }
body.dashboard-page .dot-sw { width:7px; height:7px; }

body.dashboard-page .stat-boxes { gap:7px; margin-bottom:8px; flex-shrink:0; }
body.dashboard-page .stat-box { padding:6px 8px; }
body.dashboard-page .stat-box .t { font-size:9.5px; margin-bottom:2px; }
body.dashboard-page .stat-box .v { font-size:12.5px; }
body.dashboard-page .chart-area { flex:1; min-height:0; height:auto; }

body.dashboard-page .pie-wrap { gap:12px; flex:1; min-height:0; }
body.dashboard-page .pie { width:88px; height:88px; }
body.dashboard-page .pie-legend { font-size:10.5px; gap:8px; }
body.dashboard-page .stat-boxes.three { gap:6px; margin-bottom:8px; }

body.dashboard-page .panel-row2 { gap:10px; flex:1; min-height:0; }
body.dashboard-page .panel-row2 table { font-size:10.5px; }
body.dashboard-page .panel-row2 th { padding:5px 5px; font-size:9.5px; }
body.dashboard-page .panel-row2 td { padding:5px 5px; }
body.dashboard-page .status-badge { padding:2px 8px; font-size:9.5px; }
body.dashboard-page .call-icon, body.dashboard-page .wa-icon { width:20px; height:20px; font-size:10px; }

body.dashboard-page .panel-row-bottom { gap:10px; flex:1.05; min-height:0; }
body.dashboard-page .mini-stats { gap:6px; margin-bottom:8px; flex-shrink:0; }
body.dashboard-page .mini-stat { padding:5px 3px; }
body.dashboard-page .mini-stat .t { font-size:8.5px; }
body.dashboard-page .mini-stat .v { font-size:13px; }
body.dashboard-page .svc-type-row { margin-bottom:5px; font-size:10px; }
body.dashboard-page .bar-bg { height:5px; margin:3px 0; }
body.dashboard-page .prod-row { gap:6px; margin-bottom:6px; font-size:10px; }
body.dashboard-page .prod-row .pname { width:78px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
body.dashboard-page .prod-row .pnum { width:18px; }
body.dashboard-page .summary-row { padding:6px 0; font-size:10.5px; }
body.dashboard-page .summary-row .left { gap:7px; }
body.dashboard-page .sq-icon { width:22px; height:22px; font-size:11px; }
body.dashboard-page .qa-grid { gap:6px; flex:1; }
body.dashboard-page .qa-btn { padding:8px 6px; font-size:10px; gap:6px; }
body.dashboard-page footer.page-footer { padding:3px; font-size:9px; flex-shrink:0; }

/* Below ~1280px width, one-screen mode is impractical - allow normal scroll instead */
@media (max-width: 1280px) {
  body.dashboard-page { overflow:auto; }
  body.dashboard-page .layout { height:auto; min-height:100vh; }
  body.dashboard-page .sidebar, body.dashboard-page .main { height:auto; overflow:visible; }
  body.dashboard-page .content { overflow:visible; }
}

/* ================== v3.9: Site-wide mobile responsiveness ================== */
@media (max-width: 900px) {
  .layout { position:relative; }
  .sidebar {
    position:fixed; top:0; left:0; height:100vh; z-index:300;
    transform:translateX(-100%); transition:transform .25s ease; box-shadow:4px 0 20px rgba(0,0,0,.2);
  }
  .sidebar.mobile-open { transform:translateX(0); }
  .sidebar.mobile-open::after {
    content:''; position:fixed; inset:0 0 0 230px; background:rgba(0,0,0,.35); z-index:-1;
  }
  .main { width:100%; margin-left:0 !important; }
  .hamburger { display:block !important; }
  .topbar { flex-wrap:wrap; gap:10px; }
  .content { padding:14px !important; }
  .kpi-row { grid-template-columns:repeat(2,1fr) !important; }
}
@media (max-width: 560px) {
  .kpi-row { grid-template-columns:1fr !important; }
  .page-head { flex-direction:column; align-items:flex-start; gap:10px; }
  .page-head > div { width:100%; }
  .btn, .page-head .btn { width:auto; }
}

/* Collapse every multi-column form/panel grid to a single column on small screens */
@media (max-width: 700px) {
  .form-row, .row, .q-row, .top-row, .bottom-row,
  .panel-row2, .panel-row3, .panel-row4, .panel-row-bottom {
    grid-template-columns: 1fr !important;
  }
}

/* Any table not already wrapped for horizontal scroll gets one automatically (see app.js) */
.table-scroll { overflow-x:auto; max-width:100%; -webkit-overflow-scrolling:touch; }
@media (max-width: 700px) {
  table { font-size:12px; }
  .panel { padding:14px !important; }
}

/* Login page */
.login-wrap { min-height:100vh; display:flex; align-items:center; justify-content:center; background:linear-gradient(135deg,#0b1f3a,#1e4fd1); }
.login-box { background:#fff; border-radius:14px; padding:40px 36px; width:360px; box-shadow:0 20px 50px rgba(0,0,0,.25); }
.login-box .drop { width:54px; height:54px; background:#2196f3; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:26px; margin:0 auto 14px; }
.login-box h2 { text-align:center; font-size:19px; margin-bottom:4px; color:#111827; }
.login-box p.sub { text-align:center; font-size:12.5px; color:#6b7280; margin-bottom:24px; }
.login-box .form-group { margin-bottom:16px; }
.login-box button { width:100%; padding:11px; background:#1976d2; color:#fff; border:none; border-radius:8px; font-weight:700; cursor:pointer; font-size:14px; }
.login-hint { margin-top:16px; text-align:center; font-size:11.5px; color:#9ca3af; }

/* ================== v3 additions: Timeline, Tabs, Accounts, Misc ================== */
.activity-timeline { position:relative; padding-left:6px; }
.tl-item { display:flex; gap:12px; margin-bottom:16px; position:relative; }
.tl-item:not(:last-child)::before { content:''; position:absolute; left:17px; top:36px; bottom:-16px; width:2px; background:#e5e7eb; }
.tl-dot { width:34px; height:34px; min-width:34px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:15px; }
.tl-body { flex:1; }
.tl-type { font-size:12.5px; font-weight:700; }
.tl-text { font-size:12.5px; color:#374151; margin-top:2px; }
.tl-date { font-size:10.5px; color:#9ca3af; margin-top:2px; }

.tabs { display:flex; gap:6px; border-bottom:1px solid #e5e7eb; margin-bottom:16px; flex-wrap:wrap; }
.tab-btn { padding:9px 16px; border:none; background:none; cursor:pointer; font-size:13px; font-weight:600; color:#6b7280; border-bottom:2px solid transparent; }
.tab-btn.active { color:#2563eb; border-bottom-color:#2563eb; }
.tab-pane { display:none; }
.tab-pane.active { display:block; }

.profile-header { display:flex; justify-content:space-between; align-items:flex-start; background:#fff; border-radius:12px; padding:18px 22px; margin-bottom:16px; box-shadow:0 1px 3px rgba(0,0,0,.06); flex-wrap:wrap; gap:12px; }
.profile-header .ph-name { font-size:19px; font-weight:800; }
.profile-header .ph-sub { font-size:12.5px; color:#6b7280; margin-top:4px; }
.mini-kpi-row { display:flex; gap:12px; flex-wrap:wrap; margin-bottom:16px; }
.mini-kpi { flex:1; min-width:140px; background:#fff; border-radius:10px; padding:12px 14px; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.mini-kpi .t { font-size:11px; color:#6b7280; font-weight:600; }
.mini-kpi .v { font-size:18px; font-weight:800; margin-top:4px; }

.badge-warn { background:#fef3c7; color:#b45309; padding:8px 12px; border-radius:8px; font-size:12.5px; font-weight:600; margin-bottom:12px; display:inline-block; }
.stock-alert-row { display:flex; justify-content:space-between; align-items:center; padding:7px 0; border-bottom:1px dashed #f1f5f9; font-size:12.5px; }
.stock-alert-row:last-child { border-bottom:none; }
.stock-badge { background:#fee2e2; color:#dc2626; padding:2px 8px; border-radius:10px; font-size:10.5px; font-weight:700; }

.income-text { color:#16a34a; font-weight:700; }
.expense-text { color:#ef4444; font-weight:700; }
.profit-pos { color:#16a34a; }
.profit-neg { color:#ef4444; }

.status-badge.assigned, .status-badge.onway, .status-badge.inprogress { background:#dbeafe; color:#1d4ed8; }
.status-badge.partial { background:#fef3c7; color:#b45309; }

@media print {
  * { -webkit-print-color-adjust:exact !important; print-color-adjust:exact !important; color-adjust:exact !important; }
  html, body {
    width:210mm !important; height:297mm !important; margin:0 !important; padding:0 !important;
    overflow:hidden !important;
  }
  .sidebar, .topbar, .page-footer, .no-print, .quo-left { display:none !important; }
  .main { margin:0 !important; }
  .content { padding:0 !important; }
  .quo-right, .pv-wrap {
    width:190mm !important; max-width:190mm !important; position:static !important;
    overflow:visible !important; margin:0 auto !important;
  }
  .a4 {
    width:190mm !important; max-width:190mm !important;
    min-height:277mm !important; height:auto !important;
    aspect-ratio:unset !important; box-sizing:border-box !important;
    box-shadow:none !important; border:none !important; border-radius:0 !important;
    margin:0 !important; padding:8mm !important;
    display:flex !important; flex-direction:column !important; justify-content:space-between !important;
    gap:6mm;
  }
  .pv-top, .pv-co-row, .pv-two-col, .pv-table, .pv-summary, .pv-bottom, .pv-footer {
    page-break-inside: avoid;
  }
  .pv-table tr { page-break-inside: avoid; }
  @page { size: A4 portrait; margin: 0; }
}

/* ================== v3.1: SVG icon alignment (replacing emoji) ================== */
.nav .icon, .icon-circle, .sq-icon, .bell, .avatar { display:flex; align-items:center; justify-content:center; }
.nav .icon svg { display:block; }
.qa-btn { display:flex; align-items:center; gap:8px; justify-content:center; }
.qa-btn svg { flex-shrink:0; }
.support b { display:flex; align-items:center; gap:6px; }
.support b svg { flex-shrink:0; }

.source-filter {
  padding:8px 32px 8px 14px;
  border:1px solid #dbe2ea;
  border-radius:8px;
  font-size:13px;
  color:#374151;
  background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  background-size:12px;
  appearance:none;
  -webkit-appearance:none;
  cursor:pointer;
}
body.dashboard-page .source-filter { padding:5px 26px 5px 10px; font-size:11px; }

/* ================== v3.2: Topbar redesign (subtitle, Quick Action dropdown, icon buttons) ================== */
.topbar-left { display:flex; align-items:center; gap:14px; }
.topbar-subtitle { font-size:12px; color:#6b7280; margin-top:2px; }

.qa-dropdown-wrap { position:relative; }
.qa-dropdown-btn { display:flex; align-items:center; gap:6px; background:#16a34a; color:#fff; border:none; padding:9px 16px; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; }
.qa-dropdown-btn:hover { background:#15803d; }
.qa-dropdown-menu { display:none; position:absolute; right:0; top:calc(100% + 6px); background:#fff; border:1px solid #e5e7eb; border-radius:10px; box-shadow:0 8px 24px rgba(0,0,0,.12); min-width:200px; padding:6px; z-index:50; }
.qa-dropdown-menu.open { display:block; }
.qa-dropdown-menu a { display:flex; align-items:center; gap:10px; padding:9px 12px; border-radius:7px; color:#374151; text-decoration:none; font-size:13px; font-weight:600; }
.qa-dropdown-menu a:hover { background:#f3f4f6; color:#111827; }
.qa-dropdown-menu a svg { color:#6b7280; flex-shrink:0; }

.icon-btn { position:relative; width:38px; height:38px; border-radius:50%; display:flex; align-items:center; justify-content:center; color:#374151; background:#f3f4f6; cursor:pointer; }
.icon-btn.bell { background:none; width:auto; height:auto; }
.icon-btn .dot { position:absolute; top:-6px; right:-8px; background:#ef4444; color:#fff; font-size:10px; width:16px; height:16px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; }

body.dashboard-page .qa-dropdown-btn { padding:6px 12px; font-size:11px; }
body.dashboard-page .icon-btn { width:30px; height:30px; }

/* ================== v3.2: Financial Overview panel + 4-col row + branch filter ================== */
.panel-row4 { display:grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap:14px; margin-bottom:20px; }
@media (max-width:1300px){ .panel-row4 { grid-template-columns: 1fr 1fr; } }
@media (max-width:700px){ .panel-row4 { grid-template-columns: 1fr; } }

.h3-sub { font-size:10.5px; font-weight:500; color:#9ca3af; text-transform:none; margin-left:4px; }

.fin-row { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px dashed #f1f5f9; }
.fin-row:last-child { border-bottom:none; }
.fin-icon { width:26px; height:26px; border-radius:7px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.fin-label { flex:1; font-size:12.5px; color:#374151; }
.fin-val { font-size:13px; font-weight:700; color:#111827; }

.qa7{background:#0f172a;}

body.dashboard-page .panel-row4 { gap:8px; }
body.dashboard-page .fin-row { padding:4px 0; }
body.dashboard-page .fin-icon { width:18px; height:18px; }
body.dashboard-page .fin-label { font-size:9.5px; }
body.dashboard-page .fin-val { font-size:10px; }

/* ================== v3.4: Follow-up filter badge tabs ================== */
.fu-tabs { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:16px; }
.fu-tab { position:relative; background:#fff; border:1px solid #e5e7eb; border-radius:10px; padding:10px 22px 10px 14px; font-size:12.5px; font-weight:600; color:#374151; text-decoration:none; transition:all .15s; }
.fu-tab:hover { border-color:#2563eb; color:#2563eb; }
.fu-tab.active { background:#2563eb; border-color:#2563eb; color:#fff; }
.fu-count { position:absolute; top:-8px; right:-8px; background:#ef4444; color:#fff; font-size:10.5px; font-weight:700; min-width:20px; height:20px; padding:0 5px; border-radius:10px; display:flex; align-items:center; justify-content:center; box-shadow:0 1px 3px rgba(0,0,0,.2); }
.fu-tab.active .fu-count { background:#fff; color:#2563eb; }
.fu-actions { white-space:nowrap; }
.fu-actions a { margin-right:3px; }

/* ================== v3.5: Row-level 3-dot action dropdown (tables) ================== */
.row-dropdown { position:relative; display:inline-block; }
.row-dots-btn { width:30px; height:30px; border-radius:6px; border:1px solid #e5e7eb; background:#f9fafb; color:#374151; display:flex; align-items:center; justify-content:center; cursor:pointer; }
.row-dots-btn:hover { background:#f3f4f6; color:#111827; }
.row-dropdown .qa-dropdown-menu { min-width:190px; white-space:nowrap; text-align:left; }

/* ================== v3.6: Searchable select (type-to-filter dropdown) ================== */
.ss-wrap { position:relative; }
.ss-input { width:100%; padding:10px 12px; border:1px solid #d1d5db; border-radius:8px; font-size:13px; box-sizing:border-box; }
.ss-input:focus { outline:none; border-color:#2563eb; box-shadow:0 0 0 3px rgba(37,99,235,.1); }
.ss-list { display:none; position:absolute; top:calc(100% + 4px); left:0; right:0; background:#fff; border:1px solid #e5e7eb; border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,.12); max-height:240px; overflow-y:auto; z-index:60; }
.ss-list.open { display:block; }
.ss-item { padding:9px 12px; font-size:13px; color:#374151; cursor:pointer; }
.ss-item:hover, .ss-item.active { background:#eff6ff; color:#2563eb; }
.ss-empty { padding:9px 12px; font-size:12.5px; color:#9ca3af; }

/* ================== v3.7: Quotation Builder (live A4 preview page) ================== */
.quo-grid { display:flex; gap:16px; align-items:flex-start; }
.quo-left { flex:1.55; min-width:0; }
.quo-right { width:420px; flex-shrink:0; position:sticky; top:18px; }
@media (max-width:1300px){ .quo-grid{ flex-direction:column; } .quo-right{ width:100%; position:static; } }

.top-row { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
@media (max-width:800px){ .top-row{ grid-template-columns:1fr; } }
.bottom-row { display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; }
@media (max-width:1000px){ .bottom-row{ grid-template-columns:1fr; } }
.q-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:12px; }
@media (max-width:640px){ .q-row{ grid-template-columns:1fr; } }

.quo-left label, .quo-right label { display:block; font-size:11.5px; color:#6b7280; font-weight:600; margin-bottom:5px; }
.quo-left input[type=text], .quo-left input[type=date], .quo-left input[type=number],
.quo-left select, .quo-left textarea, .quo-right input[type=text] {
  width:100%; padding:9px 11px; border:1px solid #d1d5db; border-radius:8px; font-size:13px; font-family:inherit; background:#fff; box-sizing:border-box;
}
.quo-left textarea { resize:vertical; }

.readonly-box { background:#f3f4f6; border:1px solid #e5e7eb; border-radius:8px; padding:9px 11px; font-size:13px; font-weight:600; color:#111827; }

.cust-search-row { display:flex; gap:8px; margin-bottom:6px; }
.cust-search-row .ss-wrap { flex:1; }
.btn-new { white-space:nowrap; }
.lead-toggle-link { font-size:11.5px; color:#2563eb; cursor:pointer; text-decoration:underline; margin-bottom:10px; display:inline-block; }
.new-cust-box { display:none; background:#f8fafc; border:1px dashed #cbd5e1; border-radius:10px; padding:12px; margin-bottom:12px; }
.new-cust-box.show { display:block; }

.cust-card { display:none; grid-template-columns:1fr auto; gap:10px; margin-top:8px; }
.cust-card.show { display:grid; }
.cust-left { display:flex; gap:10px; }
.cust-left .ic { color:#2563eb; font-size:16px; margin-top:2px; }
.cust-left .name { font-weight:800; font-size:14px; }
.cust-left .line { font-size:12.5px; color:#374151; margin-top:3px; display:flex; align-items:center; gap:5px; }
.cust-right { text-align:right; font-size:12px; }
.cust-right .lbl { color:#6b7280; }
.cust-right b { color:#111827; }
.empty-hint { color:#9ca3af; font-size:11.5px; padding:8px 0 2px; }

#itemsTable th { text-transform:uppercase; }
#itemsTable td input { padding:6px 8px; font-size:12.5px; }
.item-name input, .item-model input { font-weight:600; }
.qty-input { width:60px; } .price-input,.disc-input{ width:90px; }
.row-total { font-weight:700; white-space:nowrap; }
.del-row { color:#ef4444; cursor:pointer; background:none; border:none; font-size:15px; }
.add-item-btn { margin-top:10px; padding:9px 14px; border-radius:8px; border:1px dashed #93c5fd; background:#eff6ff; color:#2563eb; font-weight:700; font-size:12.5px; cursor:pointer; }

.pf { margin-bottom:12px; }
.pf-row2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:12px; }
.grand-row { display:flex; justify-content:space-between; align-items:baseline; margin:14px 0 12px; padding-top:12px; border-top:2px solid #111827; }
.grand-row .lbl { font-weight:700; font-size:13.5px; }
.grand-row .val { font-weight:800; font-size:19px; color:#111827; }
.words-box { background:#f3f4f6; border:1px solid #e5e7eb; border-radius:8px; padding:10px 11px; font-size:12px; color:#374151; min-height:44px; }

.terms-edit { border:none; background:transparent; padding:0; font-size:12px; color:#374151; width:100%; min-height:110px; font-family:inherit; resize:vertical; }
.terms-edit:focus { outline:1px dashed #93c5fd; }

.pm-grid { display:flex; flex-wrap:wrap; gap:10px; margin-bottom:14px; }
.pm-opt { display:flex; align-items:center; gap:8px; border:1.5px solid #e5e7eb; border-radius:9px; padding:8px 12px; cursor:pointer; font-size:12.5px; font-weight:600; color:#374151; }
.pm-opt.checked { border-color:#2563eb; background:#eff6ff; color:#2563eb; }
.pm-opt input { display:none; }
.pm-ic { width:26px; height:26px; border-radius:7px; display:flex; align-items:center; justify-content:center; font-size:13px; color:#fff; flex-shrink:0; }

/* A4 live preview */
.quo-right { overflow-x:hidden; }
.a4 { background:#fff; border:1px solid #e5e7eb; border-radius:10px; padding:22px 24px; font-size:11.5px; color:#111827; box-shadow:0 4px 18px rgba(0,0,0,.06); width:100%; aspect-ratio:210/297; overflow-x:hidden; box-sizing:border-box; }
.pv-table, .pv-summary, .pv-two-col, .pv-bottom, .pv-co-row { max-width:100%; box-sizing:border-box; }
.pv-summary { width:auto; max-width:220px; }
.pv-table { table-layout:fixed; word-wrap:break-word; }
.pv-top { display:flex; justify-content:space-between; align-items:flex-start; border-bottom:2px solid #2563eb; padding-bottom:12px; margin-bottom:12px; }
.pv-brand { display:flex; align-items:center; gap:8px; }
.pv-brand .drop { width:28px; height:28px; background:#2563eb; border-radius:9px; display:flex; align-items:center; justify-content:center; color:#fff; font-weight:800; font-size:14px; }
.pv-brand b { font-size:13px; display:block; }
.pv-brand span { font-size:8.5px; color:#6b7280; letter-spacing:.5px; }
.pv-co-row { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; }
.pv-co { font-size:10px; color:#4b5563; margin-top:6px; line-height:1.5; }
.pv-date-block { text-align:right; font-size:10.5px; color:#374151; white-space:nowrap; }
.pv-date-block div { margin-bottom:4px; }
.pv-date-block span { color:#6b7280; margin-right:6px; }
.pv-title { text-align:right; }
.pv-title h2 { margin:0; color:#2563eb; font-size:18px; letter-spacing:1px; }
.pv-title div { font-size:10.5px; color:#4b5563; margin-top:4px; }
.pv-two-col { display:flex; justify-content:space-between; gap:16px; margin-bottom:12px; }
.pv-two-col .blk h4 { font-size:10px; color:#2563eb; margin:0 0 6px; }
.pv-two-col .blk div { font-size:10.5px; color:#374151; margin-bottom:2px; }
.pv-table { width:100%; border-collapse:collapse; margin-bottom:10px; }
.pv-table th { background:#f3f4f6; font-size:9px; text-transform:uppercase; padding:6px 6px; text-align:left; color:#4b5563; }
.pv-table td { padding:6px 6px; font-size:10.5px; border-bottom:1px solid #f3f4f6; }
.pv-summary { margin-left:auto; width:220px; }
.pv-summary .r { display:flex; justify-content:space-between; padding:4px 0; font-size:10.5px; color:#374151; }
.pv-summary .grand { background:#2563eb; color:#fff; padding:8px 10px; border-radius:6px; display:flex; justify-content:space-between; font-weight:800; margin-top:6px; font-size:12.5px; }
.pv-words { font-size:9.5px; color:#6b7280; font-style:italic; margin-top:8px; }
.pv-bottom { display:flex; justify-content:space-between; margin-top:18px; padding-top:12px; border-top:1px solid #e5e7eb; }
.pv-bottom .blk h5 { font-size:9px; color:#2563eb; margin:0 0 6px; }
.pv-bottom .blk ol { font-size:9px; color:#4b5563; padding-left:14px; margin:0; }
.pv-sign { text-align:center; font-size:9.5px; color:#4b5563; }
.pv-sign .line { border-top:1px solid #9ca3af; width:110px; margin:22px auto 4px; }
.pv-thanks { text-align:center; font-size:10px; color:#6b7280; font-style:italic; margin:14px 0 10px; }
.pv-footer { background:#0b1f3a; color:#cbd5e1; text-align:center; padding:7px; border-radius:0 0 8px 8px; margin:14px -24px -22px; font-size:9px; }

/* ================== Quotation-only print theme: deep blue + higher-contrast text ================== */
.quo-doc.a4 { color:#111827; }
.quo-doc .pv-top { border-bottom-color:#1e3a8a; }
.quo-doc .pv-brand .drop { background:#1e3a8a; }
.quo-doc .pv-title h2 { color:#1e3a8a; }
.quo-doc .pv-co { color:#1f2937; }
.quo-doc .pv-date-block { color:#1f2937; }
.quo-doc .pv-date-block span { color:#374151; }
.quo-doc .pv-two-col .blk h4 { color:#1e3a8a; }
.quo-doc .pv-two-col .blk div { color:#1f2937; }
.quo-doc .pv-table th { background:#e0e7ff; color:#1e3a8a; font-weight:700; }
.quo-doc .pv-table td { color:#1f2937; }
.quo-doc .pv-summary .r { color:#1f2937; }
.quo-doc .pv-summary .grand { background:#1e3a8a; }
.quo-doc .pv-words { color:#374151; }
.quo-doc .pv-bottom .blk h5 { color:#1e3a8a; }
.quo-doc .pv-bottom .blk ol { color:#1f2937; }
.quo-doc .pv-sign { color:#1f2937; }
.quo-doc .pv-thanks { color:#374151; }
.quo-doc .pv-footer { background:#1e3a8a; }

.table-scroll { overflow-x:auto; max-width:100%; }
#itemsTable { min-width:760px; }
.quo-left, .quo-grid, .top-row > .panel, .bottom-row > .panel { min-width:0; }
.quo-grid { max-width:100%; }
.btn-outline-blue { border-color:#93c5fd; color:#2563eb; background:#fff; }
.btn-outline-blue:hover { background:#eff6ff; }

/* ================== v3.8: Table pagination + show-entries toolbar ================== */
.table-toolbar { display:flex; justify-content:flex-end; align-items:center; gap:10px; margin-bottom:10px; flex-wrap:wrap; }
.table-toolbar label { font-size:12.5px; color:#6b7280; display:flex; align-items:center; gap:6px; white-space:nowrap; }
.table-toolbar select { padding:6px 10px; border:1px solid #d1d5db; border-radius:8px; font-size:12.5px; background:#fff; }
.table-toolbar input[type=text] {
  flex:1;
  min-width:200px;
  padding:8px 14px;
  border:1px solid #d1d5db;
  border-radius:8px;
  font-size:13px;
  color:#111827;
  background:#fff;
  transition: border-color .15s, box-shadow .15s;
}
.table-toolbar input[type=text]::placeholder { color:#9ca3af; }
.table-toolbar input[type=date] {
  padding:6px 10px;
  border:1px solid #d1d5db;
  border-radius:8px;
  font-size:12.5px;
  color:#111827;
  background:#fff;
  transition: border-color .15s, box-shadow .15s;
}
.table-toolbar input[type=date]:focus {
  outline:none;
  border-color:#2563eb;
  box-shadow:0 0 0 3px rgba(37,99,235,.12);
}
.table-toolbar input[type=text]:focus {
  outline:none;
  border-color:#2563eb;
  box-shadow:0 0 0 3px rgba(37,99,235,.12);
}
.table-pagination { display:flex; align-items:center; gap:6px; justify-content:flex-end; margin-top:14px; flex-wrap:wrap; }
.pg-info { font-size:11.5px; color:#9ca3af; margin-right:auto; }
.pg-btn { padding:6px 11px; border:1px solid #e5e7eb; background:#fff; border-radius:6px; font-size:12px; font-weight:600; color:#374151; cursor:pointer; }
.pg-btn:hover:not(:disabled) { background:#f3f4f6; }
.pg-btn.active { background:#2563eb; border-color:#2563eb; color:#fff; }
.pg-btn:disabled { opacity:.4; cursor:not-allowed; }

/* ================== v3.10: Stock Transaction filters ================== */
.txn-filter-bar { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.txn-filter-bar select, .txn-filter-bar input[type=date] { padding:7px 10px; border:1px solid #d1d5db; border-radius:7px; font-size:12px; }
.txn-filter-bar input[type=text] { padding:7px 10px; border:1px solid #d1d5db; border-radius:7px; font-size:12px; }

/* ================== v3.11: Nicer topbar profile section ================== */
.profile { display:flex; align-items:center; gap:10px; padding:6px 12px 6px 6px; border-radius:12px; background:#f8fafc; border:1px solid #eef1f5; transition:background .15s; }
.profile:hover { background:#f1f5f9; }
.profile .avatar { width:38px; height:38px; border-radius:50%; background:linear-gradient(135deg,#2563eb,#1d4ed8); color:#fff; display:flex; align-items:center; justify-content:center; flex-shrink:0; box-shadow:0 2px 6px rgba(37,99,235,.25); }
.profile .name { font-size:13px; font-weight:700; color:#111827; line-height:1.3; }
.profile .role { font-size:11px; color:#6b7280; line-height:1.4; }
.profile .role a { font-weight:600; text-decoration:none; padding:1px 6px; border-radius:5px; transition:background .15s; }
.profile .role a:hover { background:#fee2e2; }

/* ================== v3.12: Fixed bottom footer (like a bottom topbar) ================== */
.page-footer {
  position: fixed;
  left: 230px;
  right: 0;
  bottom: 0;
  z-index: 150;
  background: #fff;
  border-top: 1px solid #eef1f5;
}
.content { padding-bottom: 30px !important; }
@media (max-width: 900px) {
  .page-footer { left: 0; }
}

/* ================== v3.13: Real notification dropdown ================== */
.icon-btn.bell.qa-dropdown-wrap { position:relative; }
.notif-dropdown { right:0; left:auto; padding:6px 0; }
.notif-section-title { font-size:10.5px; font-weight:700; color:#6b7280; text-transform:uppercase; letter-spacing:.03em; padding:10px 14px 4px; }
.notif-item { display:flex; flex-direction:column; gap:2px; padding:8px 14px; text-decoration:none; border-bottom:1px solid #f3f4f6; }
.notif-item:hover { background:#f8fafc; }
.notif-item b { font-size:12.5px; color:#111827; }
.notif-item span { font-size:11px; color:#9ca3af; }
.notif-viewall { display:block; text-align:center; padding:8px; font-size:11.5px; color:#2563eb; text-decoration:none; font-weight:600; }
.notif-viewall:hover { background:#f8fafc; }

/* ================== v3.14: Notification dismiss button ================== */
.notif-item-row { display:flex; align-items:center; border-bottom:1px solid #f3f4f6; }
.notif-item-row .notif-item { flex:1; border-bottom:none; }
.notif-dismiss-btn { background:none; border:none; color:#9ca3af; font-size:13px; cursor:pointer; padding:6px 10px; flex-shrink:0; }
.notif-dismiss-btn:hover { color:#ef4444; }

.password-input-wrap { position:relative; }
.password-input-wrap input { width:100%; padding-right:38px; }
.pw-toggle { position:absolute; right:10px; top:50%; transform:translateY(-50%); cursor:pointer; font-size:16px; user-select:none; opacity:0.6; }
.pw-toggle:hover { opacity:1; }
