:root {
  --primary: #059669;
  --primary-dark: #065f46;
  --primary-darker: #064e3b;
  --primary-soft: #ecfdf5;
  --primary-border: #a7f3d0;

  --accent: #d97706;
  --accent-soft: #fffbeb;

  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;

  --info: #2563eb;
  --info-soft: #eff6ff;

  --indigo: #4f46e5;
  --indigo-soft: #eef2ff;

  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --text-light: #94a3b8;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 45px rgba(15, 23, 42, 0.16);

  --sidebar-width: 268px;
  --bottom-nav-height: 68px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Cairo', 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.num {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}

span.num, strong.num {
  display: inline-block;
}

td.num, th.num {
  display: table-cell;
  text-align: right;
  white-space: nowrap;
}

/* ===== Layout Shell ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Desktop Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--primary-darker) 0%, #053b2c 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 18px 16px 76px;
  overflow-y: auto;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 16px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #34d399, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.3rem;
  color: #fff;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.08rem;
  font-weight: 800;
  margin: 0;
  color: #fff;
  line-height: 1.25;
}

.brand-sub {
  font-size: 0.76rem;
  color: #a7f3d0;
  margin: 2px 0 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  text-align: right;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-btn.active {
  background: #ffffff;
  color: var(--primary-darker);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.nav-btn svg {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.live-clock-box {
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 9px 12px;
  text-align: center;
}

.clock-time {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fde68a;
  letter-spacing: 0.4px;
}

.clock-date {
  font-size: 0.74rem;
  color: #d1fae5;
  margin-top: 2px;
}

.time-sub {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
}

.install-pill {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 9px 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s;
}

.install-pill:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* Main Content Area */
.main-area {
  flex: 1;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Mobile Topbar */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 35;
  background: linear-gradient(135deg, var(--primary-darker), var(--primary-dark));
  color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 14px rgba(6, 78, 59, 0.22);
}

.mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-topbar .brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1rem;
}

.mobile-topbar h1 {
  font-size: 1rem;
  margin: 0;
  font-weight: 800;
}

.mobile-topbar p {
  font-size: 0.72rem;
  margin: 0;
  color: #a7f3d0;
}

.page-container {
  padding: 24px 28px 96px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
}

/* Sample Banner */
.sample-banner {
  background: var(--accent-soft);
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
}

.sample-banner strong {
  font-weight: 800;
}

/* Page Header */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
}

.page-subtitle {
  margin: 2px 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 11px;
  font-weight: 700;
  font-size: 0.9rem;
  transition: all 0.18s ease;
  white-space: nowrap;
  min-height: 42px;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.25);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-alt);
  border-color: #cbd5e1;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.btn-danger-soft:hover {
  background: #fee2e2;
}

.btn-indigo {
  background: var(--indigo);
  color: #fff;
}

.btn-indigo:hover {
  background: #4338ca;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  min-height: 34px;
  border-radius: 9px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  min-height: 36px;
  border-radius: 9px;
}

/* Filter Bar */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-group label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.18s, box-shadow 0.18s;
  min-height: 42px;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.14);
}

.select-compact {
  width: auto;
  min-width: 120px;
  padding: 7px 12px;
  min-height: 38px;
  font-weight: 600;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.kpi-card.hero {
  background: linear-gradient(135deg, var(--primary-darker), var(--primary));
  color: #fff;
  border: none;
  box-shadow: 0 10px 24px rgba(5, 150, 105, 0.25);
}

.kpi-card.hero.loss {
  background: linear-gradient(135deg, #991b1b, #dc2626);
  box-shadow: 0 10px 24px rgba(220, 38, 38, 0.25);
}

.kpi-label {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-card.hero .kpi-label {
  color: rgba(255, 255, 255, 0.88);
}

.kpi-value {
  font-size: 1.42rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
}

.kpi-card.hero .kpi-value {
  color: #fff;
  font-size: 1.55rem;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.kpi-card.hero .kpi-sub {
  color: rgba(255, 255, 255, 0.82);
}

.text-profit { color: var(--primary-dark) !important; }
.text-loss { color: var(--danger) !important; }
.text-indigo { color: var(--indigo) !important; }
.text-accent { color: var(--accent) !important; }

/* Cards & Sections */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  overflow: hidden;
}

.card-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 18px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-sale, .badge-paid {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: 1px solid var(--primary-border);
}

.badge-purchase, .badge-unpaid {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge-partial, .badge-warn {
  background: var(--accent-soft);
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-info {
  background: var(--info-soft);
  color: var(--info);
}

/* Supermarkets Cards Grid */
.sm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

.sm-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sm-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.sm-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.sm-name {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text);
}

.sm-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.sm-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--surface-alt);
  padding: 10px;
  border-radius: 12px;
}

.sm-metric {
  text-align: center;
}

.sm-metric-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
}

.sm-metric-val {
  font-size: 0.88rem;
  font-weight: 800;
  margin-top: 2px;
}

.sm-card-actions {
  display: flex;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.sm-card-actions .btn {
  flex: 1;
}

/* Profit Bar Chart */
.bar-row {
  margin-bottom: 14px;
}

.bar-row:last-child {
  margin-bottom: 0;
}

.bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 5px;
  gap: 8px;
}

.bar-track {
  width: 100%;
  height: 11px;
  background: #edf2f7;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #34d399);
  transition: width 0.35s ease;
}

.bar-fill.negative {
  background: linear-gradient(90deg, #dc2626, #f87171);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 800;
  text-align: right;
  padding: 11px 12px;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #f9fbfa;
}

/* Month Strip for Payroll */
.months-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.month-pill {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 9px 6px;
  text-align: center;
  font-weight: 700;
  font-size: 0.83rem;
  color: var(--text-muted);
  transition: all 0.16s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.month-pill:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.month-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.28);
}

.month-pill .m-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cbd5e1;
}

.month-pill.has-paid .m-dot { background: #10b981; }
.month-pill.active .m-dot { background: #ffffff; }

/* Employee Payroll Card */
.payroll-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.emp-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  box-shadow: var(--shadow-sm);
}

.emp-card.status-paid { border-right: 4px solid var(--primary); }
.emp-card.status-partial { border-right: 4px solid var(--accent); }
.emp-card.status-unpaid { border-right: 4px solid var(--danger); }

.emp-nums {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: var(--surface-alt);
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 0.83rem;
}

.emp-num-item {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

/* Annual Matrix */
.matrix-cell {
  text-align: center !important;
  padding: 7px 6px !important;
  font-size: 0.76rem;
  min-width: 74px;
  cursor: pointer;
}

.matrix-pill {
  display: inline-block;
  padding: 4px 7px;
  border-radius: 8px;
  font-weight: 700;
  width: 100%;
}

.matrix-pill.paid { background: var(--primary-soft); color: var(--primary-dark); }
.matrix-pill.partial { background: var(--accent-soft); color: #b45309; }
.matrix-pill.unpaid { background: #f1f5f9; color: #94a3b8; }

/* Tabs */
.tabs {
  display: inline-flex;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.tab-btn {
  padding: 8px 16px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-muted);
  transition: all 0.16s;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary-darker);
  box-shadow: var(--shadow-sm);
}

/* Calculator */
.calc-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
}

.calc-display-box {
  background: #0f172a;
  color: #fff;
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 14px;
  direction: ltr;
  text-align: right;
}

.calc-expr-input {
  width: 100%;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.08rem;
  text-align: right;
  outline: none;
  margin-bottom: 6px;
  font-family: 'Segoe UI', monospace;
}

.calc-result-val {
  font-size: 2rem;
  font-weight: 800;
  color: #34d399;
  min-height: 44px;
  word-break: break-all;
}

.calc-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  direction: ltr;
}

.calc-key {
  min-height: 52px;
  border-radius: 12px;
  font-size: 1.15rem;
  font-weight: 800;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  transition: all 0.12s;
}

.calc-key:active {
  transform: scale(0.96);
}

.calc-key.op {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: var(--primary-border);
}

.calc-key.eq {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.calc-key.clr {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

.live-calc-box {
  background: var(--primary-soft);
  border: 1.5px solid var(--primary-border);
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
}

.live-calc-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  padding: 4px 0;
}

.live-calc-row.grand {
  border-top: 1.5px dashed var(--primary-border);
  margin-top: 6px;
  padding-top: 8px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary-darker);
}

/* Forms & Modals */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  background: var(--surface);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 0.18s ease-out;
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-alt);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(90px);
  background: #0f172a;
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Mobile Bottom Nav */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
  grid-template-columns: repeat(5, 1fr);
}

.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 10px;
}

.bottom-nav-btn svg {
  width: 22px;
  height: 22px;
}

.bottom-nav-btn.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}

.empty-state h3 {
  margin: 10px 0 6px;
  color: var(--text);
}

.two-col {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 18px;
}

/* ===== Responsive Breakpoints (iPhone / Android / Tablet) ===== */
@media (max-width: 960px) {
  .sidebar {
    display: none;
  }
  .main-area {
    margin-right: 0;
  }
  .mobile-topbar {
    display: flex;
  }
  .bottom-nav {
    display: grid;
  }
  .page-container {
    padding: 16px 14px calc(var(--bottom-nav-height) + 84px + env(safe-area-inset-bottom));
  }
  .two-col, .calc-grid {
    grid-template-columns: 1fr;
  }
  .months-strip {
    grid-template-columns: repeat(4, 1fr);
  }
  .toast {
    bottom: calc(var(--bottom-nav-height) + 16px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 600px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .kpi-card.hero {
    grid-column: 1 / -1;
  }
  .kpi-value {
    font-size: 1.15rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .months-strip {
    grid-template-columns: repeat(3, 1fr);
  }
  .sm-grid, .payroll-list {
    grid-template-columns: 1fr;
  }
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal-dialog {
    border-radius: 22px 22px 0 0;
    max-height: 92vh;
  }
}

/* ===== Official Printable Master Invoice ===== */
.invoice-sheet {
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
}

.invoice-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 2.5px solid var(--primary-darker);
  margin-bottom: 20px;
}

.invoice-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.invoice-logo {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary-darker), var(--primary));
  color: #fff;
  font-size: 1.8rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.invoice-company {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--primary-darker);
}

.invoice-sub {
  margin: 2px 0 4px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.invoice-doc-type {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-darker);
  border: 1px solid var(--primary-border);
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 800;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.invoice-meta-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.84rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 240px;
}

.invoice-meta-box span {
  color: var(--text-muted);
}

.invoice-summary-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.inv-kpi {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inv-kpi span {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
}

.inv-kpi strong {
  font-size: 1rem;
  font-weight: 800;
}

.inv-kpi.highlight {
  background: var(--primary-darker);
  color: #fff;
  border-color: var(--primary-darker);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.inv-kpi.highlight.loss {
  background: #991b1b;
  border-color: #991b1b;
}

.inv-kpi.highlight span {
  color: rgba(255, 255, 255, 0.85);
}

.invoice-section {
  margin-bottom: 20px;
}

.invoice-section-title {
  margin: 0 0 10px;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--primary-darker);
  padding-right: 10px;
  border-right: 4px solid var(--primary);
}

.invoice-table th {
  background: #f1f5f9 !important;
  font-size: 0.82rem;
  padding: 9px 10px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.invoice-table td {
  font-size: 0.83rem;
  padding: 8px 10px;
}

.invoice-total-row {
  background: var(--primary-soft) !important;
  font-weight: 800;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.invoice-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.invoice-grand-box {
  background: var(--surface-alt);
  border: 2px solid var(--primary-border);
  border-radius: 14px;
  padding: 16px 20px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.invoice-eq-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  gap: 12px;
}

.invoice-eq-row.grand-final {
  background: var(--primary-darker);
  color: #fff;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 1.08rem;
  font-weight: 800;
  margin-top: 4px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.invoice-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
  text-align: center;
}

.sig-title {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 36px;
}

.sig-line {
  border-bottom: 1.5px solid #94a3b8;
  width: 80%;
  margin: 0 auto;
}

/* Annual Profit 12-Month Vertical Bar Chart */
.annual-bars-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
  align-items: end;
  height: 190px;
  padding-top: 14px;
}

.annual-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  gap: 5px;
}

.annual-bar-val {
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.annual-bar-track {
  flex: 1;
  width: 100%;
  max-width: 34px;
  background: #edf2f7;
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.annual-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, #10b981, #059669);
  border-radius: 8px 8px 0 0;
  transition: height 0.3s ease;
}

.annual-bar-fill.negative {
  background: linear-gradient(180deg, #f87171, #dc2626);
}

.annual-bar-lbl {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

@media (max-width: 960px) {
  .invoice-summary-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .inv-kpi.highlight {
    grid-column: 1 / -1;
  }
  .invoice-two-col {
    grid-template-columns: 1fr;
  }
  .invoice-sheet {
    padding: 16px;
  }
  .annual-bars-grid {
    overflow-x: auto;
    grid-template-columns: repeat(12, minmax(46px, 1fr));
  }
}

/* ===== Print Stylesheet ===== */
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }
  .sidebar, .mobile-topbar, .bottom-nav, .header-actions, .filter-bar, .sample-banner, .no-print {
    display: none !important;
  }
  .main-area {
    margin-right: 0 !important;
  }
  .page-container {
    padding: 0 !important;
    max-width: 100% !important;
  }
  .invoice-sheet {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .invoice-summary-strip {
    grid-template-columns: repeat(5, 1fr) !important;
  }
  .invoice-two-col {
    grid-template-columns: 1fr 1fr !important;
  }
  .card, .kpi-card, .invoice-section, .invoice-grand-box, .invoice-signatures {
    box-shadow: none !important;
    break-inside: avoid;
  }
  body {
    background: #fff !important;
    font-size: 11px !important;
  }
}
