/* Client Portal 2.0 — shared design tokens and component styles
   Loaded by every mockup HTML file. Tailwind utilities still apply on top. */

:root {
  /* Brand */
  --teal: #1BBDE8;
  --teal-dark: #0d8ab0;
  --gold: #C9A040;
  --gold-soft: #e8d39a;

  /* Neutrals */
  --ink: #1a2835;
  --ink-2: #2c3e50;
  --muted: #5c6f7e;
  --border: #e8edf2;
  --border-strong: #cdd6de;
  --bg: #f4f7fa;
  --card: #ffffff;

  /* Status */
  --success: #16a34a;
  --success-bg: #ecfdf5;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --info: #2563eb;
  --info-bg: #eff6ff;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(20, 30, 50, 0.04);
  --shadow-card: 0 1px 3px rgba(20, 30, 50, 0.04), 0 8px 24px rgba(20, 30, 50, 0.05);
  --shadow-modal: 0 4px 12px rgba(20, 30, 50, 0.08), 0 24px 48px rgba(20, 30, 50, 0.12);

  /* Type */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top app bar (client side) */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-logo { display: flex; align-items: center; line-height: 0; }
.topbar-logo img { height: 34px; width: auto; display: block; }
.topbar-logo .accent { color: var(--teal); }
@media (max-width: 768px) { .topbar-logo img { height: 28px; } }

/* Auth / brand lockup (login, forgot-password, signout, master-login) */
.brand-logo img { height: 44px; width: auto; display: block; margin: 0 auto; }
@media (max-width: 600px) { .brand-logo img { height: 38px; } }
.topbar-nav { display: flex; gap: 4px; margin-left: 24px; }
.topbar-nav a {
  color: var(--muted);
  font-size: 14px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.topbar-nav a.active { color: var(--ink); background: var(--bg); }
.topbar-nav a:hover { color: var(--ink); text-decoration: none; background: var(--bg); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; border-radius: var(--radius-sm);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}

@media (max-width: 768px) {
  .topbar { padding: 0 16px; }
  .topbar-nav { display: none; }
}

/* Main content shell */
.shell { max-width: 1100px; margin: 0 auto; padding: 32px 24px 96px; }
@media (max-width: 768px) { .shell { padding: 16px 16px 96px; } }

/* Card */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 28px;
}
.card-tight { padding: 20px; }
.card h2 { margin: 0 0 6px; font-size: 20px; font-weight: 600; color: var(--ink); }
.card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: var(--ink); }
.card-subtitle { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
  font-family: inherit;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg); border-color: var(--ink); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--bg); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-block { width: 100%; }
.btn-large { padding: 16px 28px; font-size: 16px; min-height: 52px; }

/* Form fields */
.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }
label, .label {
  display: block;
  font-size: 14px; font-weight: 500;
  color: var(--ink); margin-bottom: 6px;
}
.label-helper { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 4px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="date"],
select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-height: 48px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(27, 189, 232, 0.18);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--bg); color: var(--muted); cursor: not-allowed;
}
.field-help { font-size: 13px; color: var(--muted); margin-top: 6px; }
.field-error { font-size: 13px; color: var(--error); margin-top: 6px; }
input.error, select.error, textarea.error { border-color: var(--error); }

/* Checkbox / radio (custom) */
.checkbox, .radio {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; cursor: pointer;
}
.checkbox input, .radio input { width: 20px; height: 20px; margin: 2px 0 0; cursor: pointer; }
.checkbox-text, .radio-text {
  font-size: 15px; color: var(--ink); line-height: 1.5;
}

/* Alerts */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  margin-bottom: 16px;
  display: flex; gap: 10px; align-items: flex-start;
}
.alert-success { background: var(--success-bg); color: #064e3b; border-color: #a7f3d0; }
.alert-error   { background: var(--error-bg);   color: #7f1d1d; border-color: #fecaca; }
.alert-warning { background: var(--warning-bg); color: #78350f; border-color: #fde68a; }
.alert-info    { background: var(--info-bg);    color: #1e3a8a; border-color: #bfdbfe; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1;
}
.badge-success { background: var(--success-bg); color: #065f46; }
.badge-error { background: var(--error-bg); color: #991b1b; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-info { background: var(--info-bg); color: #1e40af; }
.badge-neutral { background: var(--bg); color: var(--muted); }

/* Section / progress */
.section-progress {
  display: flex; gap: 4px; margin-bottom: 24px;
  background: var(--bg); padding: 4px; border-radius: var(--radius-sm);
  overflow-x: auto;
}
.section-progress button {
  flex: 1; padding: 10px 16px;
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--muted);
  border-radius: 6px; white-space: nowrap;
}
.section-progress button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.section-progress button.completed { color: var(--success); }
.section-progress button.completed::before { content: "✓ "; }

/* Sub-header bar (sits below topbar; holds back-link + page title + status) */
.subbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  position: sticky; top: 64px; z-index: 40;
}
.subbar .back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 14px; font-weight: 500;
  padding: 6px 10px; border-radius: var(--radius-sm);
  text-decoration: none;
}
.subbar .back-link:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.subbar-divider { width: 1px; height: 20px; background: var(--border); }
.subbar-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.subbar-spacer { flex: 1; }
@media (max-width: 768px) {
  .subbar { padding: 8px 14px; gap: 8px; }
  .subbar-divider, .subbar-title { display: none; }
}

/* Fixed-to-viewport form footer (autosave + section nav + submit) */
.form-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(20,30,50,0.06);
  z-index: 45;
  padding: 12px 24px max(12px, env(safe-area-inset-bottom));
}
.form-footer-inner {
  max-width: 880px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.autosave-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
  white-space: nowrap;
}
.autosave-status .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--success);
}
.autosave-status.saving .dot { background: var(--warning); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
.form-actions { display: flex; gap: 10px; align-items: center; }

@media (max-width: 768px) {
  .form-footer { padding: 10px 12px max(10px, env(safe-area-inset-bottom)); }
  .form-footer-inner { gap: 8px; flex-wrap: wrap; justify-content: center; }
  .autosave-status { flex-basis: 100%; justify-content: center; font-size: 12px; order: -1; }
  .form-actions { flex: 1; width: 100%; }
  .form-actions .btn { flex: 1; min-height: 46px; padding: 10px 12px; font-size: 14px; }
}

/* Stat / KPI tile */
.tile {
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 20px;
  background: #fff; border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.tile-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.tile-value { font-size: 22px; font-weight: 700; color: var(--ink); }
.tile-meta { font-size: 12px; color: var(--muted); }

/* Mobile bottom nav (clients on phones) */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid var(--border);
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  z-index: 50;
}
.mobile-nav-list { display: flex; }
.mobile-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px;
  font-size: 11px; color: var(--muted); font-weight: 500;
}
.mobile-nav a.active { color: var(--teal); }
.mobile-nav a .icon { font-size: 20px; }
@media (max-width: 768px) { .mobile-nav { display: block; } .shell { padding-bottom: 88px; } }

/* Utility */
.muted { color: var(--muted); }
.center { text-align: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.flex { display: flex; }
.row { display: flex; gap: 16px; align-items: center; }
.between { justify-content: space-between; }
.spacer-1 { height: 8px; } .spacer-2 { height: 16px; } .spacer-3 { height: 24px; } .spacer-4 { height: 32px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
