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

:root {
  --blue-900: #0d47a1;
  --blue-700: #1565c0;
  --blue-500: #1976d2;
  --blue-100: #e3f2fd;
  --red-700:  #c62828;
  --red-100:  #ffebee;
  --green-700: #2e7d32;
  --green-100: #e8f5e9;
  --orange-700: #e65100;
  --orange-100: #fff3e0;
  --gray-900: #212121;
  --gray-700: #424242;
  --gray-500: #9e9e9e;
  --gray-200: #eeeeee;
  --gray-100: #f5f7fa;
  --white:    #ffffff;
  --shadow:   0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.5;
}

/* ─── LOGIN ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--blue-900) 0%, var(--blue-500) 100%);
}

.login-card {
  background: var(--white);
  border-radius: 14px;
  padding: 48px 40px 40px;
  width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo .cross { font-size: 52px; display: block; line-height: 1; margin-bottom: 8px; }
.login-logo h1 { font-size: 26px; font-weight: 800; color: var(--blue-900); letter-spacing: -.02em; }
.login-logo p  { color: var(--gray-500); font-size: 13px; margin-top: 4px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--gray-700); }
.form-group input {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-size: 15px; transition: border-color .2s;
}
.form-group input:focus { outline: none; border-color: var(--blue-500); }

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; transition: all .15s; text-decoration: none;
}
.btn-primary { background: var(--blue-700); color: #fff; width: 100%; padding: 13px; font-size: 15px; }
.btn-primary:hover { background: var(--blue-900); }
.btn-danger  { background: var(--red-700); color: #fff; }
.btn-danger:hover { opacity: .88; }
.btn-outline { background: transparent; border: 1.5px solid var(--blue-500); color: var(--blue-700); }
.btn-outline:hover { background: var(--blue-100); }
.btn-ghost   { background: transparent; color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-200); }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ─── ERROR / ALERT ──────────────────────────────────────── */
.error-msg {
  background: var(--red-100); color: var(--red-700);
  padding: 10px 14px; border-radius: 8px; font-size: 14px;
  margin-bottom: 16px; display: none;
}

.alert {
  padding: 13px 16px; border-radius: 8px; font-size: 14px;
  margin-bottom: 20px; border-left: 4px solid;
}
.alert-danger  { background: var(--red-100);    color: var(--red-700);    border-color: var(--red-700);    }
.alert-warning { background: var(--orange-100); color: var(--orange-700); border-color: var(--orange-700); }
.alert-info    { background: var(--blue-100);   color: var(--blue-700);   border-color: var(--blue-500);   }
.alert-success { background: var(--green-100);  color: var(--green-700);  border-color: var(--green-700);  }

/* ─── APP SHELL ──────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: 256px; background: var(--blue-900); color: #fff;
  flex-shrink: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}

.sidebar-header { padding: 22px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }

.sidebar-brand { display: flex; align-items: center; gap: 9px; }
.sidebar-brand .cross { font-size: 26px; line-height: 1; }
.sidebar-brand span   { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }

.sidebar-user { margin-top: 14px; display: flex; align-items: center; gap: 10px; }
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.14);
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user .user-name {
  font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .user-role {
  font-size: 11px; color: rgba(255,255,255,.55); margin-top: 2px;
  text-transform: uppercase; letter-spacing: .06em;
}

.sidebar-nav { padding: 12px 0; flex: 1; overflow-y: auto; }

.nav-section {
  padding: 10px 20px 4px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.35);
}

.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 20px; color: rgba(255,255,255,.75); text-decoration: none;
  font-size: 14px; transition: all .12s; border-left: 3px solid transparent;
}
.nav-link:hover  { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: #fff; font-weight: 600; }
.nav-link .icon  { width: 20px; text-align: center; font-size: 15px; }

.sidebar-footer { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-footer button {
  background: none; border: none; color: rgba(255,255,255,.55);
  font-size: 13px; cursor: pointer; padding: 0;
}
.sidebar-footer button:hover { color: #fff; }

/* ─── MAIN CONTENT ───────────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.page-header {
  background: var(--white); border-bottom: 1px solid var(--gray-200);
  padding: 18px 32px; display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.page-title    { font-size: 20px; font-weight: 700; color: var(--gray-900); }
.page-subtitle { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

.content-area { padding: 28px 32px; overflow-y: auto; flex: 1; }

/* ─── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: 10px;
  border: 1px solid var(--gray-200); box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.card-body  { padding: 20px; }

/* ─── STATS ──────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px; margin-bottom: 28px;
}
.stat-card {
  background: var(--white); border-radius: 10px;
  padding: 18px 20px; border: 1px solid var(--gray-200); box-shadow: var(--shadow);
  transition: box-shadow .15s ease, transform .15s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-label { font-size: 12px; color: var(--gray-500); font-weight: 500; }
.stat-value { font-size: 30px; font-weight: 800; color: var(--blue-700); margin: 4px 0; }
.stat-sub   { font-size: 12px; color: var(--gray-500); }

/* ─── GRID ───────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-2-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }

/* ─── LISTS ──────────────────────────────────────────────── */
.item-list { list-style: none; }
.item-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--gray-100);
}
.item-row:last-child { border-bottom: none; }

.item-icon {
  width: 38px; height: 38px; border-radius: 8px; background: var(--blue-100);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.item-icon.red    { background: var(--red-100); }
.item-icon.orange { background: var(--orange-100); }
.item-icon.green  { background: var(--green-100); }

.item-info   { flex: 1; min-width: 0; }
.item-title  { font-size: 14px; font-weight: 600; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta   { font-size: 12px; color: var(--gray-500); margin-top: 1px; }
.item-action { flex-shrink: 0; }

.view-link { font-size: 13px; color: var(--blue-700); text-decoration: none; font-weight: 500; white-space: nowrap; }
.view-link:hover { text-decoration: underline; }

/* ─── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 100px; font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
.badge-blue   { background: var(--blue-100);   color: var(--blue-700);   }
.badge-red    { background: var(--red-100);    color: var(--red-700);    }
.badge-green  { background: var(--green-100);  color: var(--green-700);  }
.badge-orange { background: var(--orange-100); color: var(--orange-700); }
.badge-gray   { background: var(--gray-200);   color: var(--gray-700);   }

/* ─── DETAIL VIEW ────────────────────────────────────────── */
.detail-section { margin-bottom: 28px; }
.detail-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--gray-500); margin-bottom: 14px;
  padding-bottom: 8px; border-bottom: 1px solid var(--gray-200);
}

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

.detail-field { margin-bottom: 18px; }
.detail-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--gray-500); margin-bottom: 4px; }
.detail-value { font-size: 15px; color: var(--gray-900); }
.detail-value.sensitive { color: var(--red-700); font-weight: 600; }
.detail-value pre { font-family: inherit; font-size: 14px; white-space: pre-wrap; line-height: 1.6; }

/* ─── TABLE ──────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left; padding: 11px 14px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200); white-space: nowrap;
}
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--gray-100); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-100); cursor: pointer; }

/* ─── ACTION BAR ─────────────────────────────────────────── */
.action-bar { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ─── LOADING ────────────────────────────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px; color: var(--gray-500); font-size: 14px; gap: 10px;
}

/* ─── PROFILE HEADER ─────────────────────────────────────── */
.profile-header {
  display: flex; align-items: center; gap: 20px;
  padding: 24px; border-bottom: 1px solid var(--gray-200);
}
.avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--blue-100); display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: var(--blue-700); flex-shrink: 0;
}
.profile-meta h2 { font-size: 20px; font-weight: 700; }
.profile-meta p  { color: var(--gray-500); font-size: 13px; margin-top: 3px; }

/* ─── SENSITIVE DATA HIGHLIGHT ───────────────────────────── */
.sensitive-box {
  background: var(--red-100); border: 1px solid #ef9a9a;
  border-radius: 8px; padding: 14px 16px; margin-bottom: 20px;
}
.sensitive-box .sensitive-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--red-700); margin-bottom: 6px;
}
.sensitive-box .sensitive-data { font-size: 16px; font-weight: 700; color: var(--red-700); }

/* ─── VULN ANNOTATION (dev teaching aid) ─────────────────── */
.vuln-note {
  font-size: 11px; font-family: 'Courier New', monospace;
  background: #fffde7; border: 1px solid #f9a825; border-radius: 4px;
  padding: 2px 7px; color: #f57f17; margin-left: 8px;
  vertical-align: middle; white-space: nowrap;
}

/* ─── HEADER ACTIONS / NOTIFICATIONS ─────────────────────── */
.header-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 8px;
  border: 1.5px solid var(--gray-200); background: var(--white);
  cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s; color: var(--gray-700);
}
.icon-btn:hover { background: var(--gray-100); border-color: var(--gray-500); }
.notif-dot {
  position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 100px; background: var(--red-700); color: #fff; font-size: 10px; font-weight: 700;
  display: none; align-items: center; justify-content: center; border: 2px solid var(--white); line-height: 1;
}

/* ─── FOOTER ─────────────────────────────────────────────── */
.app-footer {
  flex-shrink: 0; padding: 14px 32px; border-top: 1px solid var(--gray-200);
  background: var(--white); display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--gray-500); gap: 12px; flex-wrap: wrap;
}
.app-footer .footer-links { display: flex; gap: 14px; flex-wrap: wrap; }
.app-footer a { color: var(--gray-500); text-decoration: none; }
.app-footer a:hover { color: var(--blue-700); text-decoration: underline; }

/* ─── SKELETON LOADERS ───────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, #e4e7ec 37%, var(--gray-200) 63%);
  background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: 6px;
}
@keyframes skeleton-loading {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.skeleton-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.skeleton-row:last-child { border-bottom: none; }
.skeleton-icon { width: 38px; height: 38px; border-radius: 8px; flex-shrink: 0; }
.skeleton-line { height: 11px; }
.skeleton-block { height: 16px; margin-bottom: 10px; }

/* ─── EMPTY STATE ────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 52px 20px; text-align: center; color: var(--gray-500);
}
.empty-state .empty-icon { font-size: 32px; margin-bottom: 10px; opacity: .55; }
.empty-state .empty-title { font-size: 14px; font-weight: 600; color: var(--gray-700); margin-bottom: 3px; }
.empty-state .empty-sub { font-size: 12.5px; max-width: 320px; }

/* ─── TOOLTIP (disabled actions) ─────────────────────────── */
.tooltip-wrap { position: relative; display: inline-flex; }
.tooltip-wrap[data-tooltip]:hover::after {
  content: attr(data-tooltip); position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%); background: var(--gray-900); color: #fff; font-size: 11px;
  padding: 6px 10px; border-radius: 6px; white-space: nowrap; box-shadow: var(--shadow-md); z-index: 20;
}
.tooltip-wrap[data-tooltip]:hover::before {
  content: ''; position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--gray-900);
}
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }
.tooltip-wrap .btn:disabled, .tooltip-wrap .btn.disabled { pointer-events: none; }

/* ─── SPECIALTY TAG ──────────────────────────────────────── */
.specialty-tag { font-size: 11.5px; color: var(--gray-500); font-weight: 500; }

/* ─── BILLING WIDGETS ────────────────────────────────────── */
.insurance-card {
  background: linear-gradient(135deg, var(--blue-900), var(--blue-500));
  color: #fff; border-radius: 12px; padding: 24px 26px; position: relative; overflow: hidden;
}
.insurance-card .plan-name { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.insurance-card .plan-sub { font-size: 12.5px; opacity: .85; margin-top: 2px; }
.insurance-card .insurance-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 18px; margin-top: 20px;
}
.insurance-card .insurance-field-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; opacity: .72; }
.insurance-card .insurance-field-value { font-size: 14.5px; font-weight: 700; margin-top: 3px; }
.insurance-card .card-chip { position: absolute; top: 22px; right: 26px; font-size: 28px; opacity: .5; }

.amount-due-card { text-align: center; }
.amount-due-card .amount { font-size: 32px; font-weight: 800; color: var(--gray-900); margin: 6px 0; }
.amount-due-card .amount.zero { color: var(--green-700); }

.claim-row-desc { font-weight: 600; color: var(--gray-900); font-size: 14px; }
.claim-row-meta { font-size: 12px; color: var(--gray-500); margin-top: 1px; }

/* ─── TOAST ──────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--gray-900); color: #fff; padding: 12px 22px; border-radius: 8px; font-size: 13px;
  box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── PROFILE EDIT FORM ──────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid .form-group { margin-bottom: 0; }
.form-group input[disabled] { background: var(--gray-100); color: var(--gray-500); cursor: not-allowed; }

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .grid-2, .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .content-area { padding: 20px 16px; }
  .app-footer { padding: 12px 16px; flex-direction: column; align-items: flex-start; gap: 6px; }
}
