/* ============================================================
   EMI Optimizer — Premium Design System v5.0
   A modern, dark-sidebar financial planning interface
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");

/* ── 1. CUSTOM PROPERTIES ── */
:root {
  --clr-primary: #6366f1;
  --clr-primary-dark: #4f46e5;
  --clr-primary-light: #818cf8;
  --clr-primary-glow: rgba(99, 102, 241, 0.14);
  --clr-violet: #a855f7;
  --clr-teal: #14b8a6;
  --clr-amber: #f59e0b;
  --clr-rose: #f43f5e;
  --clr-emerald: #10b981;
  --clr-blue: #3b82f6;

  /* Sidebar */
  --sidebar-bg: #0d1117;
  --sidebar-hover: rgba(255, 255, 255, 0.055);
  --sidebar-active-bg: rgba(99, 102, 241, 0.18);
  --sidebar-border: rgba(255, 255, 255, 0.07);
  --sidebar-width: 252px;
  --sidebar-collapsed: 68px;
  --sidebar-text: rgba(255, 255, 255, 0.55);
  --sidebar-text-active: #ffffff;

  /* Surfaces */
  --surface-app: #f1f5f9;
  --surface-card: #ffffff;
  --surface-card-alt: #f8fafc;
  --surface-input: #f8fafc;

  /* Borders */
  --border: rgba(148, 163, 184, 0.2);
  --border-strong: rgba(148, 163, 184, 0.38);
  --border-focus: rgba(99, 102, 241, 0.5);

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 24px 56px rgba(0, 0, 0, 0.12);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 14px rgba(0, 0, 0, 0.04);
  --shadow-card-hover:
    0 8px 28px rgba(0, 0, 0, 0.09), 0 2px 8px rgba(0, 0, 0, 0.04);

  /* Radius */
  --radius-sm: 5px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transition */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-f: 120ms;
  --dur-b: 200ms;
  --dur-s: 300ms;
  --t: all var(--dur-b) var(--ease);

  /* Z-index */
  --z-sidebar: 100;
  --z-header: 90;
  --z-modal: 200;
  --z-toast: 300;

  --pad: 22px;
}

/* ── 2. RESET & BASE ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--surface-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
}

/* ── 3. CUSTOM SCROLLBAR ── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.55);
}
.emi-sidebar ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}

/* ── 4. APP SHELL ── */
.emi-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── 5. SIDEBAR ── */
.emi-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: var(--z-sidebar);
  transition:
    width var(--dur-s) var(--ease),
    min-width var(--dur-s) var(--ease);
  overflow: hidden;
  flex-shrink: 0;
}
.emi-sidebar.collapsed {
  width: var(--sidebar-collapsed);
  min-width: var(--sidebar-collapsed);
}

/* Brand */
.emi-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 17px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 62px;
  flex-shrink: 0;
}
.emi-brand-icon {
  width: 34px;
  height: 34px;
  min-width: 34px;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-violet));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.42);
  flex-shrink: 0;
  letter-spacing: -1px;
}
.emi-brand-text {
  overflow: hidden;
  white-space: nowrap;
  transition: opacity var(--dur-b) var(--ease);
}
.emi-brand-name {
  font-size: 14.5px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.4px;
  line-height: 1.2;
}
.emi-brand-tagline {
  font-size: 10px;
  color: var(--sidebar-text);
  margin-top: 1px;
}
.emi-sidebar.collapsed .emi-brand-text {
  opacity: 0;
  pointer-events: none;
}

/* Nav */
.emi-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 7px;
}
.emi-nav-section-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.22);
  padding: 8px 9px 3px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--dur-b) var(--ease);
}
.emi-sidebar.collapsed .emi-nav-section-label {
  opacity: 0;
}

.emi-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 9px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--t);
  position: relative;
  color: var(--sidebar-text);
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.emi-nav-item:hover {
  background: var(--sidebar-hover);
  color: rgba(255, 255, 255, 0.88);
}
.emi-nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}
.emi-nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 58%;
  background: var(--clr-primary);
  border-radius: 0 3px 3px 0;
}
.emi-nav-icon {
  width: 19px;
  height: 19px;
  min-width: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.emi-nav-icon svg {
  width: 17px;
  height: 17px;
}
.emi-nav-label {
  font-size: 13px;
  font-weight: 500;
  transition: opacity var(--dur-b) var(--ease);
  overflow: hidden;
  flex: 1;
}
.emi-sidebar.collapsed .emi-nav-label {
  opacity: 0;
}
.emi-nav-badge {
  margin-left: auto;
  background: var(--clr-rose);
  color: white;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  transition: opacity var(--dur-b) var(--ease);
  flex-shrink: 0;
}
.emi-sidebar.collapsed .emi-nav-badge {
  opacity: 0;
}

/* Sidebar footer */
.emi-sidebar-footer {
  padding: 9px 7px 10px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.emi-user-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.048);
  overflow: hidden;
  margin-bottom: 3px;
}
.emi-user-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-violet));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
}
.emi-user-info {
  overflow: hidden;
  transition: opacity var(--dur-b) var(--ease);
  flex: 1;
}
.emi-sidebar.collapsed .emi-user-info {
  opacity: 0;
}
.emi-user-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.emi-user-status {
  font-size: 10px;
  color: var(--sidebar-text);
}
.emi-sign-out-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  cursor: pointer;
  transition: var(--t);
  width: 100%;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
}
.emi-sign-out-btn:hover {
  background: rgba(244, 63, 94, 0.12);
  color: #fca5a5;
}

/* Sidebar toggle button */
.emi-sidebar-toggle {
  position: absolute;
  top: 20px;
  right: -11px;
  width: 22px;
  height: 22px;
  background: var(--surface-card);
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  transition: var(--t);
}
.emi-sidebar-toggle:hover {
  background: var(--clr-primary);
  color: white;
  border-color: var(--clr-primary);
}
.emi-sidebar-toggle svg {
  width: 11px;
  height: 11px;
  transition: transform var(--dur-s) var(--ease);
}
.emi-sidebar.collapsed .emi-sidebar-toggle svg {
  transform: rotate(180deg);
}

/* ── 6. MAIN AREA ── */
.emi-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Desktop top bar */
.emi-topbar {
  height: 54px;
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: var(--z-header);
}
.emi-topbar-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  flex: 1;
}

/* Status pills */
.emi-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
  white-space: nowrap;
}
.emi-pill-saving {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.3);
  color: #b45309;
}
.emi-pill-saved {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.28);
  color: #047857;
}
.emi-pill-error {
  background: rgba(244, 63, 94, 0.08);
  border-color: rgba(244, 63, 94, 0.28);
  color: #be123c;
}
.emi-pill-idle {
  background: rgba(100, 116, 139, 0.07);
  border-color: rgba(100, 116, 139, 0.2);
  color: #64748b;
}
.emi-pill-ok {
  background: rgba(16, 185, 129, 0.07);
  border-color: rgba(16, 185, 129, 0.22);
  color: #047857;
}
.emi-pill-err {
  background: rgba(244, 63, 94, 0.07);
  border-color: rgba(244, 63, 94, 0.22);
  color: #be123c;
}

/* Mobile top bar */
.emi-mobile-topbar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 52px;
  min-height: 52px;
  background: var(--sidebar-bg);
  flex-shrink: 0;
}

/* Scrollable content */
.emi-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--pad);
  scroll-behavior: smooth;
}

/* ── 7. CARDS ── */
.emi-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--dur-b) var(--ease);
  overflow: hidden;
}
.emi-card:hover {
  box-shadow: var(--shadow-card-hover);
}
.emi-card-pad {
  padding: 20px;
}
.emi-card-pad-lg {
  padding: 24px;
}
.emi-card-pad-sm {
  padding: 14px;
}
.emi-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.emi-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

/* ── 8. METRIC CARDS ── */
.emi-metric {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  box-shadow: var(--shadow-card);
  transition: var(--t);
  position: relative;
  overflow: hidden;
}
.emi-metric:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.emi-metric-icon {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.emi-metric-icon svg {
  width: 21px;
  height: 21px;
}
.emi-metric-body {
  flex: 1;
  min-width: 0;
}
.emi-metric-value {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.7px;
  line-height: 1.15;
  color: var(--text-primary);
}
.emi-metric-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 3px;
}
.emi-metric-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.emi-metric-trend {
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.emi-metric-trend-up {
  color: #059669;
}
.emi-metric-trend-down {
  color: #dc2626;
}

/* Icon colour variants */
.icon-indigo {
  background: rgba(99, 102, 241, 0.11);
  color: #6366f1;
}
.icon-violet {
  background: rgba(168, 85, 247, 0.11);
  color: #a855f7;
}
.icon-teal {
  background: rgba(20, 184, 166, 0.11);
  color: #0d9488;
}
.icon-amber {
  background: rgba(245, 158, 11, 0.11);
  color: #d97706;
}
.icon-rose {
  background: rgba(244, 63, 94, 0.11);
  color: #e11d48;
}
.icon-emerald {
  background: rgba(16, 185, 129, 0.11);
  color: #059669;
}
.icon-blue {
  background: rgba(59, 130, 246, 0.11);
  color: #2563eb;
}
.icon-orange {
  background: rgba(249, 115, 22, 0.11);
  color: #ea580c;
}

/* ── 9. BUTTONS ── */
.emi-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--t);
  font-family: inherit;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.emi-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  pointer-events: none;
}
.emi-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.emi-btn-primary {
  background: linear-gradient(
    135deg,
    var(--clr-primary-dark),
    var(--clr-primary)
  );
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.28);
}
.emi-btn-primary:hover {
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}
.emi-btn-primary:active {
  transform: none;
  box-shadow: none;
}

.emi-btn-secondary {
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}
.emi-btn-secondary:hover {
  background: var(--surface-app);
  box-shadow: var(--shadow-xs);
}

.emi-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.emi-btn-ghost:hover {
  background: var(--surface-app);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.emi-btn-danger {
  background: linear-gradient(135deg, #c5182a, #f43f5e);
  color: white;
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.28);
}
.emi-btn-danger:hover {
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.4);
  transform: translateY(-1px);
}

.emi-btn-success {
  background: linear-gradient(135deg, #047857, #10b981);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.28);
}
.emi-btn-success:hover {
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.emi-btn-amber {
  background: linear-gradient(135deg, #b45309, #f59e0b);
  color: white;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.28);
}
.emi-btn-amber:hover {
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.36);
  transform: translateY(-1px);
}

.emi-btn-sm {
  padding: 5px 10px;
  font-size: 11.5px;
}
.emi-btn-sm svg {
  width: 12px;
  height: 12px;
}
.emi-btn-lg {
  padding: 11px 20px;
  font-size: 14px;
}
.emi-btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* ── 10. FORM INPUTS ── */
.emi-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.emi-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}
.emi-label-req::after {
  content: " *";
  color: var(--clr-rose);
}

.emi-input,
.emi-select,
.emi-textarea {
  width: 100%;
  padding: 8px 11px;
  background: var(--surface-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  font-family: inherit;
  transition: var(--t);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.emi-input:focus,
.emi-select:focus,
.emi-textarea:focus {
  background: #ffffff;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px var(--clr-primary-glow);
}
.emi-input::placeholder {
  color: var(--text-muted);
}
.emi-input-wrap {
  position: relative;
}
.emi-input-prefix {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 12.5px;
  pointer-events: none;
  font-weight: 500;
}
.emi-input-wrap .emi-input {
  padding-left: 24px;
}

/* ── 11. BADGES ── */
.emi-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.badge-indigo {
  background: rgba(99, 102, 241, 0.1);
  color: #4f46e5;
}
.badge-violet {
  background: rgba(168, 85, 247, 0.1);
  color: #9333ea;
}
.badge-emerald {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}
.badge-amber {
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
}
.badge-rose {
  background: rgba(244, 63, 94, 0.1);
  color: #be123c;
}
.badge-slate {
  background: rgba(100, 116, 139, 0.1);
  color: #475569;
}
.badge-blue {
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
}

/* ── 12. TABLE ── */
.emi-tbl-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.emi-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.emi-tbl thead {
  background: var(--surface-app);
}
.emi-tbl th {
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.emi-tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.emi-tbl tbody tr:last-child td {
  border-bottom: none;
}
.emi-tbl tbody tr {
  transition: background var(--dur-f) var(--ease);
}
.emi-tbl tbody tr:hover {
  background: rgba(99, 102, 241, 0.028);
}

/* ── 13. PROGRESS BAR ── */
.emi-progress {
  height: 7px;
  background: var(--surface-app);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border);
}
.emi-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.65s var(--ease);
}
.emi-progress-thin {
  height: 4px;
  border: none;
}

/* ── 14. MODAL ── */
.emi-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 30, 0.6);
  backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn var(--dur-b) var(--ease);
}
.emi-modal {
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  overflow: hidden;
  animation: slideUp var(--dur-s) var(--ease);
}

/* ── 15. EMPTY STATE ── */
.emi-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
}
.emi-empty-icon {
  width: 54px;
  height: 54px;
  background: var(--surface-app);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  color: var(--text-muted);
}
.emi-empty-icon svg {
  width: 24px;
  height: 24px;
}
.emi-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.emi-empty-sub {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 300px;
  line-height: 1.65;
  margin-bottom: 20px;
}

/* ── 16. SECTION HEADER ── */
.emi-section-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.emi-section-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.35px;
}
.emi-section-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── 17. GRADIENT BANNERS ── */
.emi-banner {
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
  color: white;
}
.emi-banner::after {
  content: "";
  position: absolute;
  top: -60%;
  right: -8%;
  width: 260px;
  height: 260px;
  background: rgba(255, 255, 255, 0.065);
  border-radius: 50%;
  pointer-events: none;
}
.emi-banner-value {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1.1;
}
.emi-banner-label {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
  margin-top: 4px;
}
.emi-banner-sub {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 2px;
}

/* ── 18. CHAT ── */
.emi-chat-bubble {
  padding: 11px 14px;
  border-radius: var(--radius-lg);
  max-width: 85%;
  font-size: 13px;
  line-height: 1.65;
}
.emi-chat-bubble.user {
  background: var(--clr-primary);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.emi-chat-bubble.assistant {
  background: var(--surface-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.emi-chat-bubble.error {
  background: rgba(244, 63, 94, 0.06);
  border: 1px solid rgba(244, 63, 94, 0.2);
  color: #be123c;
}

/* ── 19. MISC UTILITIES ── */
.text-gradient {
  background: linear-gradient(
    135deg,
    var(--clr-primary) 0%,
    var(--clr-violet) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.text-gradient-gold {
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.emi-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}
.emi-alert {
  display: flex;
  gap: 11px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid;
  margin-bottom: 14px;
  font-size: 12.5px;
}
.emi-alert-info {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.22);
}
.emi-alert-success {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.22);
}
.emi-alert-warning {
  background: rgba(245, 158, 11, 0.06);
  border-color: rgba(245, 158, 11, 0.22);
}
.emi-alert-error {
  background: rgba(244, 63, 94, 0.06);
  border-color: rgba(244, 63, 94, 0.22);
}

/* Hide number spinner */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* ── 20. ANIMATIONS ── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
@keyframes pulseGlow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.3);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(99, 102, 241, 0);
  }
}
@keyframes countUp {
  from {
    transform: translateY(6px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.animate-fade {
  animation: fadeIn var(--dur-b) var(--ease);
}
.animate-slide-up {
  animation: slideUp var(--dur-s) var(--ease);
}
.animate-spin {
  animation: spin 0.75s linear infinite;
}
.animate-glow {
  animation: pulseGlow 2.2s ease-in-out infinite;
}
.emi-skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* ── 21. MOBILE BOTTOM NAV ── */
.emi-mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-card);
  border-top: 1px solid var(--border);
  padding: 5px 4px max(8px, env(safe-area-inset-bottom));
  z-index: var(--z-sidebar);
}
.emi-mobile-nav-inner {
  display: flex;
  align-items: center;
  overflow-x: auto;
  gap: 2px;
  padding: 0 6px;
}
.emi-mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--t);
  color: var(--text-muted);
  min-width: 52px;
  border: none;
  background: none;
  font-family: inherit;
  flex-shrink: 0;
}
.emi-mobile-nav-item.active {
  color: var(--clr-primary);
  background: rgba(99, 102, 241, 0.08);
}
.emi-mobile-nav-item svg {
  width: 20px;
  height: 20px;
}
.emi-mobile-nav-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── 22. LOAN CARD ── */
.emi-loan-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--t);
  margin-bottom: 12px;
}
.emi-loan-card:hover {
  box-shadow: var(--shadow-card-hover);
}
.emi-loan-accent {
  height: 3px;
}

/* ── 23. COUNTDOWN GRID ── */
.emi-countdown-item {
  text-align: center;
  padding: 14px 10px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-md);
  backdrop-filter: blur(4px);
}
.emi-countdown-num {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -1px;
}
.emi-countdown-lbl {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.8;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── 24. GRID HELPERS ── */
.g-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.g-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.g-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.g-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}

@media (max-width: 1200px) {
  .g-4,
  .g-5 {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 900px) {
  .g-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 640px) {
  .g-2,
  .g-3,
  .g-4,
  .g-5 {
    grid-template-columns: 1fr;
  }
}

/* ── 25. RESPONSIVE ── */
@media (max-width: 768px) {
  .emi-sidebar {
    display: none;
  }
  .emi-topbar {
    display: none;
  }
  .emi-mobile-nav {
    display: flex;
  }
  .emi-mobile-topbar {
    display: flex;
  }
  .emi-main {
    padding-bottom: max(68px, calc(52px + env(safe-area-inset-bottom)));
  }
  .emi-content {
    padding: 14px;
  }
  :root {
    --pad: 14px;
  }
}
@media (max-width: 480px) {
  .emi-content {
    padding: 12px;
  }
  :root {
    --pad: 12px;
  }
}

/* Expose mobile sidebar overlay */
.emi-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  z-index: 99;
  backdrop-filter: blur(4px);
}
@media (max-width: 768px) {
  .emi-sidebar.mobile-open {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: var(--z-sidebar);
    width: var(--sidebar-width) !important;
    min-width: var(--sidebar-width) !important;
  }
  .emi-sidebar-overlay.visible {
    display: block;
  }
}

/* ── 26. PLAN NAME INLINE EDIT ── */
.plan-name-input {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  border: none;
  background: transparent;
  outline: none;
  padding: 2px 0;
  width: 100%;
  max-width: 280px;
  border-bottom: 2px solid transparent;
  transition: var(--t);
  font-family: inherit;
}
.plan-name-input:focus {
  border-bottom-color: var(--clr-primary);
}

/* ── 27. RISK GAUGE ── */
.emi-risk-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #10b981 0%, #f59e0b 50%, #f43f5e 100%);
  position: relative;
  margin-bottom: 6px;
}
.emi-risk-needle {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: white;
  border: 2px solid #0f172a;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow-sm);
  transition: left 0.5s var(--ease);
}

/* ── 28. TOOLTIP ── */
.emi-tip-wrap {
  position: relative;
  display: inline-flex;
}
.emi-tip {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: white;
  font-size: 11.5px;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-f) var(--ease);
  z-index: 10;
}
.emi-tip-wrap:hover .emi-tip {
  opacity: 1;
}

/* ── 29. SECTION DIVIDER WITH TITLE ── */
.emi-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 10px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.emi-group-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── 30. OVERVIEW HERO CARD ── */
.emi-hero {
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  color: white;
}
.emi-hero::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -5%;
  width: 220px;
  height: 220px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 50%;
  pointer-events: none;
}
.emi-hero::after {
  content: "";
  position: absolute;
  bottom: -50%;
  left: -3%;
  width: 160px;
  height: 160px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 50%;
  pointer-events: none;
}
