/* The gate's pages: sign-in, users and access (/_gate/admin) and the
   platform console (/_gate/platform). The product's palette, no fonts to
   fetch: these pages stand before anything else loads. Mobile first where
   it matters: at 390 px nothing may scroll the page sideways, tables turn
   into cards (table.stack) or scroll in their own box (.scroll), and every
   control is at least 44 px tall. */
:root {
  --ground: #05070C;
  --surface: #0C111C;
  --surface-2: #121A2B;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.20);
  --text: #EEF1F6;
  --muted: #AEB7C9;
  --dim: #7C8699;
  --amber: #FFB020;
  --green: #35D488;
  --danger: #FF6B6B;
  --tap: 44px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(800px 500px at 50% -10%, rgba(255, 176, 32, 0.08), transparent 60%), var(--ground);
  color: var(--text);
  font: 400 16px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow-wrap: break-word;
}
.shell { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }

/* the frame: brand, page links, FI | EN */
.masthead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 32px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -0.01em; min-height: var(--tap); margin-right: auto; }
.mark { width: 26px; height: 28px; background: var(--surface-2); border: 2px solid var(--amber); border-radius: 6px 6px 13px 13px; }
.masthead .actions a, .masthead .actions button.link { display: inline-flex; align-items: center; min-height: var(--tap); }
.lang { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.lang a { display: inline-flex; align-items: center; justify-content: center; min-width: var(--tap); min-height: var(--tap); padding: 0 10px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.lang a + a { border-left: 1px solid var(--line-strong); }
.lang a.on { background: var(--surface-2); color: var(--amber); }
.lang a:hover { color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 26px; max-width: 420px; margin: 0 auto; }
.wide .card { max-width: none; margin: 0 0 20px; }
h1 { margin: 0 0 8px; font-size: 26px; line-height: 1.2; }
h2 { margin: 28px 0 12px; font-size: 18px; line-height: 1.3; }
.card h2 { margin-top: 0; }
.sub-item { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.sub-item p { margin: 0 0 8px; }
.muted { color: var(--muted); margin: 0 0 18px; }
.lead { max-width: 62ch; }
.small { color: var(--dim); font-size: 13px; }
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 6px; }
label .small { font-weight: 400; }
input, select {
  width: 100%; max-width: 100%; font: inherit; color: var(--text); background: var(--ground);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 11px 12px; min-height: var(--tap);
}
input:focus, select:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
input.code { font: 600 24px/1.2 ui-monospace, Consolas, monospace; letter-spacing: 0.3em; text-align: center; }
button {
  margin-top: 16px; width: 100%; min-height: var(--tap); border: 0; border-radius: 10px; padding: 12px 16px;
  background: var(--amber); color: #1A1204; font: 700 16px/1 inherit; cursor: pointer;
}
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
button.link { background: none; color: var(--muted); width: auto; min-height: 0; padding: 8px 0; margin-top: 0; font-weight: 500; text-decoration: underline; }
button.danger { background: var(--danger); color: #1F0606; }
.small-btn { width: auto; min-height: 36px; margin: 0 0 0 8px; padding: 8px 12px; font-size: 13px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); }
.small-btn.warn { color: var(--danger); }
.small-btn.delete { background: transparent; color: var(--danger); border: 1px dashed rgba(255, 107, 107, 0.6); font-weight: 600; }
.small-btn.delete:hover { background: rgba(255, 107, 107, 0.08); }
.confirm .before { margin-top: 18px; padding: 14px; border: 1px solid var(--line-strong); border-radius: 12px; }
.confirm .before h2 { font-size: 16px; margin: 0 0 6px; }
.confirm .before .alt-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.confirm .before .alt-actions form { margin: 0; }
.confirm .before .alt-actions .small-btn { margin: 0; min-height: var(--tap); }
.btn-quiet {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600;
}
.btn-quiet:hover { color: var(--text); }
.err { color: var(--danger); margin: 10px 0 0; }
.ok { color: var(--green); }
.notice { margin: 0 0 20px; padding: 12px 16px; border-radius: 12px; border: 1px solid; }
.notice.is-ok { color: var(--green); border-color: rgba(53, 212, 136, 0.45); background: rgba(53, 212, 136, 0.07); }
.notice.is-err { color: var(--danger); border-color: rgba(255, 107, 107, 0.45); background: rgba(255, 107, 107, 0.07); }
a { color: var(--amber); }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.top .actions a { display: inline-flex; align-items: center; min-height: var(--tap); }
.inline { display: inline-flex; align-items: center; margin: 0; }
.inline select { width: auto; min-width: 16em; }
.add .grid { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .add .grid { grid-template-columns: 1.4fr 1fr 1.6fr; } }
.add button { width: auto; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 400; color: var(--text); min-height: var(--tap); margin: 12px 0 0; cursor: pointer; }
label.check input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--amber); }
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--dim); background: var(--surface-2); padding: 10px 12px; white-space: nowrap; }
td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tr.off td { opacity: 0.6; }
.pill { display: inline-block; font-size: 12px; line-height: 1.5; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-strong); white-space: nowrap; color: var(--muted); }
.pill.ok { color: var(--green); border-color: rgba(53, 212, 136, 0.4); }
.pill.off { color: var(--dim); border-style: dashed; }
.pill.role-manager { color: var(--amber); border-color: rgba(255, 176, 32, 0.45); }
.pill.role-admin { color: var(--text); border-color: var(--text); }
.pill.wait { color: var(--amber); border-color: rgba(255, 176, 32, 0.45); border-style: dashed; }
table.log td { font-size: 13px; }
.addr { overflow-wrap: anywhere; }

/* ---- users and access ---------------------------------------------------- */
.viewing { margin: 4px 0 16px; }
.picker { max-width: none; }
.picker label { margin-top: 0; }
.field-row { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.field-row select { flex: 1 1 16em; width: auto; }
.field-row button { width: auto; margin: 0; }
.picker .small { margin: 10px 0 0; }
.users .grid { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .users .grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); } }
.users #add button[type="submit"] { width: auto; }
/* the sign-up form's honeypot (signup.php): off screen, never filled by a person */
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
fieldset.roles { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
fieldset.roles legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 6px; }
@media (min-width: 760px) { fieldset.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; } fieldset.roles legend { grid-column: 1 / -1; } }
label.choice {
  display: flex; gap: 12px; align-items: flex-start; font-weight: 400; margin: 8px 0 0; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: 12px; cursor: pointer; min-height: var(--tap);
}
label.choice:has(input:checked) { border-color: var(--amber); background: rgba(255, 176, 32, 0.05); }
label.choice input { width: 20px; height: 20px; min-height: 0; margin: 2px 0 0; flex: none; accent-color: var(--amber); }
label.choice > span { display: flex; flex-direction: column; gap: 2px; }
/* a role the plan does not offer (managers, plan_role_allowed()) */
label.choice.is-off { opacity: 0.55; cursor: not-allowed; }
fieldset.roles [data-note] { grid-column: 1 / -1; margin: 8px 0 0; }
.hint { margin: 2px 0 0 30px; }
.people-box h2 { margin-top: 32px; }
.filters { display: grid; gap: 0 12px; grid-template-columns: 1fr; margin-bottom: 8px; }
@media (min-width: 760px) { .filters { grid-template-columns: 2fr 1fr 1fr auto; align-items: end; } }
.filter-go { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.filter-go button { width: auto; margin: 0; }
.count { margin: 8px 0; }
.empty { padding: 20px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); }
.acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.acts .small-btn, .acts .inline select { margin: 0; }
.acts .inline { gap: 8px; }
.acts .move select { min-width: 10em; width: auto; }
/* departments (DEPT-1) */
@media (min-width: 760px) { .filters.has-dept { grid-template-columns: 2fr 1fr 1fr 1fr auto; } }
.acts .dept select, .acts .dept-rename input { min-width: 9em; width: auto; margin: 0; }
.bulk-dept { margin: 4px 0 12px; }
.bulk-dept .field-row select { max-width: 24em; }
.dept-add { margin-top: 16px; }
.dept-add .field-row input { flex: 1 1 16em; width: auto; margin: 0; }
.dept-add .field-row button { margin: 0; }
label.pick { display: inline-flex; align-items: center; min-width: var(--tap); min-height: var(--tap); margin: -8px 4px -8px -6px; vertical-align: middle; cursor: pointer; }
label.pick input { width: 20px; height: 20px; min-height: 0; margin: 0 auto; accent-color: var(--amber); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
details.legend { margin: 16px 0 0; }
details.legend summary, details.logbox summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; gap: 8px; }
details.legend summary { color: var(--muted); font-weight: 600; font-size: 14px; }
details.legend summary::before, details.logbox summary::before { content: "▸"; color: var(--dim); }
details[open].legend summary::before, details[open].logbox summary::before { content: "▾"; }
details.legend summary::-webkit-details-marker, details.logbox summary::-webkit-details-marker { display: none; }
details.legend summary, details.logbox summary { list-style: none; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 14px; margin: 10px 0 0; font-size: 14px; }
dt { margin: 0; }
dd { margin: 0; color: var(--muted); }
details.logbox { margin-top: 32px; }
details.logbox summary h2 { margin: 0; }
details.logbox > .small { margin: 12px 0; }
.confirm { max-width: 560px; }
.consequences { margin: 12px 0 20px; padding-left: 20px; color: var(--muted); }
.consequences li { margin: 4px 0; }
.confirm-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.confirm-actions button { width: auto; margin: 0; }

/* invitations, CSV import and the invitation link */
.invites-box h2 { margin-top: 32px; }
.invites-box h2 .small { font-weight: 400; }
.batch p { margin: 0; }
.batch button { width: auto; margin-top: 10px; }
.stat.seats a { display: inline-flex; align-items: center; min-height: 32px; }
#import input[type="file"] { padding: 9px 10px; }
#import button { width: auto; }
/* a pasted list of addresses (UX-8) */
#bulk textarea {
  display: block; width: 100%; max-width: 100%; min-height: 150px; resize: vertical; font: 14px/1.5 ui-monospace, Consolas, monospace;
  color: var(--text); background: var(--ground); border: 1px solid var(--line-strong); border-radius: 10px; padding: 11px 12px;
}
#bulk textarea:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
#bulk select { max-width: 22em; }
#bulk button { width: auto; }
.preview .confirm-actions { margin: 0 0 20px; }
table.import td.num { text-align: left; }
.invite input[readonly] { color: var(--muted); }

/* the platform console (/_gate/platform) */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 22px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; min-height: var(--tap); display: inline-flex; align-items: center; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--text); border-bottom-color: var(--amber); font-weight: 600; }
.tabs a:hover { color: var(--text); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin: 0 0 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.stat strong { font-size: 24px; line-height: 1.2; overflow-wrap: anywhere; }
td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.cell-actions { white-space: nowrap; }
td.cell-actions .inline { margin-left: 4px; }
.users td.cell-actions { white-space: normal; }
.users td.cell-actions .inline { margin-left: 0; }
tr.here td { background: rgba(255, 176, 32, 0.06); }
.platform .inline input { width: auto; min-width: 0; }
.platform .inline input[name="name"] { min-width: 14em; }
details.path { max-width: none; margin: 0 0 12px; padding: 16px 20px; }
details.path summary { cursor: pointer; list-style-position: outside; min-height: var(--tap); }
details.path summary strong { font-size: 16px; }
ul.tree { list-style: none; margin: 8px 0 0; padding: 0 0 0 18px; border-left: 1px solid var(--line); }
ul.tree li { margin: 6px 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row .inline { margin-left: auto; }
.row .small-btn { margin-left: 0; }

/* ---- phones ---------------------------------------------------------------- */
@media (max-width: 719px), (pointer: coarse) {
  .small-btn { min-height: var(--tap); padding: 10px 14px; }
  button.link { min-height: var(--tap); }
  p.small a, .viewing a, .stat.seats a, .acts a.small { display: inline-flex; align-items: center; min-height: var(--tap); }
  .batch button, #import button, .preview .confirm-actions button { width: 100%; }
  #bulk button, #bulk select { width: 100%; max-width: 100%; }
}
@media (max-width: 719px) {
  .shell { padding: 16px 16px 48px; }
  .masthead { margin-bottom: 24px; }
  .card { padding: 20px 16px; }
  h1 { font-size: 23px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 12px; }
  .stat strong { font-size: 20px; }
  .inline select { min-width: 0; }
  .platform .inline { flex-wrap: wrap; gap: 6px; }
  dl { grid-template-columns: 1fr; gap: 4px; }
  dd { margin-bottom: 8px; }
  /* a table.stack is a list of cards: each row a card, each cell its label
     above its value */
  .scroll:has(> table.stack) { border: 0; overflow: visible; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.stack tr { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 0 0 10px; }
  table.stack td { border: 0; padding: 6px 0; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 600; color: var(--dim); margin-bottom: 2px; }
  table.stack tr.off td { opacity: 1; }
  table.stack tr.off { opacity: 0.7; }
  .acts { flex-direction: column; align-items: stretch; }
  .acts .inline { display: flex; flex-wrap: wrap; }
  .acts .small-btn { flex: 1 1 auto; }
  .acts .move select { flex: 1 1 10em; }
}
/* a link that looks like the primary button (the billing portal: a form
   could not follow the redirect to Stripe under form-action 'self') */
a.button {
  display: flex; align-items: center; justify-content: center; margin-top: 16px; width: 100%; min-height: var(--tap);
  box-sizing: border-box; border-radius: 10px; padding: 12px 16px; background: var(--amber); color: #1A1204;
  font: 700 16px/1 inherit; text-decoration: none;
}
