/* Ulla UI v1.0 (brand v5), Pro register: components use the semantic tokens from tokens.css, never raw colours. */

:root { color-scheme: light; --qr-background: #FFFFFF; }
[data-theme="night"] { color-scheme: dark; }

* { box-sizing: border-box; }
::selection { background: var(--selection); }

body {
  margin: 0;
  font: 400 14px/20px var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
strong, b { font-weight: 600; }
h1, h2, h3 { font-weight: 600; }
h1 { margin: 0; font-size: 32px; line-height: 40px; letter-spacing: -0.02em; }
h2 { margin: 32px 0 12px; font-size: 20px; line-height: 28px; letter-spacing: -0.01em; }
code, .mono { font-family: var(--font-mono); font-size: 12px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--text-muted); }
.overline {
  margin: 0;
  font: 500 11px/16px var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Wordmark */

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  font: 600 20px/1 "Geist", var(--font-sans);
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--text);
}
.wordmark-link, .wordmark-link:hover { text-decoration: none; }
.wordmark.small { font-size: 16px; }
.wordmark-face { width: 0.5em; height: 1.01em; margin: 0 0.01em; overflow: visible; vertical-align: -0.27em; }
/* The eyes stay still in Ulla One: the brand's blink was a distraction on a page people work in. */
.wordmark-eye { fill: var(--accent); }
.wordmark-smile { fill: none; stroke: var(--accent); stroke-width: 8.6; stroke-linecap: round; }
.wordmark-product { font: 500 0.72em/1 var(--font-sans); color: var(--text-muted); letter-spacing: -0.01em; }


/* App frame */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding: 10px 16px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-subtle);
}
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; }
.topbar nav a {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  transition: background var(--dur-instant), color var(--dur-instant);
}
.topbar nav a:hover { background: var(--fill-hover); color: var(--text); text-decoration: none; }
.topbar nav a.active { background: var(--fill-active); color: var(--text); font-weight: 500; }
.who { margin-left: auto; color: var(--text-muted); display: flex; gap: 8px; align-items: center; }

main { max-width: 1180px; margin: 0 auto; padding: 32px 16px 64px; }

.heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.heading-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 24px;
}
.card + .card { margin-top: 16px; }

/* The frame: a 5px accent border around the one thing that matters in a view. Once per view, never on a modal. */
.frame { border: var(--frame-width) solid var(--frame); border-radius: var(--radius-xl); }
.card h2:first-child { margin-top: 0; }

.flash { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius-md); border: 1px solid; }
.flash.notice { background: var(--success-subtle); border-color: var(--success-border); color: var(--success-text); }
.flash.alert { background: var(--danger-subtle); border-color: var(--danger-border); color: var(--danger-text); }

/* A secret shown once. */
.secret { display: grid; gap: 8px; padding: 16px; border-radius: var(--radius-md); background: var(--warning-subtle); border: 1px solid var(--warning-border); }
.secret code { font-size: 14px; word-break: break-all; color: var(--text); }

/* Tables */

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  font-variant-numeric: tabular-nums;
}
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { background: var(--bg-subtle); font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
td.nowrap { white-space: nowrap; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dt { color: var(--text-muted); }
dd { margin: 0; word-break: break-word; }

/* Badges: state is a dot and a word, never colour alone. */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--fill);
  color: var(--text);
  font-size: 12px;
  line-height: 18px;
  font-weight: 500;
  white-space: nowrap;
}
.badge.code { border-radius: var(--radius-xs); border-color: var(--border-subtle); font: 400 12px/18px var(--font-mono); }
.badge.success, .badge.warning, .badge.danger {
  background: var(--tone-subtle);
  border-color: var(--tone-border);
  color: var(--tone-text);
}
.badge.success::before, .badge.warning::before, .badge.danger::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tone-solid);
}
.badge.success { --tone-subtle: var(--success-subtle); --tone-border: var(--success-border); --tone-text: var(--success-text); --tone-solid: var(--success); }
.badge.warning { --tone-subtle: var(--warning-subtle); --tone-border: var(--warning-border); --tone-text: var(--warning-text); --tone-solid: var(--warning); }
.badge.danger { --tone-subtle: var(--danger-subtle); --tone-border: var(--danger-border); --tone-text: var(--danger-text); --tone-solid: var(--danger); }
.pills { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* Controls */

select, input, button, textarea { font: inherit; }
select, input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], input:not([type]), textarea {
  height: var(--control-md);
  padding: 0 10px;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
input::placeholder { color: var(--text-subtle); }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-md);
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-instant), color var(--dur-instant);
}
button:hover, .button:hover { background: var(--accent-hover); text-decoration: none; }
button.secondary, .button.secondary { background: var(--fill); color: var(--text); }
button.secondary:hover, .button.secondary:hover { background: var(--fill-hover); }
button.danger { background: var(--danger-subtle); color: var(--danger-text); }
button.danger:hover { background: var(--danger-border); }
button.link { height: auto; padding: 0; background: none; color: var(--accent-text); font-weight: 400; }
button.link:hover { background: none; text-decoration: underline; }
form.inline { display: inline; }

.form { display: grid; gap: 16px; max-width: 560px; }
.form.wide { max-width: none; }
.field { display: grid; gap: 4px; color: var(--text-muted); font-size: 12px; font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; font-size: 14px; font-weight: 400; }
.field .hint { font-weight: 400; color: var(--text-subtle); }
.check { display: flex; align-items: center; gap: 8px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.form-actions .errors { margin-right: auto; }
.errors { color: var(--danger-text); }
.errors ul { margin: 0; padding-left: 18px; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

/* Sign-in pages */

/* The sign-in card is the one thing on its page, so it wears the frame: 5px of accent, radius 18. */
.auth {
  display: grid;
  gap: 16px;
  width: min(400px, calc(100% - 32px));
  margin: 12vh auto 48px;
  padding: 32px;
  background: var(--surface);
  border: var(--frame-width) solid var(--frame);
  border-radius: var(--radius-xl);
}
.auth > .wordmark-link .wordmark { font-size: 36px; }
.auth h1 { font-size: 24px; line-height: 32px; }
.auth p { margin: 0; }
.auth input, .auth button { height: var(--control-lg); }
.auth .qr { justify-self: center; padding: 12px; background: var(--qr-background); border-radius: var(--radius-md); }
.auth .qr svg { display: block; width: 180px; height: 180px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin: 0; padding: 16px; list-style: none; border-radius: var(--radius-md); background: var(--surface-sunken); font: 400 14px/22px var(--font-mono); }

/* Dashboard: every section is a header row and one strip of figures, 32px apart. */

.dashboard-section { display: grid; gap: 12px; margin-bottom: 32px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: var(--control-md); }
.section-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-title h2 { margin: 0; font-size: 16px; line-height: 24px; }

/* Figures as the product framework draws them: equal cells, hairline dividers that hold when they wrap. */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  margin: 0;
  overflow: hidden;
  background: var(--border-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1), var(--highlight);
}
.kpi {
  display: grid;
  gap: 4px;
  align-content: start;
  padding: 20px;
  background: var(--surface);
  color: var(--text);
  transition: background var(--dur-instant);
}
.kpi:hover { background: var(--fill-hover); text-decoration: none; }
.kpi.frame { padding: 16px; border-radius: var(--radius-lg); }
.kpi-label { color: var(--text-muted); font-size: 12px; line-height: 16px; font-weight: 500; }
.kpi-value { font-size: 32px; line-height: 40px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-note { display: block; margin: 0; padding: 20px; background: var(--surface); }
.figure-unit { margin-left: 2px; font-size: 0.55em; font-weight: 500; color: var(--text-muted); }
.tone-success { color: var(--success-text); }
.tone-warning { color: var(--warning-text); }
.tone-danger { color: var(--danger-text); }

/* Header menus: the product switcher and the profile, each a <details> that drops a panel. */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.icon-button {
  display: grid;
  place-items: center;
  width: var(--control-md);
  height: var(--control-md);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}
.icon-button:hover, .menu[open] > .icon-button { background: var(--fill-hover); color: var(--text); }
.icon-button svg { fill: currentColor; }
.avatar {
  display: grid;
  place-items: center;
  width: var(--control-md);
  height: var(--control-md);
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
}
.menu[open] > .avatar, .avatar:hover { box-shadow: 0 0 0 2px var(--accent-border); }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: var(--z-dropdown);
  display: grid;
  gap: 2px;
  min-width: 260px;
  padding: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2), var(--highlight);
  color: var(--text);
}
.menu-panel hr { width: 100%; margin: 6px 0; border: 0; border-top: 1px solid var(--border-subtle); }
.menu-link, .menu-form button.menu-link {
  display: flex;
  align-items: center;
  width: 100%;
  height: var(--control-md);
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font-weight: 400;
  justify-content: flex-start;
}
.menu-link:hover, .menu-form button.menu-link:hover { background: var(--fill-hover); text-decoration: none; }
.menu-form { display: block; }
.menu-label { padding: 4px 10px 6px; }
.profile-head { display: grid; gap: 2px; padding: 6px 10px; }
.profile-panel .theme-switch { margin: 0 10px 4px; justify-self: start; }
.app-panel { width: 320px; }
.app-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.app-tile {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 16px 8px;
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 12px;
  line-height: 16px;
}
.app-tile:hover { background: var(--fill-hover); text-decoration: none; }
.available-list { display: grid; gap: 4px; margin: 0; padding: 0 10px 4px; list-style: none; color: var(--text-muted); }
.available-list li { display: flex; align-items: center; justify-content: space-between; height: 28px; }

/* The client's logo beside Ulla's; the Night version, when there is one, swaps in on Night. */
.client-logo { display: flex; align-items: center; height: var(--control-md); padding-right: 12px; margin-right: 4px; border-right: 1px solid var(--border-subtle); }
.client-logo img { height: 24px; width: auto; max-width: 140px; object-fit: contain; }
[data-theme="night"] .client-logo .paper-only, [data-theme="paper"] .client-logo .night-only { display: none; }

.empty-state { display: grid; justify-items: center; gap: 12px; padding: 40px 24px; text-align: center; }

/* A user's access to one product, on their admin page. */
.access-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .who { margin-left: 0; }
  dl { grid-template-columns: 1fr; gap: 2px; }
  dd { margin-bottom: 8px; }
}
.spaced { margin-top: 16px; }
.continuing-to { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }

/* Theme: follows the device unless someone picks Paper or Night. */
.theme-switch { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--radius-md); background: var(--fill); }
.theme-switch button { height: 24px; padding: 0 8px; border-radius: var(--radius-sm); background: none; color: var(--text-muted); font-size: 12px; font-weight: 500; }
.theme-switch button:hover { background: none; color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-1); }

/* Client logos: previews on each theme's own ground, so a dark logo is seen on Night before it ships. */
.logo-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.logo-field { display: grid; gap: 8px; align-content: start; }
.logo-preview { display: grid; place-items: center; min-height: 72px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg); }
.logo-preview img { height: 40px; width: auto; max-width: 100%; object-fit: contain; }
