/* ==========================================================================
   FGV Palm Industries Sdn. Bhd. - Treasury Unified Portal Styling
   Executive Modern Design System (Daily Cashflow + Month-End Balance)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Brand Corporate Colors */
  --slate-950: #070d1e;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;

  --primary: #1e3a8a;
  --primary-hover: #1d4ed8;
  --primary-dark: #172554;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;

  --emerald: #059669;
  --emerald-hover: #047857;
  --emerald-light: #ecfdf5;
  --emerald-border: #a7f3d0;
  --emerald-glow: rgba(5, 150, 105, 0.2);

  --rose: #e11d48;
  --rose-hover: #be123c;
  --rose-light: #fff1f2;
  --rose-border: #fecdd3;

  --amber: #d97706;
  --amber-light: #fffbeb;
  --amber-border: #fde68a;

  --sky: #0284c7;
  --sky-light: #f0f9ff;
  --sky-border: #bae6fd;

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

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.1);
  --shadow-xl: 0 20px 35px -8px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.18);

  /* Borders & Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;
}

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

body {
  font-family: var(--font-sans);
  background: #f8fafc;
  color: var(--slate-900);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ================= Header ================= */
.header {
  background: linear-gradient(135deg, var(--slate-950) 0%, #111e3b 50%, var(--slate-900) 100%);
  color: #ffffff;
  padding: 1.15rem 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.header-brand-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-logo-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.header-title-box h1 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.header-title-box p {
  font-size: 0.85rem;
  color: var(--slate-400);
  font-weight: 500;
  margin-top: 0.15rem;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  letter-spacing: 0.02em;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulse-dot 2s infinite ease-in-out;
}

.status-dot.test { background-color: #3b82f6; box-shadow: 0 0 10px #3b82f6; }
.status-dot.offline { background-color: #f59e0b; box-shadow: 0 0 10px #f59e0b; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.btn-lock {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-lock:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}

/* ================= Main Portal Navigation Tabs ================= */
.portal-nav {
  background: #ffffff;
  border-bottom: 1px solid var(--slate-200);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
  position: sticky;
  top: 76px;
  z-index: 40;
}

.portal-nav-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  padding: 0 2rem;
  gap: 0.75rem;
}

.portal-nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.95rem 1.4rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--slate-500);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.portal-nav-tab:hover {
  color: var(--primary);
  background: var(--slate-50);
}

.portal-nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
  font-weight: 700;
}

.portal-nav-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
}

/* ================= Main Container ================= */
.main-content {
  max-width: 1440px;
  margin: 2rem auto;
  padding: 0 2rem;
}

/* ================= Universal Buttons ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(30, 58, 138, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, #1d4ed8 100%);
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.35);
  transform: translateY(-1px);
}

.btn-save {
  background: linear-gradient(135deg, var(--emerald) 0%, #047857 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
}

.btn-save:hover {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.4);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--rose) 0%, #be123c 100%);
  color: #ffffff;
}

.btn-danger:hover {
  background: linear-gradient(135deg, var(--rose-hover) 0%, #9f1239 100%);
}

.btn-outline {
  background: #ffffff;
  color: var(--slate-700);
  border: 1px solid var(--slate-300);
  box-shadow: var(--shadow-xs);
}

.btn-outline:hover {
  background: var(--slate-50);
  border-color: var(--slate-400);
  color: var(--slate-900);
}

.add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

/* ================= Modern Control Toolbar ================= */
.toolbar-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1rem 1.4rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.daily-toolbar-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--slate-200);
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
}

.daily-toolbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.date-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.toolbar-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--slate-700);
  letter-spacing: 0.01em;
}

.date-nav-group {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  padding: 2px;
  box-shadow: var(--shadow-xs);
}

.btn-date-nav {
  background: transparent;
  border: none;
  color: var(--slate-600);
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.btn-date-nav:hover {
  background: var(--slate-100);
  color: var(--primary);
}

.modern-date-picker {
  border: none !important;
  font-family: var(--font-mono);
  font-size: 0.9rem !important;
  font-weight: 700;
  color: var(--slate-900);
  padding: 0.35rem 0.5rem !important;
  outline: none;
  background: transparent;
  cursor: pointer;
}

.btn-date-today {
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  color: var(--slate-700);
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-left: 2px;
  transition: all 0.15s;
}

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

/* Real-time Record Status Badges */
.record-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.25s ease;
}

.record-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.record-badge.found {
  background: var(--emerald-light);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
}
.record-badge.found .record-badge-dot {
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.record-badge.clean {
  background: var(--slate-100);
  color: var(--slate-600);
  border: 1px solid var(--slate-300);
}
.record-badge.clean .record-badge-dot {
  background: var(--slate-400);
}

.record-badge.checking {
  background: var(--amber-light);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}
.record-badge.checking .record-badge-dot {
  background: var(--amber);
  animation: pulse-dot 1.5s infinite ease-in-out;
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ================= Daily Cashflow Sub-Tabs ================= */
.daily-sub-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--slate-200);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.daily-sub-tab {
  padding: 0.75rem 1.4rem;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: 1px solid var(--slate-200);
  border-bottom: none;
  background-color: var(--slate-100);
  color: var(--slate-600);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  top: 2px;
}

.daily-sub-tab:hover {
  background-color: #ffffff;
  color: var(--primary);
}

.daily-sub-tab.active {
  background-color: #ffffff;
  color: var(--primary);
  font-weight: 700;
  border-color: var(--slate-300);
  border-bottom: 3px solid #ffffff;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
}

/* ================= Executive Account Hero Ribbon ================= */
.account-hero-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.6rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.account-hero-info {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.account-hero-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.account-hero-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -0.01em;
}

.account-hero-num {
  font-size: 0.85rem;
  color: var(--slate-500);
  font-weight: 500;
}

.account-hero-num span {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--slate-800);
  background: var(--slate-100);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.account-hero-metrics {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.hero-metric-item {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  min-width: 150px;
  box-shadow: var(--shadow-xs);
}

.hero-metric-item.highlight {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid var(--emerald-border);
  box-shadow: 0 4px 12px var(--emerald-glow);
}

.metric-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
  margin-bottom: 0.2rem;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--slate-900);
  font-variant-numeric: tabular-nums;
}

.metric-val.text-emerald { color: var(--emerald); }
.metric-val.text-rose { color: var(--rose); }

/* ================= Section Blocks & Report Tables ================= */
.section-block {
  margin-bottom: 1.75rem;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.2s ease;
}

.section-block:hover {
  box-shadow: 0 8px 25px -4px rgba(15, 23, 42, 0.07);
}

.section-bar {
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-bar.bar-sky {
  background: linear-gradient(90deg, #f0f9ff 0%, #ffffff 100%);
  border-bottom: 1px solid var(--sky-border);
  border-left: 4px solid var(--sky);
}

.section-bar.bar-amber {
  background: linear-gradient(90deg, #fffbeb 0%, #ffffff 100%);
  border-bottom: 1px solid var(--amber-border);
  border-left: 4px solid var(--amber);
}

.section-bar.bar-emerald {
  background: linear-gradient(90deg, #ecfdf5 0%, #ffffff 100%);
  border-bottom: 1px solid var(--emerald-border);
  border-left: 4px solid var(--emerald);
}

.section-bar.bar-indigo {
  background: linear-gradient(90deg, #eef2ff 0%, #ffffff 100%);
  border-bottom: 1px solid #c7d2fe;
  border-left: 4px solid var(--indigo);
}

.section-bar h2 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -0.01em;
}

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

.report-table th {
  background: var(--slate-900);
  color: #ffffff;
  font-weight: 600;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--slate-800);
  letter-spacing: 0.02em;
}

.report-table td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--slate-200);
  vertical-align: middle;
}

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

.report-table tr.section-total {
  background: #f1f5f9;
  font-weight: 700;
  border-top: 2px solid var(--slate-300);
}

.report-table tr.section-total td {
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
  color: var(--slate-900);
}

.row-input {
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  background: #ffffff;
  color: var(--slate-900);
  outline: none;
  transition: all 0.15s ease;
}

.row-input:focus {
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.less-dropdown {
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  background: #ffffff;
  color: var(--slate-800);
  outline: none;
  cursor: pointer;
}

/* ================= KPI Overview Cards (Month-End) ================= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, #3b82f6 100%);
}

.kpi-card-header {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
  margin-bottom: 0.35rem;
}

.kpi-card-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-card-value.emerald { color: var(--emerald); }
.kpi-card-value.rose { color: var(--rose); }

.kpi-subtext {
  font-size: 0.78rem;
  color: var(--slate-400);
  margin-top: 0.35rem;
}

/* ================= Month-End Data Table ================= */
.table-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
  overflow: hidden;
  margin-bottom: 2rem;
}

#treasury-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

#treasury-table th {
  background: var(--slate-900);
  color: #ffffff;
  font-weight: 600;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--slate-800);
  text-align: left;
}

#treasury-table td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--slate-200);
}

#treasury-table tbody tr:hover {
  background-color: #f8fafc;
}

.balance-input {
  width: 110px;
  text-align: right;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
}

.balance-input:focus {
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

tr.warning-row {
  background-color: #fff1f2 !important;
}

tr.warning-row td {
  color: var(--rose);
}

tr.warning-row .balance-input {
  color: var(--rose);
  border-color: var(--rose-border);
  background: #ffffff;
}

/* ================= Upcoming Payment Alert Banner ================= */
.reminder-banner {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
  border-left: 5px solid var(--amber);
  border-radius: var(--radius-md);
  padding: 1rem 1.4rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-xs);
}

.reminder-header {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 0.25rem;
}

.reminder-sub {
  font-size: 0.82rem;
  color: #a16207;
  margin-bottom: 0.6rem;
}

.reminder-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.reminder-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background: rgba(255, 255, 255, 0.75);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

/* ================= Lock Screen ================= */
.lock-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--slate-950) 0%, #0f1f3d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.lock-box {
  background: rgba(255, 255, 255, 0.98);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.lock-icon-circle {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1.25rem;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.lock-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--slate-900);
}

.lock-subtitle {
  font-size: 0.85rem;
  color: var(--slate-500);
  margin-top: 0.35rem;
  margin-bottom: 1.5rem;
}

.lock-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  outline: none;
  margin-bottom: 1rem;
  transition: all 0.2s;
  text-align: center;
  letter-spacing: 0.1em;
}

.lock-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

/* ================= Modals ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 1.5rem;
}

.modal-overlay.hidden { display: none; }

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  border: 1px solid var(--slate-200);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 0.5rem;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--slate-500);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.paste-area {
  width: 100%;
  height: 180px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  outline: none;
  margin-bottom: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ================= Toast Notification ================= */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--slate-900);
  color: #ffffff;
  padding: 0.85rem 1.4rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  z-index: 100;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { background: #064e3b; border-color: #059669; }
.toast.error { background: #881337; border-color: #e11d48; }

/* Utilities */
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.mb-2 { margin-bottom: 0.5rem; }
.text-sm { font-size: 0.875rem; }
.btn-block { width: 100%; }
.lock-error { color: var(--rose); font-size: 0.8rem; margin-bottom: 0.75rem; display: none; }

/* Print Media */
@media print {
  body { background: #ffffff; }
  .header, .portal-nav, .toolbar-card, .btn, .add-btn, .modal-overlay, .daily-sub-tabs, #reminder-banner, .toast { display: none !important; }
  .main-content { margin: 0; padding: 0; max-width: 100%; }
  .print-header { display: block !important; margin-bottom: 1.5rem; text-align: center; }
  .section-block { box-shadow: none; border: 1px solid #000000; page-break-inside: avoid; }
  .account-hero-card { border: 1px solid #000000; }
}


/* ==========================================================================
   RESPONSIVE MOBILE & TABLET STYLES
   ========================================================================== */

/* Strict Viewport Containment */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

#dashboard-app,
.header,
.portal-nav,
.main-content,
#module-daily-cashflow,
#module-month-end,
.daily-toolbar-card,
.account-hero-card,
.section-block,
.table-card {
  max-width: 100%;
  box-sizing: border-box;
}

/* Table Horizontal Scrolling Base Wrappers */
.section-block {
  width: 100%;
  overflow: hidden;
}

.section-block-body,
.section-block > div:not(.section-bar),
.table-card {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.report-table {
  min-width: 580px;
}

.investment-table {
  min-width: 860px;
}

#treasury-table {
  min-width: 850px;
}

/* Tablet & Smaller Laptops (<= 1024px) */
@media (max-width: 1024px) {
  .header-container {
    padding: 0 1rem;
    gap: 1rem;
  }
  .portal-nav-container,
  .main-content {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  .account-hero-card {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  .account-hero-metrics {
    justify-content: stretch;
  }
  .hero-metric-item {
    flex: 1;
    min-width: 0;
  }
}

/* Tablets & Mobile Screens (<= 768px) */
@media (max-width: 768px) {
  :root {
    --header-height: auto;
  }

  /* Header adjustments */
  .header {
    padding: 0.65rem 0;
    width: 100%;
  }
  .header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0 0.75rem;
    width: 100%;
  }
  .header-brand-wrap {
    justify-content: flex-start;
    width: 100%;
    gap: 0.65rem;
  }
  .header-logo-badge {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    flex-shrink: 0;
  }
  .header-title-box h1 {
    font-size: 1rem;
    line-height: 1.2;
  }
  .header-title-box p {
    font-size: 0.7rem;
  }
  .header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 0.5rem;
  }
  .header-controls .status-badge {
    font-size: 0.7rem;
    padding: 0.35rem 0.6rem;
  }
  .btn-lock {
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
  }

  /* Portal Nav Tabs - horizontal swipeable */
  .portal-nav-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    scrollbar-width: none;
    padding: 0 0.75rem 2px 0.75rem;
    display: flex;
    gap: 0.5rem;
    width: 100%;
  }
  .portal-nav-container::-webkit-scrollbar {
    display: none;
  }
  .portal-nav-tab {
    padding: 0.65rem 0.85rem;
    font-size: 0.82rem;
    flex-shrink: 0;
  }

  /* Main content padding */
  .main-content {
    padding: 0.85rem 0.65rem 3rem 0.65rem;
    width: 100%;
  }

  /* Month-End KPI Grid */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    margin-bottom: 1rem;
  }
  .kpi-card {
    padding: 0.75rem 0.85rem;
  }
  .kpi-card-header {
    font-size: 0.65rem;
  }
  .kpi-card-value {
    font-size: 1.15rem;
  }
  .kpi-subtext {
    font-size: 0.65rem;
  }

  /* Month-End Toolbar Card */
  .toolbar-card {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.75rem;
    width: 100%;
  }
  .toolbar-card .btn-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0.5rem;
  }
  .toolbar-card .btn-group > div {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 0.5rem;
    justify-content: space-between;
  }
  .period-dropdown {
    flex: 1;
    min-width: 100px;
    height: 38px;
    font-size: 0.85rem;
  }
  .toolbar-card .btn-group .btn {
    width: 100%;
    justify-content: center;
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
  }
  .search-box {
    width: 100%;
  }
  .search-input {
    width: 100%;
    height: 38px;
    font-size: 0.85rem;
  }

  /* Daily Cashflow Toolbar */
  .daily-toolbar-card {
    padding: 0.75rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    width: 100%;
  }
  .daily-toolbar-left {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0.65rem;
  }
  .date-selector-wrapper {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: 0.35rem;
  }
  .toolbar-label {
    font-size: 0.78rem;
    font-weight: 600;
  }
  .date-nav-group {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    padding: 2px;
  }
  .btn-date-nav {
    width: 36px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
  }
  .modern-date-picker {
    flex: 1;
    min-width: 0;
    width: 100%;
    height: 38px;
    font-size: 0.85rem !important;
    text-align: center;
    padding: 0 4px !important;
  }
  .btn-date-today {
    height: 38px;
    padding: 0 0.65rem;
    font-size: 0.78rem;
    flex-shrink: 0;
    white-space: nowrap;
  }
  .record-badge {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.65rem;
    font-size: 0.75rem;
    text-align: center;
  }
  .daily-toolbar-card .btn-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  .daily-toolbar-card .btn-group .btn {
    width: 100%;
    justify-content: center;
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
  }

  /* Daily Sub-tabs swipeable */
  .daily-sub-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    scrollbar-width: none;
    gap: 0.4rem;
    padding: 0 0.1rem 4px 0.1rem;
    margin-bottom: 0.85rem;
    width: 100%;
  }
  .daily-sub-tabs::-webkit-scrollbar {
    display: none;
  }
  .daily-sub-tab {
    flex-shrink: 0;
    padding: 0.55rem 0.85rem;
    font-size: 0.78rem;
  }

  /* Account Hero Card */
  .account-hero-card {
    padding: 0.85rem;
    margin-bottom: 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    width: 100%;
  }
  .account-hero-badge {
    font-size: 0.65rem;
  }
  .account-hero-title {
    font-size: 1.1rem;
  }
  .account-hero-num {
    font-size: 0.78rem;
  }
  .account-hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
    width: 100%;
  }
  .hero-metric-item {
    padding: 0.5rem 0.35rem;
    text-align: center;
    min-width: 0;
  }
  .metric-label {
    font-size: 0.58rem;
    letter-spacing: 0;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .metric-val {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Section Bars & Tables */
  .section-bar {
    padding: 0.65rem 0.85rem;
  }
  .section-bar h2 {
    font-size: 0.9rem;
  }
  .section-block {
    margin-bottom: 1rem;
    width: 100%;
  }
  .section-block-body,
  .section-block > div:not(.section-bar) {
    padding: 0.4rem !important;
    width: 100%;
  }

  /* In-table form inputs touch friendly */
  .row-input,
  .less-dropdown,
  .add-btn {
    font-size: 16px !important; /* Prevents auto-zoom on mobile */
  }
  .row-input {
    min-height: 38px;
    padding: 0.35rem 0.5rem;
  }
  .less-dropdown {
    min-height: 38px;
  }
  .add-btn {
    min-height: 38px;
    padding: 0.4rem 0.75rem;
  }

  /* Modals on mobile */
  .modal-box {
    width: 95vw !important;
    max-height: 90vh !important;
    padding: 1.15rem !important;
  }
}

/* Extra Small Phones (<= 480px) */
@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .account-hero-metrics {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .hero-metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    text-align: left;
  }
  .hero-metric-item .metric-label {
    font-size: 0.72rem;
    margin-bottom: 0;
  }
  .hero-metric-item .metric-val {
    font-size: 1.05rem;
  }
}
