* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --orange: #f57c00; --dark: #263238; --dark2: #37474f;
  --bg: #eceff1; --card: #ffffff; --text: #263238; --muted: #78909c;
  --green: #43a047; --red: #e53935; --teal: #00acc1; --purple: #7986cb; --yellow: #d4a017;
}
body { font-family: 'Segoe UI', Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ---------- Login ---------- */
.login-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #263238 0%, #37474f 60%, #f57c00 160%); z-index: 100; }
.login-box { background: #fff; padding: 36px; border-radius: 12px; width: 340px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-logo { font-size: 42px; }
.login-box h1 { font-size: 18px; color: var(--orange); margin: 8px 0 2px; }
.login-sub { color: var(--muted); margin-bottom: 18px; font-size: 12px; }
.login-box input { width: 100%; padding: 11px 12px; margin: 6px 0; border: 1px solid #cfd8dc; border-radius: 6px; font-size: 14px; }
.login-error { color: var(--red); font-size: 12px; margin-top: 8px; min-height: 16px; }
.login-hint { color: var(--muted); font-size: 11px; margin-top: 12px; }

/* ---------- Buttons ---------- */
.btn { border: none; padding: 9px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; text-decoration: none; display: inline-block; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: #e65100; }
.btn-ghost { background: #eceff1; color: var(--dark); }
.btn-danger { background: var(--red); color: #fff; }
.btn-green { background: #25d366; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 10px; }

/* ---------- Topbar ---------- */
.topbar { display: flex; align-items: center; gap: 16px; background: #fff; padding: 10px 16px;
  border-bottom: 1px solid #e0e0e0; position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 800; color: var(--orange); font-size: 16px; white-space: nowrap; }
.global-search { flex: 1; max-width: 420px; padding: 9px 14px; border: 1px solid #cfd8dc; border-radius: 20px; background: #f5f7f8; }
.company-select { padding: 8px 10px; border: 2px solid var(--orange); border-radius: 8px; font-weight: 700; color: var(--dark); background: #fff8f0; max-width: 260px; font-size: 13px; }
.bell { position: relative; cursor: pointer; font-size: 18px; text-decoration: none; }
.bell-count { position: absolute; top: -6px; right: -8px; background: var(--red); color: #fff; font-size: 10px; border-radius: 10px; padding: 1px 5px; font-weight: 700; }
.modal .tabbar { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 2px solid #eceff1; }
.modal .tabbar button { background: none; border: none; padding: 9px 14px; cursor: pointer; font-size: 13px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; }
.modal .tabbar button.active { color: var(--orange); border-bottom-color: var(--orange); }
.modal .mtab { display: none; }
.modal .mtab.active { display: block; }
.modal.wide { max-width: 760px; }
.chk { display: inline-flex !important; align-items: center; gap: 6px; margin-right: 14px !important; }
.chk input { width: auto !important; }
.notif-block { background: #fff; border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.notif-block h3 { font-size: 14px; margin-bottom: 10px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.fy { color: var(--green); font-weight: 700; font-size: 12px; }
.admin-chip { background: #eceff1; border-radius: 16px; padding: 6px 12px; font-size: 12px; font-weight: 600; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: calc(100vh - 54px); }
.sidebar { width: 210px; background: var(--dark); padding: 12px 0; flex-shrink: 0; }
.nav-item { display: flex; gap: 10px; align-items: center; color: #b0bec5; padding: 12px 18px; cursor: pointer; font-size: 13.5px; border-left: 3px solid transparent; }
.nav-item:hover { background: var(--dark2); color: #fff; }
.nav-item.active { background: var(--dark2); color: #fff; border-left-color: var(--orange); }
.content { flex: 1; padding: 20px; overflow-x: auto; }

/* ---------- Stat cards ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat-card { border-radius: 10px; padding: 20px; color: #fff; position: relative; cursor: pointer; min-height: 96px; box-shadow: 0 3px 10px rgba(0,0,0,.12); }
.stat-card.purple { background: linear-gradient(135deg, #7986cb, #5c6bc0); }
.stat-card.teal { background: linear-gradient(135deg, #26c6da, #00acc1); }
.stat-card.green { background: linear-gradient(135deg, #66bb6a, #43a047); }
.stat-card.yellow { background: linear-gradient(135deg, #d4b106, #d4a017); }
.stat-value { font-size: 28px; font-weight: 800; }
.stat-label { font-size: 11.5px; margin-top: 6px; letter-spacing: .5px; opacity: .95; }
.stat-icon { position: absolute; top: 14px; right: 14px; font-size: 22px; opacity: .9; }

.mini-cards { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.mini-card { background: #fff; border-radius: 8px; padding: 10px 16px; min-width: 130px; box-shadow: 0 1px 4px rgba(0,0,0,.08); cursor: default; }
.mini-card b { display: block; font-size: 18px; color: var(--dark); }
.mini-card span { font-size: 11.5px; color: var(--muted); }
.mini-card.red b { color: var(--red); }
.mini-card.clickable { cursor: pointer; transition: transform .12s, box-shadow .12s; border-bottom: 3px solid transparent; }
.mini-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.14); border-bottom-color: var(--primary, #1976d2); }
.mini-card.clickable span::after { content: ' ›'; color: #bbb; }
.filter-info { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #e3f2fd; border: 1px solid #90caf9; color: #0d47a1; border-radius: 8px; padding: 8px 14px; margin: 0 0 10px; font-size: 13px; }
.mini-card.green2 b { color: var(--green); }

/* ---------- Cards/Grid ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-bottom: 14px; }
.card { background: var(--card); border-radius: 10px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.card h3 { font-size: 14px; margin-bottom: 12px; color: var(--dark); }
.card canvas { max-height: 240px; }
.card label { display: block; margin: 10px 0; font-size: 12.5px; color: var(--muted); }
.card input, .card textarea, .card select { width: 100%; padding: 9px 10px; border: 1px solid #cfd8dc; border-radius: 6px; margin-top: 4px; font-size: 13.5px; font-family: inherit; }
.hint { font-size: 11.5px; color: var(--muted); margin: 6px 0; }

/* ---------- Pages ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.page-head h2 { font-size: 19px; }
.page-actions { display: flex; gap: 8px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input, .filters select { padding: 8px 12px; border: 1px solid #cfd8dc; border-radius: 6px; font-size: 13px; background: #fff; }
.filters input[type="text"] { min-width: 240px; }
.filters label { font-size: 12.5px; color: var(--muted); }
.filter-total { font-weight: 800; color: var(--green); margin-left: auto; font-size: 15px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--dark2); color: #fff; text-align: left; padding: 10px 12px; font-size: 12px; white-space: nowrap; position: sticky; top: 0; }
td { padding: 9px 12px; border-bottom: 1px solid #eceff1; font-size: 13px; white-space: nowrap; }
tr:hover td { background: #f5f7f8; }
.tag { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 11px; font-weight: 700; }
.tag.active, .tag.resolved, .tag.in-stock { background: #e8f5e9; color: var(--green); }
.tag.inactive, .tag.expired, .tag.faulty, .tag.open { background: #ffebee; color: var(--red); }
.tag.paused, .tag.expiring, .tag.in-progress, .tag.assigned { background: #fff8e1; color: #b28704; }
.due-amt { color: var(--red); font-weight: 700; }
.ok-amt { color: var(--green); font-weight: 700; }
.link { color: #1565c0; cursor: pointer; font-weight: 600; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tab { background: #fff; border: 1px solid #cfd8dc; padding: 9px 18px; cursor: pointer; font-size: 13px; border-radius: 6px 6px 0 0; font-weight: 600; color: var(--muted); }
.tab.active { background: var(--dark); color: #fff; border-color: var(--dark); }

/* ---------- Due report ---------- */
.area-block { background: #fff; border-radius: 10px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.08); overflow: hidden; }
.area-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: #f5f7f8; cursor: pointer; font-weight: 700; }
.area-head .amt { color: var(--red); }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; padding: 22px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; }
.modal h3 { margin-bottom: 14px; color: var(--dark); font-size: 17px; }
.modal label { display: block; margin: 9px 0; font-size: 12.5px; color: var(--muted); }
.modal input, .modal select, .modal textarea { width: 100%; padding: 9px 10px; border: 1px solid #cfd8dc; border-radius: 6px; margin-top: 4px; font-size: 13.5px; font-family: inherit; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal .big-info { background: #f5f7f8; border-radius: 8px; padding: 12px; margin-bottom: 10px; font-size: 13px; line-height: 1.8; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--dark); color: #fff;
  padding: 12px 22px; border-radius: 8px; font-size: 13.5px; opacity: 0; transition: all .3s; z-index: 99; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

/* ---------- Receipt print ---------- */
/* ---------- Customer detail (SPECTRUM style) ---------- */
.cd-wrap { display: flex; gap: 14px; align-items: flex-start; }
.cd-left { width: 300px; flex-shrink: 0; }
.cd-namecard { background: linear-gradient(135deg, #263238, #37474f); color: #fff; border-radius: 10px 10px 0 0; padding: 16px; }
.cd-namecard h2 { font-size: 17px; margin-bottom: 6px; }
.cd-badges { font-size: 11px; color: #ffca28; font-weight: 700; letter-spacing: .5px; }
.cd-badge.g { color: #69f0ae; } .cd-badge.r { color: #ff8a80; }
.cd-info { background: #fff; border-radius: 0 0 10px 10px; padding: 8px 14px; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.cd-row { padding: 7px 0; border-bottom: 1px solid #f0f0f0; font-size: 12.5px; }
.cd-row span { color: #78909c; display: block; font-size: 11px; }
.cd-row b { color: var(--dark); word-break: break-word; }
.cd-right { flex: 1; min-width: 0; }
.cd-tops { display: flex; gap: 16px; align-items: center; background: #fff; border-radius: 10px; padding: 14px 18px; box-shadow: 0 1px 4px rgba(0,0,0,.08); margin-bottom: 12px; flex-wrap: wrap; }
.ringbox { text-align: center; }
.ring { width: 74px; height: 74px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.ring-in { width: 58px; height: 58px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; }
.ring-lbl { font-size: 11.5px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.cd-stat { text-align: center; min-width: 80px; }
.cd-stat b { display: block; font-size: 20px; }
.cd-stat span { font-size: 11px; color: var(--muted); }
.cd-tabs { display: flex; gap: 2px; background: var(--dark2); border-radius: 8px 8px 0 0; overflow-x: auto; }
.cd-tab { background: none; border: none; color: #b0bec5; padding: 11px 14px; cursor: pointer; font-size: 12.5px; font-weight: 700; white-space: nowrap; border-bottom: 3px solid transparent; }
.cd-tab.active { color: #fff; background: rgba(255,255,255,.08); border-bottom-color: var(--orange); }
.cd-pane { display: none; background: #fff; border-radius: 0 0 10px 10px; padding: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.cd-pane.active { display: block; }
.conn-card { border: 1px solid #e0e0e0; border-radius: 10px; overflow: hidden; }
.conn-head { display: flex; align-items: center; gap: 10px; background: #f5f7f8; padding: 10px 14px; }
.conn-num { background: var(--orange); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; }
.conn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; padding: 14px; }
.conn-grid span { display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
.conn-grid b { font-size: 13px; }
.conn-amounts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; padding: 12px 14px; background: #fafafa; border-top: 1px solid #eee; }
.conn-amounts span { display: block; font-size: 10.5px; color: var(--muted); font-weight: 700; }
.conn-pkg { margin: 0; }
.conn-pkg th { font-size: 11px; }
@media (max-width: 900px) { .cd-wrap { flex-direction: column; } .cd-left { width: 100%; } }

@media print {
  body * { visibility: hidden; }
  #modalBox, #modalBox * { visibility: visible; }
  #modalBox { position: fixed; inset: 0; max-width: none; box-shadow: none; }
  .modal-actions { display: none !important; }
}

/* ---------- Mobile (phone) layout ---------- */
.menu-btn, .bottom-nav, .sidebar-backdrop, .mobile-only { display: none; }
.cust-cards .ccard { background: #fff; border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.cust-cards .ccard .ct { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cust-cards .ccard .cn { font-weight: 700; font-size: 15px; }
.cust-cards .ccard .cs { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cust-cards .ccard .cdue { font-weight: 800; font-size: 16px; white-space: nowrap; }
.cust-cards .ccard .cb { display: flex; gap: 8px; margin-top: 10px; }
.cust-cards .ccard .cb .btn { flex: 1; text-align: center; padding: 11px 8px; font-size: 14px; }
.cust-cards .ccard .cb .btn-ghost { flex: 0 0 auto; }
.cust-cards .ccard .cb .btn-green { flex: 0 0 auto; }
@media (max-width: 760px) {
  body { font-size: 15px; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .menu-btn { display: inline-block; background: none; border: none; font-size: 24px; padding: 4px 8px; cursor: pointer; color: var(--dark); }
  .brand { font-size: 14px; flex: 1; }
  .topbar-right { margin-left: 0; gap: 6px; }
  .topbar-right .btn, .topbar-right .admin-chip, .topbar-right .fy { display: none; }
  .company-select { order: 5; flex: 1 1 100%; max-width: none; font-size: 14px; padding: 10px; }
  .global-search { order: 6; display: block; flex: 1 1 100%; max-width: none; font-size: 15px; padding: 11px 14px; }
  .layout { min-height: auto; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 240px; z-index: 60; transform: translateX(-100%); transition: transform .2s; overflow-y: auto; padding-top: 16px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; }
  .nav-item { padding: 14px 18px; font-size: 15px; }
  .mobile-only { display: flex; }
  .content { padding: 12px 10px 78px; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid #ddd; z-index: 50; box-shadow: 0 -2px 8px rgba(0,0,0,.08); }
  .bottom-nav a { flex: 1; text-align: center; padding: 7px 2px 6px; font-size: 11px; color: var(--muted); cursor: pointer; text-decoration: none; font-weight: 600; }
  .bottom-nav a i { display: block; font-style: normal; font-size: 20px; line-height: 1.2; }
  .bottom-nav a.active { color: var(--orange); }
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; min-height: 80px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 10px; }
  .stat-icon { font-size: 16px; top: 8px; right: 8px; }
  .mini-cards { gap: 8px; }
  .mini-card { flex: 1 1 calc(50% - 8px); min-width: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-head h2 { font-size: 17px; }
  .page-actions { flex-wrap: wrap; }
  .filters input[type="text"] { min-width: 0; width: 100%; }
  .filters select, .filters label { flex: 1 1 45%; }
  .filters input, .filters select { font-size: 14px; padding: 10px; }
  .btn { padding: 10px 14px; font-size: 14px; }
  .btn-sm { padding: 8px 10px; font-size: 13px; }
  .modal { max-width: 100%; width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 12px 12px 0 0; }
  .modal-back { align-items: flex-end; }
  .modal .row { grid-template-columns: 1fr; }
  .modal input, .modal select, .modal textarea { font-size: 16px; padding: 11px; }
  table th, table td { padding: 8px 8px; font-size: 13px; }
  .filter-info { flex-wrap: wrap; }
  .cd-wrap { flex-direction: column; }
}
.more-row { text-align: center; padding: 10px; }

.perm-sec { margin: 12px 0; padding: 10px 12px; background: #f7f9fa; border-radius: 8px; }
.perm-sec > b { display: block; margin-bottom: 6px; font-size: 13px; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.perm-grid.small { grid-template-columns: repeat(3, 1fr); max-height: 180px; overflow-y: auto; }
.perm-grid .chk { margin: 0 !important; font-size: 12.5px; }
@media (max-width: 760px) { .perm-grid, .perm-grid.small { grid-template-columns: 1fr; } }

/* search + offline */
.gsearch-wrap { flex: 1; display: flex; gap: 6px; max-width: 560px; align-items: center; }
.gsearch-wrap .global-search { flex: 1; max-width: none; order: 0 !important; }
.gsearch-btn { order: 1; }
.gsearch-btn { white-space: nowrap; padding: 9px 14px; }
.psearch { display: flex; gap: 6px; align-items: center; margin: -6px 0 12px; }
.psearch input { flex: 1; max-width: 420px; padding: 9px 12px; border: 1px solid #cfd8dc; border-radius: 20px; background: #fff; font-size: 13.5px; }
.psearch small { color: var(--muted); }
.offline-badge { background: #ff9800; color: #fff; font-size: 11.5px; font-weight: 700; padding: 5px 10px; border-radius: 14px; cursor: pointer; white-space: nowrap; }
.offline-badge.off { background: #e53935; }
@media (max-width: 760px) {
  .gsearch-wrap { order: 6; flex: 1 1 100%; max-width: none; }
  .gsearch-btn { padding: 11px 12px; font-size: 14px; }
  .psearch input { max-width: none; font-size: 15px; padding: 10px 12px; }
  .offline-badge { order: 7; flex: 1 1 100%; text-align: center; }
}
