/* ============================================================
   Money Tracker — styles
   ============================================================ */

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --green: #059669;
  --green-light: #ecfdf5;
  --red: #e11d48;
  --red-light: #fff1f2;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #1e293b;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.15);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ============ App layout ============ */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============ Sidebar ============ */
.sidebar {
  width: 250px;
  min-width: 250px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.brand-icon {
  font-size: 30px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

.brand-title {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-subtitle {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.brand-logo {
  width: 150px;
  height: auto;
  border-radius: 8px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

/* ============ Language toggle ============ */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  margin: 10px auto 0;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.lang-toggle:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.lang-toggle:active {
  transform: scale(0.97);
}

.lang-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* The sidebar brand stacks the logo and the toggle button */
.brand {
  flex-direction: column;
}

/* Mobile top bar variant: the top bar is light, so invert the toggle colours */
.mobile-topbar .lang-toggle {
  margin: 0;
  color: var(--primary);
  background: var(--primary-light);
  border-color: rgba(79, 70, 229, 0.3);
}

.mobile-topbar .lang-toggle:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Bengali typography: give the Bengali glyphs a font that renders them well */
body.lang-bn {
  font-family: "Noto Sans Bengali", "Hind Siliguri", "Nirmala UI", "SolaimanLipi",
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 24px;
  flex: 1;
  overflow-y: auto;
}

.nav-group {
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 14.5px;
  font-weight: 600;
  border-radius: 10px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  width: 100%;
}

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

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--primary);
}

.nav-icon { font-size: 18px; }

.nav-group-label { flex: 1; }

.nav-chevron {
  font-size: 12px;
  transition: transform 0.2s;
  color: #94a3b8;
}

.nav-group-toggle.active .nav-chevron {
  transform: rotate(180deg);
}

.nav-submenu {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 6px 20px;
  margin-left: 4px;
  border-left: 1px solid rgba(148, 163, 184, 0.15);
}

.nav-submenu.open {
  display: flex;
}

.nav-subitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 8px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

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

.nav-subitem.active {
  background: rgba(79, 70, 229, 0.18);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar-footer {
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  padding-top: 16px;
}

.storage-badge {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  padding: 6px 12px;
  border-radius: 999px;
}

.storage-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

.version {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 10px;
  padding-left: 4px;
}

/* ============ Main ============ */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
}

.view { display: none; animation: fadeIn 0.25s ease; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view-header {
  margin-bottom: 24px;
}

.view-header h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.view-subtext {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-top: 4px;
}

.dashboard-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}

/* ============ Dashboard cards ============ */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.today-card .card-icon         { background: var(--green-light); }
.today-expense-card .card-icon { background: var(--red-light); }
.cash-card .card-icon          { background: var(--amber-light); }
.month-income-card .card-icon  { background: var(--green-light); }
.month-expense-card .card-icon { background: var(--red-light); }
.month-profit-card .card-icon  { background: var(--primary-light); }

.card-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.card-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -0.4px;
}

.today-card .card-value         { color: var(--green); }
.today-expense-card .card-value { color: var(--red); }
.month-income-card .card-value  { color: var(--green); }
.month-expense-card .card-value { color: var(--red); }
.month-profit-card .card-value  { color: var(--primary); }

#cash-in-hand { color: var(--text); }
#cash-in-hand.positive { color: var(--green); }
#cash-in-hand.negative { color: var(--red); }

#monthly-profit { color: var(--text); }
#monthly-profit.positive { color: var(--green); }
#monthly-profit.negative { color: var(--red); }

/* ============ Recent panel ============ */
.recent-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.panel-header h3 { font-size: 16px; font-weight: 600; }

.recent-list {
  max-height: 380px;
  overflow-y: auto;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: #f8fafc; }

.recent-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.recent-icon.income  { background: var(--green-light); }
.recent-icon.expense { background: var(--red-light); }

.recent-main { flex: 1; min-width: 0; }

.recent-title {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.recent-amount {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.recent-amount.income  { color: var(--green); }
.recent-amount.expense { color: var(--red); }

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

.empty-state .empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ============ Login screen ============ */
.login-container {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 300;
  padding: 20px;
}

.login-container::before {
  display: none;
}

.login-container > * {
  position: relative;
  z-index: 2;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  border: 1px solid #e2e8f0;
  padding: 42px 36px;
  width: 100%;
  max-width: 400px;
  animation: fadeIn 0.3s ease;
}

.login-developer {
  text-align: right;
  margin-top: 10px;
  color: #000000;
  font-weight: bold;
  font-size: 13px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  width: 80px !important;
  height: 80px !important;
  border-radius: 8px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  background: transparent !important;
  mix-blend-mode: multiply !important;
}

.login-title {
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  margin-top: 10px;
  text-align: center;
  letter-spacing: -0.2px;
}

.login-card .form-group {
  margin-bottom: 18px;
}

.login-card label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.login-card input {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-card input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.btn-login-green {
  background: #10b981;
  color: #ffffff;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  width: 100%;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-login-green:hover {
  background: #059669;
}

.btn-login-green:active {
  transform: scale(0.99);
}

.btn-login-green:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

/* ============ Sidebar user + logout ============ */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  margin-bottom: 10px;
}

.sidebar-user-icon {
  font-size: 18px;
}

.sidebar-user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .role-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.role-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.role-badge.edit      { background: var(--green-light); color: var(--green); }
.role-badge.view-only { background: var(--amber-light); color: var(--amber); }
.role-badge.admin     { background: var(--primary-light); color: var(--primary); }

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: rgba(225, 29, 72, 0.15);
  color: #fda4af;
  border: 1px solid rgba(225, 29, 72, 0.35);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-logout:hover {
  background: rgba(225, 29, 72, 0.28);
  color: #fff;
  border-color: rgba(225, 29, 72, 0.6);
}

.btn-logout .nav-icon {
  font-size: 16px;
}

/* ============ Buttons ============ */
.btn {
  border: none;
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

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

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: 7px;
}

/* ============ Forms ============ */
.form-centered {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.form-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  max-width: 720px;
  width: 100%;
}

.form-row {
  margin-bottom: 20px;
}

.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ============ Single-column transaction form with Income/Expense toggle ============ */
.transaction-card {
  max-width: 620px;
}

.transaction-mode-toggle {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.mode-toggle-btn {
  flex: 1;
  padding: 12px 0;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}

.mode-toggle-btn.income.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.mode-toggle-btn.expense.active {
  background: var(--red);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.15);
}

.mode-toggle-btn:not(.active) {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  opacity: 0.75;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}

.form-group .optional {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

.form-group input[type="date"],
.form-group input[type="number"],
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14.5px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-group input[readonly] {
  background: #f8fafc;
  color: var(--text-muted);
  cursor: default;
  border-color: var(--border);
}

.form-group input[readonly]:focus {
  border-color: var(--border);
  box-shadow: none;
}

/* Type toggle */
.type-toggle {
  display: flex;
  gap: 12px;
}

.type-toggle input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-btn {
  flex: 1;
  text-align: center;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: #fff;
  transition: all 0.15s;
  cursor: pointer;
}

.type-btn.income:hover  { border-color: var(--green); color: var(--green); background: var(--green-light); }
.type-btn.expense:hover { border-color: var(--red);   color: var(--red);   background: var(--red-light); }

#type-income:checked + .type-btn.income {
  border-color: var(--green);
  background: var(--green-light);
  color: var(--green);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

#type-expense:checked + .type-btn.expense {
  border-color: var(--red);
  background: var(--red-light);
  color: var(--red);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.1);
}

.form-error {
  display: none;
  background: var(--red-light);
  color: var(--red);
  border: 1px solid #fecdd3;
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 18px;
}

.form-error.visible { display: block; }

.form-success {
  display: none;
  background: var(--green-light);
  color: var(--green);
  border: 1px solid #a7f3d0;
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 18px;
}

.form-success.visible { display: block; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

/* ============ Autocomplete (Product search) ============ */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  max-height: 260px;
  overflow-y: auto;
  z-index: 50;
}

.autocomplete-dropdown.visible {
  display: block;
}

.autocomplete-item {
  padding: 11px 14px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: var(--primary-light);
  color: var(--primary);
}

.autocomplete-item.disabled {
  color: var(--text-muted);
  cursor: default;
  text-align: center;
  font-style: italic;
}

/* ============ History table ============ */
.nowrap {
  white-space: nowrap;
}

/* History tabs (All / Income / Expense) */
.history-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.history-tab {
  padding: 10px 22px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.history-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.history-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.history-tab-panel .table-wrapper {
  margin-bottom: 0;
}

/* History summary cards */
.history-summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 22px;
}

.history-summary-cards.single-card {
  grid-template-columns: 1fr;
}

.summary-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.summary-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.summary-income .summary-card-icon  { background: var(--green-light); }
.summary-expense .summary-card-icon { background: var(--red-light); }
.summary-balance .summary-card-icon { background: var(--amber-light); }
.summary-profit .summary-card-icon  { background: var(--primary-light); }

.summary-card-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.summary-card-value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}

.summary-income .summary-card-value  { color: var(--green); }
.summary-expense .summary-card-value { color: var(--red); }
.summary-balance .summary-card-value { color: var(--text); }
.summary-profit .summary-card-value  { color: var(--primary); }

@media (max-width: 1100px) {
  .history-summary-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .history-summary-cards { grid-template-columns: 1fr; }
}

.history-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 280px;
  flex-wrap: wrap;
}

.filter-group input,
.filter-group select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13.5px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-group input { flex: 1; min-width: 180px; }
.filter-group select { min-width: 140px; }

.filter-group input:focus,
.filter-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.table-wrapper {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 520px;
  width: 100%;
}

.report-table-card .table-wrapper {
  border: none;
  box-shadow: none;
  border-radius: 0;
  max-height: none;
  background: transparent;
}

.transactions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.transactions-table thead {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

.transactions-table th {
  text-align: left;
  padding: 13px 18px;
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

/* History table: compact data cells */
#view-history .transactions-table td {
  font-size: 13px;
  padding: 8px 12px;
}

/* Keep Unit Price / Total / Profit columns on a single line */
.transactions-table th.nowrap,
.transactions-table td.nowrap {
  white-space: nowrap !important;
}

/* Table footer totals */
.transactions-table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  background: #f8fafc;
  white-space: nowrap;
}

.transactions-table tbody tr:last-child td { border-bottom: none; }
.transactions-table tbody tr:hover { background: #f8fafc; }

.transactions-table th.right,
.transactions-table td.right { text-align: right; }

.transactions-table th.center,
.transactions-table td.center { text-align: center; }

.type-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.type-badge.income  { background: var(--green-light); color: var(--green); }
.type-badge.expense { background: var(--red-light);   color: var(--red); }

.amount-cell {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.amount-cell.income  { color: var(--green); }
.amount-cell.expense { color: var(--red); }

.profit-cell {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#sales-total-profit {
  margin-left: 20px;
}

.actions-cell {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.action-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 7px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
}

.action-btn:hover { transform: translateY(-1px); }

.action-btn.edit { color: var(--primary); }
.action-btn.edit:hover { border-color: var(--primary); background: var(--primary-light); }

.action-btn.delete { color: var(--red); }
.action-btn.delete:hover { border-color: var(--red); background: var(--red-light); }

.admin-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--primary-light);
  color: var(--primary);
}

/* Disabled buttons for View-Only role */
button.btn.disabled,
button.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.4);
  transform: none !important;
}

button.btn.disabled:hover,
button.btn:disabled:hover {
  transform: none !important;
  box-shadow: none !important;
  background: inherit !important;
}

.history-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.history-summary {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ============ Daily Report ============ */
#daily-report-section {
  padding: 0;
  animation: fadeIn 0.25s ease;
}

.report-header {
  margin-bottom: 24px;
}

.report-header h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.report-subtitle {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-top: 4px;
}

.report-filter-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 22px 24px;
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.report-filter-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.report-filter-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.report-date-input {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14.5px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.report-date-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.report-search-btn {
  padding: 11px 26px;
}

.report-previous-balance {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

.report-table-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.report-table thead {
  background: #f8fafc;
}

.report-table th {
  text-align: left;
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.report-table th.amount-header {
  text-align: right;
}

.report-table td {
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: left;
  font-size: 0.85rem;
}

.report-table td.amount-cell {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

.report-table td.amount-cell.income  { color: var(--green); }
.report-table td.amount-cell.expense { color: var(--red); }

.report-table tbody tr:last-child td {
  border-bottom: none;
}

.report-table tbody tr:hover {
  background: #f8fafc;
}

.report-type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
  letter-spacing: 0.3px;
}

.report-type-badge.income  { background: var(--green-light); color: var(--green); }
.report-type-badge.expense { background: var(--red-light);   color: var(--red); }

.report-empty-row .empty-state {
  text-align: center;
  padding: 20px 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============ Daily Report — 2-Column Layout ============ */
.report-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-bottom: 24px;
}

.report-column {
  min-width: 0;
}

.report-column-income {
  padding-right: 24px;
  border-right: 2px solid var(--red);
}

.report-column-expense {
  padding-left: 24px;
}

.report-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.report-column-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.report-table-card-column {
  margin-bottom: 14px;
}

.report-table-column {
  margin-bottom: 0;
}

.report-column-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.report-column-total.income-total {
  color: var(--green);
}

.report-column-total.expense-total {
  color: var(--red);
}

.report-summary-boxes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.report-summary-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-align: center;
}

.report-summary-box.total-box {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.report-summary-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: -0.1px;
}

.report-summary-amount {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  background: var(--primary-light);
  padding: 8px 20px;
  border-radius: 10px;
  display: inline-block;
}

.report-summary-box.total-box .report-summary-amount {
  color: #1e293b;
  background: #e2e8f0;
}

/* ============ Inventory ============ */
/* Redesigned product form — soft borders, elegant shadows, modern grid */
.product-form-card {
  max-width: 640px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 34px 36px;
  background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
  box-shadow: 0 4px 6px rgba(15, 23, 42, 0.03), 0 18px 40px rgba(79, 70, 229, 0.08);
}

.product-form-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.product-form-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary-light), #e0e7ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.18);
  flex-shrink: 0;
}

.product-form-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
}

.product-form-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.product-grid {
  margin-bottom: 20px;
}

.product-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.product-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}

.product-field input {
  width: 100%;
  padding: 12px 15px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  font-size: 14.5px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.product-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
  background: #fff;
}

.product-field input::placeholder {
  color: #cbd5e1;
}

@media (max-width: 720px) {
  .product-grid-2 { grid-template-columns: 1fr; gap: 14px; }
}

.form-section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

.inventory-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 24px;
  overflow: hidden;
}

.inventory-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.inventory-panel .panel-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.inventory-panel .table-wrapper {
  max-height: 420px;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.inventory-panel .history-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  margin-top: 0;
}

.stock-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  min-width: 60px;
}

.stock-badge.in-stock {
  background: var(--green-light);
  color: var(--green);
}

.stock-badge.low-stock {
  background: var(--amber-light);
  color: var(--amber);
}

.stock-badge.out-of-stock {
  background: var(--red-light);
  color: var(--red);
}

/* ============ Sale summary ============ */
.sale-summary {
  background: linear-gradient(180deg, #f8fafc, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 18px;
}

.sale-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--text-muted);
  padding: 6px 0;
}

.sale-summary-row span:last-child {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Interactive Selling Price input inside the summary */
.sale-price-input {
  width: 160px !important;
  padding: 8px 12px;
  border: 1.5px solid var(--primary) !important;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 700;
  text-align: right;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sale-price-input:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.sale-summary-row.total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 10px;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
}

.sale-summary-row.profit span:last-child {
  color: var(--green);
  font-weight: 700;
}

.sale-summary-row.total.profit {
  font-size: 16.5px;
}

.sale-summary-row.total.profit span:last-child {
  color: var(--green);
  font-size: 16.5px;
}

/* History Profit column */
.text-muted {
  color: var(--text-muted);
}

/* ============ Invoice ============ */
.invoice-container {
  display: none;
  justify-content: center;
  align-items: center;
  padding: 30px 0;
  width: 100%;
}

.invoice-container.visible {
  display: flex;
}

.invoice-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 36px 40px;
  width: 100%;
  max-width: 520px;
}

.invoice-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.invoice-shop-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.invoice-shop-name {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.4px;
}

.invoice-shop-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.invoice-line {
  border-top: 2px dashed var(--border);
  margin: 16px 0;
}

.invoice-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 14.5px;
}

.invoice-row span:first-child {
  color: var(--text-muted);
  font-weight: 500;
}

.invoice-row span:last-child {
  font-weight: 600;
  color: var(--text);
}

.invoice-row.profit-row span:last-child {
  color: var(--green);
  font-weight: 700;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.invoice-table th {
  text-align: left;
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.invoice-table th.center,
.invoice-table td.center { text-align: center; }

.invoice-table th.right,
.invoice-table td.right { text-align: right; }

.invoice-table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.invoice-grand-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  padding: 6px 0;
}

.invoice-grand-total span:last-child {
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.invoice-footer-note {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 20px;
  font-style: italic;
}

.invoice-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

/* ============ Print Styles & A4 Formatting ============ */
.print-only {
  display: none !important;
}

/* ============ Print Buttons ============ */
.btn-print {
  background: #0ea5e9;
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 2px 5px rgba(14, 165, 233, 0.2);
}

.btn-print:hover {
  background: #0284c7;
  box-shadow: 0 4px 10px rgba(14, 165, 233, 0.3);
}

.btn-print:active {
  transform: scale(0.98);
}

@page {
  size: A4 portrait;
  margin: 12mm 15mm 15mm 15mm;
}

@media print {
  /* Hide non-print chrome */
  .sidebar,
  .sidebar-overlay,
  .mobile-topbar,
  .nav,
  .brand,
  .sidebar-footer,
  .view-header,
  .report-header,
  .report-filter-card,
  .history-toolbar,
  .history-tabs,
  .history-footer,
  .dashboard-toolbar,
  .panel-header button,
  .invoice-actions,
  #toast-container,
  .modal-overlay,
  .btn,
  .btn-print,
  .print-btn,
  .history-actions-col,
  .actions-cell,
  .action-btn,
  .report-column-icon,
  .summary-card-icon,
  .summary-card svg,
  .summary-card img,
  .empty-icon,
  button {
    display: none !important;
    visibility: hidden !important;
  }

  /* Reveal print-only elements */
  .print-only {
    display: block !important;
  }

  /* Reset body and app layout for A4 print */
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12px !important;
    font-family: inherit !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Universal reset: remove thick borders, box-shadows, and border-radius */
  *,
  *::before,
  *::after {
    color: #000000 !important;
    background-color: transparent !important;
    box-shadow: none !important;
    text-shadow: none !important;
    border-radius: 0 !important;
  }

  /* Clean containers */
  .app,
  .main,
  .card,
  .panel,
  .stat-card,
  .table-wrapper,
  .report-table-card,
  .report-table-card-column {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: transparent !important;
  }

  /* Hide inactive views */
  .view:not(.active),
  .section[style*="display: none"],
  .section[style*="display:none"] {
    display: none !important;
  }

  /* Ensure company logo remains in color */
  img.print-logo,
  .print-logo {
    position: absolute !important;
    left: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 55px !important;
    height: 55px !important;
    object-fit: contain !important;
    mix-blend-mode: multiply !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Print Header */
  .print-header {
    display: block !important;
    position: relative !important;
    margin-bottom: 12px !important;
    padding-bottom: 0 !important;
    border: none !important;
  }

  .print-brand-row {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    min-height: 60px !important;
    margin-bottom: 6px !important;
  }

  .print-brand-info {
    text-align: center !important;
    width: 100% !important;
  }

  .print-company-name {
    font-size: 19px !important;
    font-weight: bold !important;
    color: #000000 !important;
    margin: 0 !important;
    line-height: 1.2 !important;
    letter-spacing: 1px !important;
    text-transform: uppercase !important;
  }

  .print-company-sub {
    font-size: 11px !important;
    color: #444444 !important;
    margin: 2px 0 0 0 !important;
    font-weight: normal !important;
  }

  .print-report-title {
    font-size: 13px !important;
    font-weight: bold !important;
    color: #000000 !important;
    margin: 6px 0 2px 0 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
  }

  .print-meta-details {
    font-size: 11px !important;
    color: #333333 !important;
    font-weight: normal !important;
  }

  hr.print-header-hr {
    display: block !important;
    border: none !important;
    border-top: 1px solid #333 !important;
    margin: 8px 0 14px 0 !important;
    width: 100% !important;
  }

  /* Two-column Daily and Monthly Reports */
  .report-columns {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
    margin-bottom: 14px !important;
    width: 100% !important;
  }

  .report-column-income {
    padding: 0 !important;
    border: none !important;
  }

  .report-column-expense {
    padding: 0 !important;
    border: none !important;
  }

  .report-column-header {
    margin-bottom: 6px !important;
  }

  .report-column-title {
    font-size: 12px !important;
    font-weight: bold !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    color: #000000 !important;
  }

  /* Table Redesign (Classic Accounting Standard) */
  table,
  table.transactions-table,
  table.report-table {
    width: 100% !important;
    border-collapse: collapse !important;
    border: none !important;
    font-size: 12px !important;
    margin: 0 !important;
  }

  table thead,
  table.transactions-table thead,
  table.report-table thead {
    display: table-header-group !important;
  }

  /* Table Headers: thin 1px solid #333 top and bottom, bold text */
  table th,
  table.transactions-table th,
  table.report-table th {
    border-top: 1px solid #333 !important;
    border-bottom: 1px solid #333 !important;
    border-left: none !important;
    border-right: none !important;
    padding: 6px 8px !important;
    color: #000000 !important;
    font-size: 12px !important;
    font-weight: bold !important;
    text-transform: uppercase !important;
    text-align: left !important;
    background: transparent !important;
  }

  /* Table Rows: faint 1px solid #eee bottom border, normal text */
  table td,
  table.transactions-table td,
  table.report-table td {
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid #eee !important;
    padding: 6px 8px !important;
    color: #000000 !important;
    font-size: 12px !important;
    font-weight: normal !important;
    text-align: left !important;
    background: transparent !important;
  }

  /* Alignment for numbers */
  th.right,
  th.amount-header,
  td.right,
  td.amount-cell {
    text-align: right !important;
  }

  tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Table footers: Totals inside the tables (bold with thin 1px solid #333 borders) */
  .report-tfoot,
  table tfoot,
  table.transactions-table tfoot,
  table.report-table tfoot {
    display: table-footer-group !important;
  }

  table tfoot tr,
  tr.report-total-row {
    border: none !important;
  }

  table tfoot th,
  table tfoot td,
  tr.report-total-row th,
  tr.report-total-row td {
    border-top: 1px solid #333 !important;
    border-bottom: 1px solid #333 !important;
    border-left: none !important;
    border-right: none !important;
    padding: 6px 8px !important;
    font-size: 12px !important;
    font-weight: bold !important;
    color: #000000 !important;
    text-transform: uppercase !important;
    background: transparent !important;
  }

  table tfoot th.right,
  table tfoot td.right,
  tr.report-total-row th.right,
  tr.report-total-row td.right {
    text-align: right !important;
  }

  /* Strictly hide original duplicate HTML summary cards for Income/Expense */
  .report-column-total,
  .report-column-total.income-total,
  .report-column-total.expense-total {
    display: none !important;
    visibility: hidden !important;
  }

  /* Summary Box (Cash in Hand): thin top border, max-width 350px, aligned right */
  .report-summary-boxes {
    display: block !important;
    max-width: 350px !important;
    margin-left: auto !important;
    margin-right: 0 !important;
    margin-top: 14px !important;
    margin-bottom: 20px !important;
    padding-top: 8px !important;
    border: none !important;
    border-top: 1px solid #333 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .report-summary-box {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    padding: 4px 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: transparent !important;
  }

  .report-summary-box.total-box {
    border: none !important;
    padding: 4px 0 !important;
    margin: 0 !important;
  }

  .report-summary-label {
    font-size: 12px !important;
    font-weight: normal !important;
    color: #000000 !important;
    text-align: left !important;
  }

  .report-summary-amount {
    font-size: 12px !important;
    font-weight: bold !important;
    color: #000000 !important;
    text-align: right !important;
  }

  /* History page summaries: evenly spaced, clean right-aligned summary block */
  .history-summary-cards,
  .history-summary-cards.single-card {
    display: flex !important;
    flex-direction: column !important;
    max-width: 350px !important;
    margin-left: auto !important;
    margin-right: 0 !important;
    margin-top: 14px !important;
    margin-bottom: 20px !important;
    padding-top: 8px !important;
    border: none !important;
    border-top: 1px solid #333 !important;
    gap: 6px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .summary-card {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    padding: 4px 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: transparent !important;
  }

  .summary-card-info {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
  }

  .summary-card-label {
    font-size: 12px !important;
    font-weight: normal !important;
    color: #000000 !important;
    margin: 0 !important;
    text-align: left !important;
  }

  .summary-card-value {
    font-size: 12px !important;
    font-weight: bold !important;
    color: #000000 !important;
    margin: 0 !important;
    text-align: right !important;
  }

  /* Print Footer & Signature Lines */
  .print-footer {
    margin-top: 60px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .print-signatures {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-end !important;
    margin-top: 0 !important;
    padding: 0 10px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .signature-block {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 170px !important;
    text-align: center !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .signature-line {
    width: 100% !important;
    border-top: 1px dotted #333 !important;
    margin-bottom: 8px !important;
  }

  .signature-label {
    font-size: 11px !important;
    font-weight: bold !important;
    color: #000000 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
  }

  .print-footer-info {
    display: flex !important;
    justify-content: space-between !important;
    font-size: 10px !important;
    color: #555555 !important;
    margin-top: 20px !important;
    padding-top: 6px !important;
    border-top: 1px solid #eee !important;
  }

  .print-footer-developer {
    color: #000000 !important;
    font-weight: bold !important;
    font-size: 10px !important;
    margin-top: 2px !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Invoice Receipt Support */
  .invoice-container {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .invoice-card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    max-width: 100% !important;
    padding: 20px !important;
  }
}

/* ============ Modal ============ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  width: 380px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.2s ease;
}

.modal h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.modal p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 22px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============ Toast ============ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 13px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s ease;
  max-width: 340px;
}

.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.fade-out {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
}

/* ============ Scrollbars ============ */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ============ Mobile Topbar & Hamburger ============ */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.mobile-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-hamburger {
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.btn-hamburger:hover,
.btn-hamburger:active {
  background: #e2e8f0;
  color: var(--primary);
}

.mobile-brand-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 4px;
  mix-blend-mode: multiply;
}

/* ============ Sidebar Overlay ============ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ============ History Date Filters ============ */
.history-date-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0 10px;
}

.history-date-filter label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.history-date-filter input[type="date"] {
  border: none !important;
  padding: 9px 4px !important;
  font-size: 13px !important;
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  min-width: unset !important;
  flex: unset !important;
  color: var(--text);
}

/* ============ Responsive Styles ============ */
@media (max-width: 768px) {
  .mobile-topbar {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 270px;
    min-width: 270px;
    max-width: 85vw;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .main {
    padding: 16px 12px;
    width: 100%;
    overflow-x: hidden;
  }

  .cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .dashboard-toolbar {
    justify-content: stretch;
  }

  .dashboard-toolbar .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .login-card {
    width: 90%;
    max-width: 400px;
    padding: 32px 20px;
    margin: 16px auto;
  }

  .form-card,
  .transaction-card {
    width: 100% !important;
    max-width: 100% !important;
    padding: 20px 16px !important;
    box-sizing: border-box;
  }

  .form-row.two-col {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .report-columns {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .report-column-income {
    padding-right: 0;
    border-right: none;
    margin-bottom: 8px;
  }

  .report-column-expense {
    padding-left: 0;
  }

  .report-filter-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px;
  }

  .report-filter-group {
    width: 100%;
  }

  .report-date-input {
    width: 100%;
    box-sizing: border-box;
  }

  .report-search-btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .report-previous-balance {
    width: 100%;
    justify-content: center;
    white-space: normal;
    text-align: center;
    box-sizing: border-box;
  }

  .report-summary-boxes {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .history-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 10px;
  }

  .filter-group input[type="text"] {
    width: 100%;
    box-sizing: border-box;
  }

  .history-date-filter {
    width: 100%;
    justify-content: space-between;
    box-sizing: border-box;
  }

  .history-tabs {
    flex-wrap: wrap;
    gap: 6px;
  }

  .history-tab {
    flex: 1;
    min-width: 100px;
    text-align: center;
    padding: 9px 10px;
    font-size: 13px;
  }

  .history-summary-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .btn-logout,
  .report-print-btn,
  .history-print-btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
}
