:root {
  --navy: #102a43;
  --navy-2: #1f4b6e;
  --blue-soft: #edf5fb;
  --gold: #f2b134;
  --text: #152536;
  --muted: #64748b;
  --line: #dbe5ee;
  --surface: #ffffff;
  --background: #f4f7fa;
  --danger: #b42318;
  --success: #067647;
  --warning: #9a6700;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--background); }
a { color: inherit; }
.topbar {
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: white;
  background: var(--navy);
}
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  font-weight: 800; background: var(--gold); color: var(--navy); flex: 0 0 auto;
}
.brand strong, .brand small { display: block; }
.brand small { opacity: .75; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { padding: 8px 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; }
.topbar-button { color: white; border: 1px solid rgba(255,255,255,.3); background: transparent; padding: 8px 12px; }
.main-nav {
  padding: 0 clamp(16px, 4vw, 48px);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: white;
  border-bottom: 1px solid var(--line);
}
.main-nav a {
  padding: 14px 16px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}
.main-nav a.active { color: var(--navy); border-color: var(--gold); }
.container { width: min(1220px, calc(100% - 32px)); margin: 32px auto; }
.auth-shell { min-height: calc(100vh - 150px); display: grid; place-items: center; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: clamp(22px, 4vw, 34px); box-shadow: 0 16px 42px rgba(16,42,67,.07);
  margin-bottom: 22px;
}
.table-panel { padding: 0; overflow: hidden; }
.auth-shell .panel { width: min(480px, 100%); }
.auth-shell .panel.wide { width: min(820px, 100%); }
h1 { margin: 4px 0 8px; font-size: clamp(30px, 5vw, 46px); line-height: 1.05; }
h2 { margin: 0 0 16px; font-size: 1.35rem; }
.form-panel h2 { margin-top: 26px; }
.form-panel h2:first-of-type { margin-top: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 800; color: var(--navy-2); }
.muted { color: var(--muted); }
label { display: block; font-weight: 700; margin: 15px 0; }
input, select, textarea {
  width: 100%; margin-top: 7px; padding: 13px 14px; border: 1px solid #bccbd8;
  border-radius: 12px; font: inherit; color: var(--text); background: white;
}
textarea { resize: vertical; }
input[type="file"] { padding: 10px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(31,75,110,.15); border-color: var(--navy-2); }
.grid.two { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 18px; }
.span-two { grid-column: 1 / -1; }
.button {
  border: 0; border-radius: 12px; padding: 12px 18px; font: inherit; font-weight: 800;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.button.primary { color: white; background: var(--navy); }
.button.secondary { color: var(--navy); background: var(--blue-soft); }
.button.ghost { color: var(--navy); background: white; border: 1px solid var(--line); }
.button.full { width: 100%; margin-top: 18px; }
.button.danger-button { color: white; background: var(--danger); }
.alert { padding: 13px 16px; border-radius: 12px; margin-bottom: 18px; border: 1px solid; }
.alert-success { color: var(--success); background: #ecfdf3; border-color: #abefc6; }
.alert-danger { color: var(--danger); background: #fef3f2; border-color: #fecdca; }
.alert-warning { color: #854a0e; background: #fffaeb; border-color: #fedf89; }
.error { display: block; color: var(--danger); font-weight: 500; font-size: .87rem; margin-top: 5px; }
.page-head, .section-head, .status-row, .danger-zone {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
}
.page-head { margin-bottom: 24px; }
.page-actions, .form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-actions { justify-content: flex-end; margin-top: 26px; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 22px; }
.metric { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.metric-alert { border-color: #fedf89; background: #fffcf5; }
.metric span, .metric small, td small { display: block; color: var(--muted); }
.metric strong { display: block; font-size: 2.5rem; margin: 10px 0; color: var(--navy); }
.metric a, .text-link { color: var(--navy-2); font-weight: 800; text-decoration: none; }
.badge { display: inline-flex; align-items: center; padding: 7px 10px; border-radius: 999px; font-size: .78rem; font-weight: 900; white-space: nowrap; }
.badge.success { color: var(--success); background: #dcfae6; }
.badge.warning { color: var(--warning); background: #fff3cd; }
.badge.danger { color: var(--danger); background: #fee4e2; }
.badge.neutral { color: #475467; background: #f2f4f7; }
.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 220px auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}
.filter-bar input, .filter-bar select { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px 18px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; background: #f9fbfc; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 4px; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions form { display: inline; margin-left: 10px; }
.link-button { border: 0; padding: 0; background: none; font: inherit; font-weight: 800; cursor: pointer; }
.danger-text { color: var(--danger); }
.empty-state { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--text); font-size: 1.1rem; }
.empty-state.compact { padding: 24px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 22px; }
.details { margin: 0; display: grid; gap: 16px; }
.details div { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.details div:last-child { border-bottom: 0; padding-bottom: 0; }
.details dt { color: var(--muted); font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.details dd { margin: 5px 0 0; font-weight: 700; }
.expiry-list { display: grid; gap: 12px; }
.expiry-item { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.expiry-item:last-child { border-bottom: 0; }
.expiry-item small, .expiry-right small { display: block; color: var(--muted); margin-top: 5px; }
.expiry-right { text-align: right; }
.date-note { margin-top: 4px; }
.upload-box { margin-top: 22px; padding: 16px 18px; border: 1px dashed #9fb4c6; border-radius: 14px; background: #f9fbfc; }
.upload-box summary { cursor: pointer; color: var(--navy); font-weight: 900; }
.upload-box form { margin-top: 16px; }
.danger-zone { align-items: center; border-color: #fecdca; }
.danger-zone h2 { margin-bottom: 6px; }
.pre-wrap { white-space: pre-wrap; }
@media (max-width: 950px) {
  .cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .filter-bar { grid-template-columns: 1fr 180px auto; }
  .filter-bar .ghost { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .grid.two, .cards, .detail-grid, .filter-bar { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .page-head, .section-head, .status-row, .danger-zone { align-items: stretch; flex-direction: column; }
  .page-actions, .form-actions { width: 100%; }
  .page-actions .button, .form-actions .button { flex: 1; }
  .user-chip { display: none; }
  .topbar { padding-inline: 16px; }
  .brand small { display: none; }
  .container { width: min(100% - 20px, 1220px); margin-top: 20px; }
  .panel { border-radius: 16px; padding: 20px; }
  .table-panel { padding: 0; }
  th, td { padding: 14px; }
  .expiry-item { align-items: flex-start; }
}
/* Clients V1 */
.clients-filter { grid-template-columns: minmax(240px, 1fr) 170px 190px auto auto; }
.checkbox-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0 18px; }
.checkbox-card {
  display: flex; align-items: center; gap: 11px; min-height: 58px; margin: 0; padding: 14px;
  border: 1px solid var(--line); border-radius: 14px; background: #f9fbfc; cursor: pointer;
}
.checkbox-card input { width: 20px; height: 20px; margin: 0; }
.field-help, .security-note { display: block; margin-top: 6px; color: var(--muted); font-size: .82rem; font-weight: 500; }
.client-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 22px; }
.tag-stack, .document-checks { display: flex; flex-wrap: wrap; gap: 7px; }
.check-ok, .check-missing {
  display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 900;
}
.check-ok { color: var(--success); background: #dcfae6; }
.check-ok::before { content: "✓"; margin-right: 5px; }
.check-missing { color: var(--danger); background: #fee4e2; }
.check-missing::before { content: "!"; margin-right: 5px; }
.sensitive-panel { border-color: #b8cce0; background: linear-gradient(180deg, #fbfdff, #ffffff); }
.lock-chip { display: inline-flex; padding: 7px 10px; border-radius: 999px; background: var(--blue-soft); color: var(--navy); font-size: .76rem; font-weight: 900; }
.masked-sensitive, .revealed-sensitive { display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; }
.revealed-sensitive { padding: 9px 11px; border-radius: 9px; background: #fff3cd; color: #7a5200; font-weight: 900; }
.inline-reveal { display: inline-block; margin-left: 10px; }
.small-button { padding: 7px 10px; font-size: .8rem; }
@media (max-width: 1050px) {
  .clients-filter { grid-template-columns: 1fr 170px 190px auto; }
  .clients-filter .ghost { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .clients-filter, .checkbox-grid { grid-template-columns: 1fr; }
  .inline-reveal { display: block; margin: 10px 0 0; }
}
