/* Shared styling.
   Inter for the interface, Source Serif 4 for entity names and section titles, JetBrains
   Mono for identifiers. All self-hosted — see assets/fonts/fonts.css. */

@import url('/assets/fonts/fonts.css');

:root {
  --navy: #0f253f;          /* sampled from the Voltalia wordmark */
  --ink: #14532d;
  --accent: #3f7d5c;
  --muted: #5b6b60;
  --rule: #e3e9e4;
  --bg: #f5f7f5;
  --surface: #ffffff;
  --danger: #a3341f;
  --danger-bg: #fdf1ee;
  --warn: #8a6100;
  --warn-bg: #fdf7e8;
  --ok: #1f6f43;
  --ok-bg: #edf7f0;
  --radius: 12px;
  /* Two shadows: a hairline that reads as a border at any zoom, and a soft lift. */
  --shadow: 0 1px 1px rgba(16, 40, 26, .04), 0 4px 12px rgba(16, 40, 26, .05);
  --shadow-lg: 0 1px 2px rgba(16, 40, 26, .05), 0 12px 32px rgba(16, 40, 26, .10);
  --ring: 0 0 0 3px rgba(63, 125, 92, .22);

  --serif: 'SourceSerif4', "Iowan Old Style", Palatino, Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: 'JetBrainsMono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: #1c2620;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  letter-spacing: -.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Identifiers, counts and money-like values must not jitter as digits change, and the
   zero needs to be distinguishable from an O in a matricule. */
.mono, .field-code, .stat .n, table td, input {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'zero' 1;
}

a { color: var(--ink); }

/* ---------------------------------------------------------------- chrome */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 28px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 10;
}
/* Logo, then a hairline, then the application name — so the Voltalia mark reads as the
   owner of the tool rather than as part of its title. */
.topbar .logo { height: 26px; width: auto; display: block; flex: 0 0 auto; }
.topbar .divider {
  width: 1px;
  height: 22px;
  background: var(--rule);
  flex: 0 0 auto;
}
.topbar .brand {
  font-family: var(--serif);
  font-size: 17.5px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -.015em;
}
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13.5px; }
.topbar .who strong { color: #1c2620; font-weight: 600; }

main { max-width: 1180px; margin: 0 auto; padding: 28px; }
.page-title { font-family: var(--serif); font-size: 26px; margin: 0 0 4px; color: var(--ink); }
.page-sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

/* ---------------------------------------------------------------- buttons */

button, .btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  letter-spacing: -.004em;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid #d9e2dc;
  background: var(--surface);
  color: #1c2620;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 1px rgba(16, 40, 26, .04);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
button:hover, .btn:hover { background: #f4f7f5; border-color: #c4d2cb; }
button:active, .btn:active { box-shadow: none; transform: translateY(.5px); }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary, button.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.btn-primary:hover, button.primary:hover { background: #0f4023; border-color: #0f4023; }
.btn-primary, button.primary { box-shadow: 0 1px 2px rgba(16, 40, 26, .18); }
.btn-danger { color: var(--danger); border-color: #eccfc7; background: var(--danger-bg); }
.btn-danger:hover { background: #fae4de; border-color: #e0b7ac; }
.btn-sm { padding: 5px 11px; font-size: 13px; }

.login-logo { display: block; height: 40px; width: auto; margin: 0 auto 22px; }

/* ---------------------------------------------------------------- the card */

.card-frame {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 34px;
}

/* The card header carries the mark on the right, balancing the entity name. */
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.card-head .mark { height: 42px; width: auto; flex: 0 0 auto; margin-top: 2px; opacity: .95; }

.card-kicker {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .15em;
  color: var(--accent);
  text-transform: uppercase;
  margin: 0 0 7px;
}
.card-entity {
  font-family: var(--serif);
  font-size: 33px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 26px;
  letter-spacing: -.02em;
  line-height: 1.15;
}

/* The QR is centred and given as much width as the card allows: it is meant to be held
   up to somebody else's phone, and a bigger target scans faster and from further away.
   The values sit underneath as the fallback for when scanning is not possible. */
.qr-block { margin: 4px auto 0; width: fit-content; }
.qr-box {
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 18px;
  background: #ffffff;
  width: min(360px, 100%);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-box img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.qr-caption {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 12px;
  letter-spacing: .01em;
}

.fields { margin-top: 26px; }
.field-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 4px 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  align-items: start;
}
.field-row:last-child { border-bottom: 0; }

/* Wide enough for two columns of values, so a desktop card is not a tall ribbon. */
@media (min-width: 760px) {
  .card-stacked .fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 44px;
    row-gap: 2px;
    border-top: 1px solid var(--rule);
    padding-top: 18px;
  }
  /* Per-row rules cannot line up across two columns of unequal height, so the grid gets
     one rule at the top and spacing does the rest. */
  .card-stacked .field-row { border-bottom: 0; padding: 10px 0; }
  /* The reception address is the longest value; give it the full width. */
  .card-stacked .field-row:nth-child(3) { grid-column: 1 / -1; }
}
.field-code {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: .02em;
  padding-top: 4px;
}
.field-label { font-size: 12.5px; color: var(--muted); letter-spacing: 0; }
.field-value {
  grid-column: 2;
  font-size: 16.5px;
  font-weight: 600;
  color: #16201a;
  letter-spacing: -.012em;
  word-break: break-word;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
  flex-wrap: wrap;
}
.card-meta { color: var(--muted); font-size: 12.5px; margin-left: auto; align-self: center; }

/* ---------------------------------------------------------------- notices */

.notice {
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  border: 1px solid;
  margin-bottom: 18px;
}
.notice h3 { margin: 0 0 4px; font-size: 13.5px; font-weight: 600; letter-spacing: -.005em; }
.notice p { margin: 0; }
.notice-warn { background: var(--warn-bg); border-color: #ecd9a8; color: var(--warn); }
.notice-danger { background: var(--danger-bg); border-color: #eccfc7; color: var(--danger); }
.notice-ok { background: var(--ok-bg); border-color: #c8e2d1; color: var(--ok); }
.notice-info { background: #f0f4f8; border-color: #d5e0ea; color: #33546f; }

.page-foot {
  text-align: center;
  margin-top: 26px;
  color: var(--muted);
  font-size: 12px;
}
.page-foot img { height: 18px; width: auto; vertical-align: -4px; margin-right: 7px; opacity: .75; }

.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}
.empty h2 {
  font-family: var(--serif);
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.015em;
  margin: 0 0 8px;
}

/* ---------------------------------------------------------------- admin */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 24px; }
.tab {
  padding: 10px 15px;
  border: 0;
  background: none;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 550;
  font-size: 13.5px;
  box-shadow: none;
}
.tab:focus-visible { box-shadow: none; outline: 2px solid var(--accent); outline-offset: -2px; }
.tab:hover { background: none; color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 16px 18px;
}
.stat .n {
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.05;
  letter-spacing: -.02em;
}
.stat .k { font-size: 12px; color: var(--muted); margin-top: 5px; letter-spacing: 0; }
.stat.alert .n { color: var(--danger); }

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 20px;
}
.panel h2 {
  font-family: var(--serif);
  font-size: 18.5px;
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--ink);
  margin: 0 0 5px;
}
.panel .hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; letter-spacing: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  font-weight: 600;
  padding: 9px 10px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
td { padding: 10px 10px; border-bottom: 1px solid #f0f3f1; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfa; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -.01em; }
.dim { color: var(--muted); }
.nowrap { white-space: nowrap; }
.table-scroll { overflow-x: auto; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 550;
  letter-spacing: .002em;
  border: 1px solid;
  white-space: nowrap;
}
.pill-ok { background: var(--ok-bg); border-color: #c8e2d1; color: var(--ok); }
.pill-off { background: #f2f4f2; border-color: var(--rule); color: var(--muted); }
.pill-danger { background: var(--danger-bg); border-color: #eccfc7; color: var(--danger); }
.pill-warn { background: var(--warn-bg); border-color: #ecd9a8; color: var(--warn); }

input, select {
  font: inherit;
  font-size: 13.5px;
  padding: 8px 11px;
  border: 1px solid #d9e2dc;
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder { color: #9aa8a0; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 550;
  letter-spacing: .002em;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; align-items: end; }
.field { min-width: 0; }
/* Not `display: flex` — a flex <td> stops participating in row-height equalisation, which
   leaves its border-bottom drawn at a different height from the rest of the row. The
   buttons are already inline-flex, so alignment only needs text-align. */
.row-actions { text-align: right; white-space: nowrap; }
.row-actions > * + * { margin-left: 6px; }

dialog {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow-lg), 0 24px 64px rgba(16, 40, 26, .16);
  max-width: 620px;
  width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(20, 40, 28, .35); }
.dialog-body { padding: 24px 26px; }
.dialog-body h2 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--ink);
  margin: 0 0 4px;
}
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.brand-short { display: none; }

@media (max-width: 720px) {
  main { padding: 18px; }
  .topbar { padding: 12px 16px; gap: 10px; }
  /* The full title needs three lines on a phone, which pushes the card off screen. */
  /* Logo, who you are, and the way out. The card underneath already announces what
     this page is, so the application title only crowds a 390px bar. */
  .topbar .brand { display: none; }
  .topbar .divider { display: none; }
  .topbar .logo { height: 22px; }
  .topbar .who { font-size: 12.5px; line-height: 1.35; }
  .card-head .mark { height: 30px; }
  .card-kicker { font-size: 10px; letter-spacing: .12em; }
  .topbar .who { font-size: 12px; }
  .card-frame { padding: 18px; }
  .card-entity { font-size: 26px; }
  /* Edge to edge on a phone: this is the screen someone actually holds up to a scanner. */
  .qr-block { width: 100%; }
  .qr-box { width: 100%; padding: 12px; border-radius: 10px; }
  .qr-caption { font-size: 12.5px; }
  .fields { margin-top: 20px; }
  .card-actions .btn { flex: 1 1 auto; justify-content: center; }
  .card-meta { margin-left: 0; flex-basis: 100%; text-align: center; }
}
