/* ============================================================
   FND Portal - light theme design system
   Deliberately not derived from the spreadsheet export.
   ============================================================ */

:root {
  color-scheme: light;

  --bg:            #f2f5fa;
  --bg-accent:     #e8edf7;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --surface-3:     #f1f5f9;

  --ink:           #101828;
  --ink-2:         #344054;
  --muted:         #667085;
  --faint:         #98a2b3;

  --line:          #e4e9f0;
  --line-strong:   #d0d7e2;

  --brand:         #2f5bd7;
  --brand-dark:    #2447ab;
  --brand-soft:    #eef2ff;
  --brand-ring:    rgba(47, 91, 215, .18);

  --green:         #0e7a4a;
  --green-soft:    #e6f6ed;
  --amber:         #92600b;
  --amber-soft:    #fdf3d7;
  --red:           #b42318;
  --red-soft:      #fdeceb;
  --rose:          #a4322a;
  --rose-soft:     #fdf1f0;
  --grey:          #475467;
  --grey-soft:     #eef1f5;

  --radius:        12px;
  --radius-sm:     8px;
  --shadow-sm:     0 1px 2px rgba(16, 24, 40, .05);
  --shadow:        0 4px 14px rgba(16, 24, 40, .07);
  --shadow-lg:     0 16px 44px rgba(16, 24, 40, .12);

  --font: "Segoe UI", Inter, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

[hidden] { display: none !important; }

/* ---------------- shell ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.topbar__inner {
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 22px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 26px;
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.brand__mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--brand) 0%, #5b86ea 100%);
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
}

.brand__name { font-weight: 680; font-size: 15px; letter-spacing: -.01em; }

.nav { display: flex; gap: 4px; margin-right: auto; }

.nav__link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 560;
  font-size: 13.5px;
  white-space: nowrap;
}
.nav__link:hover { background: var(--surface-3); text-decoration: none; }
.nav__link.is-active { background: var(--brand-soft); color: var(--brand-dark); }

.userbox { display: flex; align-items: center; gap: 12px; }

.userbox__avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-dark);
  display: grid; place-items: center; font-weight: 680; font-size: 12px;
}

.userbox__link {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px; margin: -4px -8px;
  border-radius: var(--radius-sm, 8px);
  text-decoration: none; color: inherit;
}
.userbox__link:hover { background: var(--surface-3); }
.userbox__meta { line-height: 1.25; }
.userbox__name { font-weight: 600; font-size: 13px; }
.userbox__mail { color: var(--muted); font-size: 11.5px; }

.page {
  max-width: 1560px;
  margin: 0 auto;
  padding: 26px 22px 64px;
}

.page__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page__title { font-size: 22px; }
.page__sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.crumbs span { margin: 0 6px; color: var(--faint); }

/* ---------------- buttons & inputs ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit; font-weight: 580; font-size: 13.5px;
  cursor: pointer;
  transition: background .13s, border-color .13s, box-shadow .13s;
}
.btn:hover { background: var(--surface-3); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }

.btn--primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-3); }

.btn--block { width: 100%; height: 42px; }
.btn--sm { height: 32px; padding: 0 11px; font-size: 12.5px; }

.btn[disabled] { opacity: .55; cursor: not-allowed; }

.input, .select {
  height: 38px;
  padding: 0 12px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 13.5px;
  transition: border-color .13s, box-shadow .13s;
}
textarea.input { height: auto; min-height: 76px; padding: 9px 12px; resize: vertical; line-height: 1.5; }

/* Checkbox sitting on the same line as its label (edit forms). */
.checkfield { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; cursor: pointer; }
.checkfield input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.checkfield span { font-size: 13px; font-weight: 550; }

.input:focus, .select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.input::placeholder { color: var(--faint); }

.select { padding-right: 30px; cursor: pointer; }

.field { display: block; margin-bottom: 14px; }
.field__label {
  display: block;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 6px;
}
.field__hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.search { position: relative; }
.search .input { padding-left: 34px; }
.search__icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--faint); pointer-events: none; font-size: 13px;
}

/* ---------------- cards ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card__head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap;
}
.card__title { font-size: 14.5px; font-weight: 650; }
.card__body { padding: 18px; }

/* ---------------- toolbar ---------------- */

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 0;
}
.toolbar .search { flex: 1 1 280px; max-width: 380px; }
/* READ users get no Add button - don't leave its gap behind. */
.toolbar > div:empty { display: none; }
.toolbar__spacer { flex: 1 1 auto; }
.toolbar__count { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 30px; padding: 0 11px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12.5px; font-weight: 560; color: var(--ink-2);
  cursor: pointer;
}
.chip:hover { background: var(--surface-3); }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip__n { opacity: .7; font-variant-numeric: tabular-nums; }

/* ---------------- table ---------------- */

.tablewrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: auto;
  max-height: calc(100vh - 250px);
}
.tablewrap--flat { border-radius: var(--radius); max-height: none; }

table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

table.data thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-strong);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
table.data thead th.no-sort { cursor: default; }
table.data thead th:hover:not(.no-sort) { color: var(--ink-2); }
table.data thead th .arrow { opacity: .45; font-size: 9px; margin-left: 4px; }

table.data tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.center { text-align: center; }
.neg { color: var(--red); font-weight: 600; }
.dash { color: var(--faint); }

/* Wide table: many columns, scrolls sideways inside .tablewrap instead of
   squeezing every column to an unreadable width. */
table.data--wide { width: auto; min-width: 100%; }
table.data--wide thead th,
table.data--wide tbody td { white-space: nowrap; }

/* Free-text columns (Notes, Address, Reason) wrap instead of running away. */
table.data--wide td.cell-wrap { white-space: normal; min-width: 200px; max-width: 300px; }
table.data--wide th.cell-wrap { min-width: 200px; }

/* First column stays put while the rest scrolls. */
table.data--wide th.cell-sticky,
table.data--wide td.cell-sticky {
  position: sticky; left: 0;
  border-right: 1px solid var(--line-strong);
}
table.data--wide td.cell-sticky { z-index: 1; background: var(--surface); }
table.data--wide thead th.cell-sticky { z-index: 3; background: var(--surface-2); }
table.data--wide tbody tr:hover td.cell-sticky { background: var(--surface-2); }

/* Row actions stay reachable on the right edge however far the table scrolls. */
table.data--wide th.cell-actions,
table.data--wide td.cell-actions {
  position: sticky; right: 0;
  border-left: 1px solid var(--line-strong);
}
table.data--wide td.cell-actions { z-index: 1; background: var(--surface); }
table.data--wide thead th.cell-actions { z-index: 3; background: var(--surface-2); }
table.data--wide tbody tr:hover td.cell-actions { background: var(--surface-2); }

.cell-name { min-width: 260px; }
.cell-info { color: var(--ink-2); max-width: 460px; }
.cell-info--empty { color: var(--faint); }

.link-strong { font-weight: 600; color: var(--brand); }
.link-strong:hover { color: var(--brand-dark); }

/* ---------------- badges / flags ---------------- */

.badge {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 10px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  white-space: nowrap;
}
.badge--green { background: var(--green-soft); color: var(--green); }
.badge--amber { background: var(--amber-soft); color: var(--amber); }
.badge--red   { background: var(--red-soft);   color: var(--red); }
.badge--rose  { background: var(--rose-soft);  color: var(--rose); }
.badge--grey  { background: var(--grey-soft);  color: var(--grey); }
.badge--blue  { background: var(--brand-soft); color: var(--brand-dark); }

.flag {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px;
  border-radius: 6px;
  font-size: 11px; font-weight: 800;
}
.flag--on  { background: var(--green-soft); color: var(--green); }
.flag--off { background: var(--surface-3);  color: var(--faint); }

.bool { font-weight: 650; font-size: 12px; letter-spacing: .03em; }
.bool--true  { color: var(--green); }
.bool--false { color: var(--muted); }

/* ---------------- stats / info block ---------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat__label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.stat__value {
  margin-top: 6px;
  font-size: 19px; font-weight: 660;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.stat__value.is-neg { color: var(--red); }
.stat--accent { background: linear-gradient(180deg, var(--brand-soft) 0%, var(--surface) 70%); }

.infogrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0 28px;
}
.inforow {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.inforow:last-child { border-bottom: 0; }
.inforow__label {
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.inforow__value { font-weight: 620; font-variant-numeric: tabular-nums; }

.meterline { margin-top: 14px; }
.meter {
  height: 8px; border-radius: 999px; background: var(--surface-3);
  overflow: hidden; border: 1px solid var(--line);
}
.meter__fill { height: 100%; background: linear-gradient(90deg, var(--brand) 0%, #5b86ea 100%); }
.meter__fill.is-over { background: linear-gradient(90deg, #d3372b 0%, #ef6a5f 100%); }
.meter__caption {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-top: 7px;
}

/* ---------------- notes / empty ---------------- */

.note {
  display: flex; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  border: 1px solid #dbe4fb;
  color: var(--ink-2);
  font-size: 13px;
}
.note--warn { background: var(--amber-soft); border-color: #f3e2b3; }
.note--danger { background: var(--red-soft); border-color: #f7d2ce; color: var(--red); }
.note__icon { flex-shrink: 0; }

.empty {
  padding: 52px 24px;
  text-align: center;
  color: var(--muted);
}
.empty__title { font-weight: 650; color: var(--ink-2); margin-bottom: 6px; font-size: 15px; }

/* ---------------- auth screen ---------------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
  background:
    radial-gradient(1100px 520px at 12% -8%, #dfe8fb 0%, rgba(223, 232, 251, 0) 60%),
    radial-gradient(900px 480px at 92% 8%, #e6ecfa 0%, rgba(230, 236, 250, 0) 55%),
    var(--bg);
}

.auth__card {
  width: 100%;
  max-width: 424px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 30px 30px 26px;
}

.auth__brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth__title { font-size: 19px; margin-bottom: 6px; }
.auth__sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }

.auth__foot {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

.steps { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }
.step {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--faint); font-weight: 560;
}
.step__dot {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface-3); color: var(--faint);
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700;
}
.step.is-active { color: var(--brand-dark); }
.step.is-active .step__dot { background: var(--brand); color: #fff; }
.step.is-done { color: var(--green); }
.step.is-done .step__dot { background: var(--green-soft); color: var(--green); }
.step__line { flex: 1; height: 1px; background: var(--line-strong); }

.code-input {
  width: 100%;
  height: 54px;
  text-align: center;
  font-family: var(--mono);
  font-size: 26px;
  letter-spacing: .34em;
  text-indent: .34em;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
}
.code-input:focus {
  outline: none; border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.qr {
  display: grid; place-items: center;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: 0 auto 14px;
  width: fit-content;
}
.qr img, .qr canvas, .qr table { display: block; width: 188px; height: 188px; image-rendering: pixelated; }

.secret {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
}
.secret__value { flex: 1; }

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}
.alert--error { background: var(--red-soft); border: 1px solid #f7d2ce; color: var(--red); }
.alert--ok { background: var(--green-soft); border: 1px solid #cdead9; color: var(--green); }

.olist { margin: 0 0 16px; padding-left: 20px; color: var(--ink-2); font-size: 13px; }
.olist li { margin-bottom: 5px; }

/* ---------------- misc ---------------- */

/* ---------------- pager ---------------- */

.pager {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 14px 2px 0;
}
.pager .chip[disabled] { opacity: .45; cursor: not-allowed; }
.pager__gap { color: var(--faint); padding: 0 2px; }
.pager__info { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* ---------------- forms / users page ---------------- */

.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 16px; }
.formgrid .field { margin-bottom: 14px; }
.formgrid .field--full { grid-column: 1 / -1; }

.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions .btn + .btn { margin-left: 6px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mt-0 { margin-top: 0; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

@media (max-width: 860px) {
  .topbar__inner { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 12px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .userbox__meta { display: none; }
  .page { padding: 18px 14px 48px; }
  .tablewrap { max-height: none; }
}
