/* ================================================================
   CardioAI — Master Stylesheet
   Pages: Sign-In (auth-page) · Dashboard (dashboard-page)
   ================================================================ */

/* ── Custom Properties ──────────────────────────────────────── */
:root {
  --primary: #4361ee;
  --primary-d: #3451d1;
  --primary-light: #eef1ff;
  --teal: #0ea5e9;
  --teal-light: #e0f2fe;
  --dark: #1a2035;
  --dark2: #232d45;
  --text: #1e293b;
  --text-mid: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --white: #ffffff;
  --success: #22c55e;
  --success-light: #dcfce7;
  --warning-light: #fef9c3;
  --orange-light: #ffedd5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --shadow-sm: 0 1px 6px rgba(0, 0, 0, 0.07);
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.09);
  --shadow-md: 0 4px 28px rgba(0, 0, 0, 0.13);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sidebar-w: 252px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
}
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a {
  text-decoration: none;
  color: inherit;
}
button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: inherit;
}
ul {
  list-style: none;
}

/* ================================================================
   SIGN-IN PAGE
   ================================================================ */

.auth-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

/* ── AutoFill notification bar ──────────────────────────────── */
.autofill-bar {
  width: 100%;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  padding: 0;
  position: relative;
  z-index: 200;
  flex-shrink: 0;
}
.autofill-bar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  max-width: 100%;
  min-height: 36px;
}
.autofill-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: #fef3c7;
  border-radius: 4px;
  flex-shrink: 0;
}
.autofill-icon-wrap i {
  color: #d97706;
  font-size: 12px;
  transform: rotate(-45deg);
}
.autofill-bar-text {
  flex: 1;
  font-size: 12.5px;
  color: #78350f;
  font-weight: 500;
}
.autofill-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.autofill-btn-use {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 3px 11px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
}
.autofill-btn-use:hover {
  background: var(--primary-d);
}
.autofill-btn-x {
  background: none;
  border: none;
  color: #92400e;
  font-size: 13px;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.autofill-btn-x:hover {
  background: rgba(0, 0, 0, 0.07);
}

/* ── Auth split layout ──────────────────────────────────────── */
.auth-wrap {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ── Left panel ─────────────────────────────────────────────── */
.auth-left {
  width: 56%;
  background: linear-gradient(148deg, #0f172a 0%, #1e3a5f 46%, #1d5799 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 52px;
}
/* Ambient glow blobs */
.auth-left::before,
.auth-left::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.auth-left::before {
  width: 520px;
  height: 520px;
  background: radial-gradient(
    circle,
    rgba(67, 97, 238, 0.22) 0%,
    transparent 68%
  );
  top: -130px;
  right: -120px;
}
.auth-left::after {
  width: 380px;
  height: 380px;
  background: radial-gradient(
    circle,
    rgba(14, 165, 233, 0.17) 0%,
    transparent 65%
  );
  bottom: -90px;
  left: -70px;
}

.auth-left-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 470px;
}

/* Brand row */
.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 48px;
}
.brand-icon-box {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.13);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.brand-icon-box i {
  color: #f9a8d4;
  font-size: 22px;
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-name {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
  line-height: 1.1;
}
.brand-sub {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 1.8px;
  text-transform: uppercase;
  font-weight: 500;
}

/* Headline */
.left-headline {
  margin-bottom: 0;
}
.left-headline h2 {
  font-size: 34px;
  font-weight: 700;
  color: #fff;
  line-height: 1.22;
  letter-spacing: -0.6px;
  margin-bottom: 14px;
}
.left-headline p {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.7;
}

/* ECG decoration */
.ecg-wrap {
  margin: 34px 0 28px;
  height: 56px;
}
.ecg-svg {
  width: 100%;
  height: 100%;
}
.ecg-line {
  stroke-dasharray: 1500;
  stroke-dashoffset: 1500;
  animation: drawECG 2.4s cubic-bezier(0.4, 0, 0.2, 1) forwards 0.3s;
}

/* Floating stats card */
.left-stats-card {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(14px);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: stretch;
  margin-bottom: 30px;
}
.left-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 12px;
}
.left-stat-val {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  margin-bottom: 5px;
}
.left-stat-lbl {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 500;
}
.left-stat-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
}

/* Features */
.left-features {
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.left-features li {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.left-features li i {
  color: #4ade80;
  font-size: 15px;
  flex-shrink: 0;
}

/* ── Right panel ─────────────────────────────────────────────── */
.auth-right {
  width: 44%;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 48px 80px;
  position: relative;
}
.auth-form-card {
  width: 100%;
  max-width: 400px;
}

/* Form header */
.auth-form-title {
  font-size: 27px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  margin-bottom: 6px;
}
.auth-form-sub {
  font-size: 14px;
  color: var(--text-mid);
  margin-bottom: 34px;
}

/* Form groups */
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}
.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
}
.label-row .form-label {
  margin-bottom: 0;
}
.forgot-link {
  font-size: 12.5px;
  color: var(--primary);
  font-weight: 500;
}
.forgot-link:hover {
  text-decoration: underline;
}

/* Input */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 13px;
  color: var(--text-muted);
  font-size: 13.5px;
  pointer-events: none;
  z-index: 1;
}
.form-control {
  width: 100%;
  padding: 11px 40px 11px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition:
    border-color 0.18s,
    box-shadow 0.18s;
}
.form-control::placeholder {
  color: #c0c8d4;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(67, 97, 238, 0.12);
}

/* Password toggle */
.pw-toggle {
  position: absolute;
  right: 11px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pw-toggle:hover {
  color: var(--text-mid);
  background: rgba(0, 0, 0, 0.04);
}

/* Error */
.form-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  color: #dc2626;
  font-size: 13px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Sign-in button */
.btn-signin {
  width: 100%;
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition:
    background 0.18s,
    box-shadow 0.18s,
    transform 0.1s;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(67, 97, 238, 0.38);
}
.btn-signin:hover {
  background: var(--primary-d);
  box-shadow: 0 6px 22px rgba(67, 97, 238, 0.48);
}
.btn-signin:active {
  transform: translateY(1px);
}
.btn-signin:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
}

/* Page counter */
.page-counter {
  position: absolute;
  bottom: 26px;
  right: 32px;
  display: flex;
  align-items: center;
  gap: 5px;
  user-select: none;
}
.pc-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-mid);
  background: var(--bg);
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid var(--border);
}
.pc-of {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ================================================================
   DASHBOARD PAGE
   ================================================================ */

.dashboard-page {
  display: flex;
  height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--dark);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

/* Sidebar brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}
.sidebar-brand-icon-box {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-icon-box i {
  color: #f9a8d4;
  font-size: 18px;
}
.sidebar-brand-name {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

/* Sidebar navigation */
.sidebar-nav {
  flex: 1;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.48);
  font-size: 13.5px;
  font-weight: 500;
  transition:
    background 0.18s,
    color 0.18s;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.88);
}
.nav-item.active {
  background: rgba(67, 97, 238, 0.28);
  color: #a5b4fc;
}
.nav-item.active .nav-icon {
  color: #818cf8;
}
.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}
.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.4);
  font-size: 13.5px;
  font-weight: 500;
  transition:
    background 0.18s,
    color 0.18s;
}
.btn-logout:hover {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

/* ── Main content ────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 13px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.bc-label {
  color: var(--text-mid);
}
.bc-active {
  color: var(--text);
  font-weight: 600;
}
.bc-sep {
  font-size: 9px;
  color: var(--text-muted);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}
.topbar-date {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-mid);
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.topbar-user:hover {
  background: var(--bg);
}
.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* ── Page heading ────────────────────────────────────────────── */
.page-heading {
  padding: 26px 30px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-shrink: 0;
}
.page-title {
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  line-height: 1.25;
}
.page-sub {
  font-size: 13.5px;
  color: var(--text-mid);
  margin-top: 5px;
}
.btn-refresh {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  transition:
    border-color 0.18s,
    color 0.18s;
  flex-shrink: 0;
  margin-top: 3px;
}
.btn-refresh:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.btn-refresh:active i {
  animation: spin 0.4s linear;
}

/* ── Loading state ───────────────────────────────────────────── */
.loading-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 320px;
}
.loading-spinner-wrap {
  position: relative;
  width: 64px;
  height: 64px;
}
.loading-ring {
  width: 64px;
  height: 64px;
  border: 3px solid rgba(67, 97, 238, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.loading-heart {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 20px;
}
.loading-text {
  font-size: 13.5px;
  color: var(--text-mid);
}

/* ── Error banner ────────────────────────────────────────────── */
.error-banner {
  margin: 20px 30px 0;
  padding: 13px 18px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: #dc2626;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.err-retry-btn {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  padding: 4px 14px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}
.err-retry-btn:hover {
  background: #dc2626;
}

/* ── Stats grid ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  padding: 22px 30px;
  flex-shrink: 0;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 4px solid transparent;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.stat-card--blue {
  border-top-color: var(--primary);
}
.stat-card--teal {
  border-top-color: var(--teal);
}
.stat-card--green {
  border-top-color: var(--success);
}
.stat-card--red {
  border-top-color: var(--danger);
}

.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}
.stat-card--blue .stat-card-icon {
  background: var(--primary-light);
  color: var(--primary);
}
.stat-card--teal .stat-card-icon {
  background: var(--teal-light);
  color: var(--teal);
}
.stat-card--green .stat-card-icon {
  background: var(--success-light);
  color: var(--success);
}
.stat-card--red .stat-card-icon {
  background: var(--danger-light);
  color: var(--danger);
}

.stat-card-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.stat-card-badge--blue {
  background: var(--primary-light);
  color: var(--primary);
}
.stat-card-badge--teal {
  background: var(--teal-light);
  color: var(--teal);
}
.stat-card-badge--green {
  background: var(--success-light);
  color: #15803d;
}
.stat-card-badge--red {
  background: var(--danger-light);
  color: #b91c1c;
}

.stat-card-body {
  display: flex;
  flex-direction: column;
}
.stat-card-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 4px;
}
.stat-card-value {
  font-size: 34px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1.5px;
  line-height: 1.05;
}
.stat-card-footer {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-trend-icon {
  color: var(--text-muted);
}

/* ── Table section ───────────────────────────────────────────── */
.table-section {
  margin: 0 30px 30px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  flex-shrink: 0;
}
.table-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.table-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
}
.table-sub {
  font-size: 12.5px;
  color: var(--text-mid);
  margin-top: 3px;
}
.table-card-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.record-pill {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-mid);
  background: var(--bg);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* Table */
.table-scroll {
  overflow-x: auto;
}
.analyses-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}
.analyses-table thead th {
  padding: 11px 18px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.75px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.analyses-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.analyses-table tbody tr:last-child {
  border-bottom: none;
}
.analyses-table tbody tr:hover {
  background: #f8fafc;
}
.analyses-table tbody td {
  padding: 13px 18px;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
}

/* Analysis ID chip */
.id-chip {
  font-family: "Courier New", monospace;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 9px;
  border-radius: 5px;
}

/* Patient ID */
.pid-text {
  font-weight: 600;
  color: var(--text);
}

/* EF value */
.ef-val {
  font-weight: 700;
  font-size: 13.5px;
}
.ef-normal {
  color: #15803d;
}
.ef-mild {
  color: #b45309;
}
.ef-moderate {
  color: #c2410c;
}
.ef-severe {
  color: #b91c1c;
}

/* Severity badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-normal {
  background: var(--success-light);
  color: #15803d;
}
.badge-mild {
  background: var(--warning-light);
  color: #b45309;
}
.badge-moderate {
  background: var(--orange-light);
  color: #c2410c;
}
.badge-severe {
  background: var(--danger-light);
  color: #b91c1c;
}

/* Accuracy */
.accuracy-cell {
  display: flex;
  align-items: center;
  gap: 9px;
}
.acc-val {
  font-weight: 600;
  font-size: 13px;
  min-width: 45px;
}
.acc-bar-bg {
  width: 58px;
  height: 5px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}
.acc-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* Status badge */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-completed {
  background: var(--success-light);
  color: #15803d;
}
.status-completed .status-dot {
  background: #22c55e;
}
.status-processing {
  background: var(--teal-light);
  color: #0369a1;
}
.status-processing .status-dot {
  background: #0ea5e9;
  animation: blink 1.3s infinite;
}

/* ================================================================
   ANIMATIONS
   ================================================================ */

@keyframes drawECG {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stats-grid {
  animation: fadeUp 0.38s ease both 0.05s;
}
.table-section {
  animation: fadeUp 0.38s ease both 0.12s;
}

/* ================================================================
   NEW ANALYSIS BUTTON (page-heading)
   ================================================================ */
.btn-new-analysis {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  transition:
    background 0.18s,
    transform 0.12s;
  flex-shrink: 0;
  margin-top: 3px;
  cursor: pointer;
}
.btn-new-analysis:hover {
  background: var(--primary-d);
}
.btn-new-analysis:active {
  transform: scale(0.97);
}

/* ================================================================
   MODAL
   ================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 580px;
  overflow: hidden;
  animation: slideUp 0.22s ease;
}
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Modal header ── */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  gap: 14px;
}
.modal-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.modal-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.modal-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 2px 0 0;
}
.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  flex-shrink: 0;
}
.modal-close-btn:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: #fca5a5;
}

/* ── Modal body / form ── */
.modal-body {
  padding: 20px 24px 6px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.form-req {
  color: var(--danger);
  margin-left: 2px;
}
.modal-input {
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition:
    border-color 0.18s,
    box-shadow 0.18s;
}
.modal-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
}
.modal-input::placeholder {
  color: var(--text-muted);
}

/* ── File drop zone ── */
.file-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px 18px;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 0.18s,
    background 0.18s;
  background: #f8fafc;
}
.file-drop-zone:hover,
.file-drop-zone:focus,
.file-drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.file-drop-zone.has-file {
  border-color: var(--success);
  background: var(--success-light);
}
.file-drop-icon {
  font-size: 28px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
}
.file-drop-zone.drag-over .file-drop-icon,
.file-drop-zone:hover .file-drop-icon {
  color: var(--primary);
}
.file-drop-zone.has-file .file-drop-icon {
  color: var(--success);
}
.file-drop-text {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-mid);
  margin: 0;
}
.file-drop-browse {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-style: dotted;
  font-weight: 600;
}
.file-drop-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin: 4px 0 0;
}
.file-selected-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #166534;
  margin: 8px 0 0;
  word-break: break-all;
}

/* ── Modal error ── */
.modal-error-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--danger-light);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-xs);
  padding: 9px 13px;
  font-size: 13px;
  color: #b91c1c;
  font-weight: 500;
}

/* ── Modal footer ── */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--border);
}
.btn-modal-cancel {
  padding: 9px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--white);
  color: var(--text-mid);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition:
    border-color 0.15s,
    color 0.15s;
}
.btn-modal-cancel:hover {
  border-color: #94a3b8;
  color: var(--text);
}
.btn-modal-analyze {
  padding: 9px 22px;
  border: none;
  border-radius: var(--radius-xs);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition:
    background 0.15s,
    transform 0.1s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-modal-analyze:hover:not(:disabled) {
  background: var(--primary-d);
}
.btn-modal-analyze:active:not(:disabled) {
  transform: scale(0.97);
}
.btn-modal-analyze:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* ── Result section ── */
.modal-result-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.result-overlay-wrap {
  text-align: center;
}
.result-overlay-img {
  width: 100%;
  max-width: 516px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
}
.result-overlay-legend {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 8px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mid);
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.result-stats-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.result-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
}
.result-stat-row:last-child {
  border-bottom: none;
}
.result-stat-row:nth-child(odd) {
  background: #f8fafc;
}
.result-stat-label {
  font-weight: 500;
  color: var(--text-mid);
}
.result-stat-val {
  font-weight: 700;
  color: var(--text);
}
.result-stat-val.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

/* ── View scan button (table) ── */
.btn-view-scan {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-xs);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}
.btn-view-scan:hover {
  background: var(--primary);
  color: #fff;
}

/* ── Image lightbox ── */
.lightbox-card {
  position: relative;
  background: #0f172a;
  border-radius: var(--radius);
  padding: 16px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: slideUp 0.2s ease;
}
.lightbox-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}
.lightbox-close-btn:hover {
  background: rgba(255, 255, 255, 0.25) !important;
  color: #fff !important;
}
.lightbox-img {
  max-width: 100%;
  max-height: calc(90vh - 80px);
  border-radius: 8px;
  display: block;
}
.lightbox-caption {
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
}
