:root {
  --navy: #1A2744;
  --gold: #C9972E;
  --teal: #13938A;
  --paper: #FAF7F1;
  --ink: #1A2744;
  --muted: #5b6577;
  --line: #e4ddcf;
  --white: #ffffff;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(26, 39, 68, 0.10);
  font-family: "IBM Plex Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
h1 { font-family: "Fraunces", Georgia, serif; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--muted); line-height: 1.5; }
a { color: var(--teal); }

.brand-mark {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: 0.02em;
}

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100vh; display: flex; }
.auth-wrap {
  margin: auto; width: 100%; max-width: 420px; padding: 32px;
  display: flex; flex-direction: column; gap: 18px;
}
.auth-card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px;
}
.auth-card .brand-mark { font-size: 20px; margin-bottom: 18px; display: block; }
.auth-card h1 { margin: 0 0 8px; font-size: 26px; }
.auth-card form { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.auth-card label { font-size: 13px; font-weight: 500; color: var(--muted); }
.auth-card input {
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--paper);
}
.auth-card input:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
button, .button-link {
  margin-top: 8px; padding: 11px 16px; border: 0; border-radius: 8px;
  background: var(--navy); color: var(--white); font: inherit; font-weight: 600;
  cursor: pointer; text-align: center; text-decoration: none; display: inline-block;
}
button:hover, .button-link:hover { background: #223358; }
.text-link { display: inline-block; margin-top: 16px; font-size: 14px; }
.auth-footer { text-align: center; font-size: 13px; }

/* ---------- App shell ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: var(--white); padding: 14px 22px;
}
.topbar-brand { display: flex; align-items: center; gap: 14px; }
.topbar .brand-mark { color: var(--white); font-size: 19px; }
.firm-name { font-weight: 600; }
.plan-badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,0.14);
}
.plan-badge.plan-team { background: var(--gold); color: var(--navy); }
.topbar-user { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.logout { color: #cdd6e6; text-decoration: none; }
.logout:hover { color: var(--white); }

.shell-body { display: flex; min-height: calc(100vh - 56px); }
.sidenav { width: 220px; background: var(--white); border-right: 1px solid var(--line); padding: 18px 12px; }
.sidenav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  padding: 10px 14px; border-radius: 8px; font-weight: 500; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-item.active { background: var(--paper); color: var(--navy); }
.nav-item.available a { color: var(--navy); text-decoration: none; display: block; }
.nav-item.available:hover { background: var(--paper); }
.nav-item.locked { color: #aeb4c0; cursor: not-allowed; }
.nav-item.team-only .lock-tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--gold); color: var(--navy); padding: 2px 6px; border-radius: 999px;
}

.content { flex: 1; padding: 36px 40px; max-width: 900px; }
.content h1 { font-size: 30px; margin: 0 0 8px; }
.card-row { display: flex; gap: 16px; margin: 28px 0; flex-wrap: wrap; }
.stat-card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 24px; min-width: 140px;
}
.stat-value { font-family: "Fraunces", Georgia, serif; font-size: 30px; color: var(--navy); }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.upsell {
  background: #fdf6e6; border: 1px solid var(--gold); border-radius: var(--radius);
  padding: 16px 18px; color: #6b531a; font-size: 14px;
}
.stat-link { text-decoration: none; display: block; transition: border-color .1s; }
.stat-link:hover { border-color: var(--teal); }

/* ---------- Page head + actions ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-actions { display: flex; gap: 10px; }
.button-link.secondary { background: var(--white); color: var(--navy); border: 1px solid var(--line); }
.button-link.secondary:hover { background: var(--paper); }
.small { font-size: 13px; }

/* ---------- Filter tabs ---------- */
.filter-tabs { display: flex; gap: 6px; margin: 20px 0 14px; border-bottom: 1px solid var(--line); }
.filter-tabs a {
  padding: 8px 14px; text-decoration: none; color: var(--muted); font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.filter-tabs a.on { color: var(--navy); border-bottom-color: var(--gold); font-weight: 600; }

/* ---------- Data table ---------- */
.data-table { width: 100%; border-collapse: collapse; background: var(--white);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.data-table th { background: var(--paper); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table a { color: var(--navy); font-weight: 500; }
.row-inactive { opacity: 0.6; }
.row-actions { display: flex; gap: 12px; align-items: center; }
.status-pill { font-size: 12px; padding: 2px 9px; border-radius: 999px; }
.status-active { background: #e3f3f0; color: var(--teal); }
.status-inactive { background: #eee; color: #777; }
.link-button { background: none; border: 0; color: var(--teal); cursor: pointer; font: inherit; padding: 0; margin: 0; }
.link-button:hover { text-decoration: underline; background: none; }
.row-actions form { display: inline; margin: 0; }
.table-scroll { overflow-x: auto; }
.preview-table th, .preview-table td { white-space: nowrap; }

.empty-state { background: var(--white); border: 1px dashed var(--line); border-radius: var(--radius); padding: 36px; text-align: center; margin-top: 18px; }

/* ---------- Forms ---------- */
.form-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 26px; margin-top: 18px; max-width: 720px; }
.form-card fieldset { border: 0; padding: 0; margin: 0 0 22px; }
.form-card legend { font-family: "Fraunces", Georgia, serif; font-size: 18px; color: var(--navy); margin-bottom: 12px; padding: 0; }
.form-card legend .hint { font-family: "IBM Plex Sans", sans-serif; font-size: 13px; color: var(--muted); font-weight: 400; }
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }
.field label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--paper); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
.field .req { color: var(--gold); }
.checkboxes { justify-content: flex-end; gap: 8px; }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.check input { width: auto; }
.form-actions { display: flex; align-items: center; gap: 16px; margin-top: 8px; }
.form-errors { background: #fdecea; border: 1px solid #e2a39c; border-radius: var(--radius); padding: 12px 16px; color: #8a2b20; margin: 16px 0; }
.form-errors ul { margin: 0; padding-left: 18px; }

/* ---------- Import ---------- */
.import-grid { display: flex; gap: 18px; flex-wrap: wrap; }
.import-grid .form-card { flex: 1; min-width: 280px; margin-top: 18px; }
.disabled-card { opacity: 0.8; }
button.disabled, button:disabled { background: #cfd4dd; color: #fff; cursor: not-allowed; }
