/*
 * ServiceOS shared design tokens and components (P02-IDEN-002, P07-WEB-013).
 *
 * frontend-standard.md: one frontend dialect, shared tokens, `sos-` prefixed
 * component classes, no inline-style sprawl. Tenant/white-label branding
 * (P10-WLBL-*) overrides the custom properties here — never forks this file.
 *
 * Breakpoint scale is fixed platform-wide: 480 / 768 / 1024 / 1280.
 *
 * P07-WEB-013 widened the token set rather than restyling pages one by one. The
 * platform had exactly two greys, one shadow and one radius, which is why every
 * surface landed at the same visual weight — the "flat" reading. Three scales
 * fix that at the root, and every page inherits it:
 *
 *   A neutral ramp (ink 900..300), so text, secondary text, borders and
 *   dividers stop competing at one contrast level.
 *
 *   An elevation scale (0..4) built from two stacked shadows — a tight contact
 *   shadow plus a wide ambient one. One-shadow cards read as stickers; two read
 *   as material.
 *
 *   A type and space scale on a 4px rhythm, so section, card and control
 *   spacing is chosen from a set rather than per component.
 *
 * Every token name that existed before P07-WEB-013 still exists and still means
 * the same thing: admin.css, workspace.css and the widget sheets consume them.
 */

:root {
  /* ---- brand ---- */
  --sos-accent: #0f6e56;
  --sos-accent-strong: #0b5442;
  --sos-accent-soft: #d7f3ea;
  --sos-accent-tint: #eefaf6;
  --sos-accent-ink: #ffffff;

  /* ---- neutral ramp ---- */
  --sos-ink: #101d26;
  --sos-ink-800: #1f333f;
  --sos-ink-700: #33505f;
  --sos-muted: #5b6b78;
  --sos-muted-soft: #8496a1;
  --sos-line: #dde5e1;
  --sos-line-soft: #eaefec;
  --sos-surface: #f5f8f6;
  --sos-surface-sunk: #eef3f0;
  --sos-panel: #ffffff;

  /* ---- status ---- */
  --sos-danger: #a3282d;
  --sos-danger-soft: #fbe9e9;
  --sos-success: #0f6e56;
  --sos-success-soft: #d7f3ea;
  --sos-warn: #8a5a12;
  --sos-warn-soft: #fdf1dc;
  --sos-info: #1f5f8b;
  --sos-info-soft: #e2eff8;

  /* ---- type ---- */
  --sos-font: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sos-sans: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --sos-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --sos-text-xs: 0.75rem;
  --sos-text-sm: 0.85rem;
  --sos-text-base: 1rem;
  --sos-text-lg: 1.125rem;
  --sos-text-xl: 1.375rem;
  --sos-text-2xl: 1.75rem;
  --sos-text-3xl: 2.25rem;

  /* ---- space (4px rhythm) ---- */
  --sos-space-1: 0.25rem;
  --sos-space-2: 0.5rem;
  --sos-space-3: 0.75rem;
  --sos-space-4: 1rem;
  --sos-space-5: 1.5rem;
  --sos-space-6: 2rem;
  --sos-space-7: 3rem;
  --sos-space-8: 4rem;
  --sos-space: 1rem;

  /* ---- radius ---- */
  --sos-radius-sm: 8px;
  --sos-radius: 12px;
  --sos-radius-lg: 16px;
  --sos-radius-xl: 24px;
  --sos-radius-pill: 999px;

  /* ---- elevation: contact shadow + ambient shadow ---- */
  --sos-shadow-1: 0 1px 2px rgba(16, 29, 38, 0.05), 0 1px 3px rgba(16, 29, 38, 0.04);
  --sos-shadow-2: 0 1px 2px rgba(16, 29, 38, 0.05), 0 4px 12px -2px rgba(16, 29, 38, 0.07);
  --sos-shadow-3: 0 2px 4px rgba(16, 29, 38, 0.05), 0 12px 28px -8px rgba(16, 29, 38, 0.13);
  --sos-shadow-4: 0 4px 8px rgba(16, 29, 38, 0.06), 0 28px 60px -20px rgba(16, 29, 38, 0.22);

  /* ---- effects ---- */
  --sos-glow: rgba(15, 110, 86, 0.18);
  --sos-focus: 0 0 0 3px var(--sos-glow);
  --sos-ease: cubic-bezier(0.32, 0.72, 0, 1);
  --sos-fast: 140ms;
  --sos-slow: 260ms;
}

/*
 * Dark mode readiness via tokens, not per-page overrides. Desaturated tonal
 * variants rather than inverted values, and elevation switches from shadow to
 * a lighter surface — shadows do not read on a dark background.
 */
@media (prefers-color-scheme: dark) {
  :root {
    --sos-accent: #4fc3a1;
    --sos-accent-strong: #6fd4b6;
    --sos-accent-soft: #123a30;
    --sos-accent-tint: #0f2c25;
    --sos-accent-ink: #08201a;

    --sos-ink: #e8f0ec;
    --sos-ink-800: #d3e0da;
    --sos-ink-700: #b8c9c1;
    --sos-muted: #9fb2ab;
    --sos-muted-soft: #7b8f88;
    --sos-line: #294039;
    --sos-line-soft: #1e3129;
    --sos-surface: #0c1512;
    --sos-surface-sunk: #080f0d;
    --sos-panel: #14201c;

    --sos-danger: #f0868a;
    --sos-danger-soft: #38191b;
    --sos-success: #4fc3a1;
    --sos-success-soft: #123a30;
    --sos-warn: #e0b064;
    --sos-warn-soft: #33280f;
    --sos-info: #7fb6dd;
    --sos-info-soft: #14252f;

    --sos-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --sos-shadow-2: 0 2px 8px rgba(0, 0, 0, 0.45);
    --sos-shadow-3: 0 8px 24px rgba(0, 0, 0, 0.5);
    --sos-shadow-4: 0 24px 56px rgba(0, 0, 0, 0.6);
    --sos-glow: rgba(79, 195, 161, 0.26);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--sos-ink);
  font-family: var(--sos-sans);
  background: var(--sos-surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Icons ----------
 *
 * One family, one stroke width, sized from a token — never emoji. Emoji render
 * from whatever font the OS supplies, cannot be recoloured by white-label
 * tokens, and read as decoration on a page whose job is credibility.
 */

.sos-icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sos-icon--sm { width: 1em; height: 1em; }
.sos-icon--lg { width: 1.75em; height: 1.75em; }

/* ---------- Auth shell ----------
 *
 * Two panels above 1024px: the form on the right, and on the left the proof a
 * signing-in user has already bought into. A single card floating in an empty
 * viewport is the cheapest-looking screen a product can ship, and it is the
 * screen every returning customer sees most often.
 */

.sos-auth {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
  background: var(--sos-surface);
}

/* The aside is one composition, not three.
 *
 * It used to be `justify-content: space-between`, which pinned the brand to the
 * top, the line to the middle and the points to the floor of a 900px panel —
 * three clusters with no relationship, and two large voids doing nothing. A
 * reader's eye had nowhere to travel.
 *
 * Now the brand sits at the top and the argument sits as a single block on the
 * lower third, where the eye lands after the logo. The void is above the block
 * rather than distributed through it, which is what makes it read as space
 * rather than as emptiness. */
.sos-auth__aside {
  display: none;
  flex-direction: column;
  padding: var(--sos-space-7);
  color: #eef7f3;
  /* One directional gradient rather than two radials over a third layer. The
   * stacked radials banded visibly on a wide panel — the blotches were the
   * gradient, not the compression. */
  background: linear-gradient(148deg, #0d3129 0%, #0a241e 52%, #061613 100%);
}

.sos-auth__aside-body {
  /* Lower-middle, not the floor. `margin-top: auto` alone pinned the block to
     the bottom edge and left the whole upper panel empty; the bottom margin
     lifts it into the band the eye actually rests on. */
  margin-top: auto;
  margin-bottom: 12vh;
  max-width: 30ch;
}

.sos-auth__aside-brand {
  font-family: var(--sos-font);
  font-size: var(--sos-text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sos-auth__aside-quote {
  font-family: var(--sos-font);
  /* Larger than the card's own heading, deliberately. This panel is the only
   * thing on the screen that is allowed to be loud; the form should be quiet. */
  /* Capped so the line breaks into three balanced lines rather than four with
     a two-word orphan on the last. */
  font-size: clamp(1.6rem, 2.1vw, 2.05rem);
  text-wrap: balance;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.sos-auth__aside-points {
  display: grid;
  gap: var(--sos-space-3);
  margin: var(--sos-space-6) 0 0;
  padding: var(--sos-space-5) 0 0;
  /* A hairline tying the points to the line above them. Without it they float
   * as a separate list and the block stops reading as one thought. */
  border-top: 1px solid rgba(238, 247, 243, 0.16);
  list-style: none;
  font-size: var(--sos-text-sm);
  line-height: 1.45;
  color: rgba(238, 247, 243, 0.8);
}

.sos-auth__aside-points li {
  display: flex;
  gap: var(--sos-space-3);
  align-items: flex-start;
}

.sos-auth__aside-points .sos-icon {
  flex: none;
  margin-top: 0.15em;
  color: #63d1af;
}

.sos-auth__main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sos-space-6) var(--sos-space-5);
}

/* No border and no shadow above 1024px.
 *
 * The card used to be a bordered, drop-shadowed panel floating in a large flat
 * field — the "sticker on a wall" look. With an aside beside it the right-hand
 * column is already a distinct surface, so the card only needs to be the thing
 * inside it, not a second object on top of it. Below 1024px the aside is gone
 * and the card becomes the page, so it keeps its own edges there. */
.sos-auth__card {
  width: min(24rem, 100%);
  padding: var(--sos-space-6);
  background: var(--sos-panel);
  border: 1px solid var(--sos-line);
  border-radius: var(--sos-radius-lg);
  box-shadow: var(--sos-shadow-2);
}

.sos-auth__brand {
  margin-bottom: var(--sos-space-6);
}

.sos-auth__name {
  font-family: var(--sos-font);
  font-size: var(--sos-text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sos-auth__powered {
  margin-top: 0.1rem;
  color: var(--sos-muted);
  font-size: var(--sos-text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sos-auth__title {
  margin: 0 0 var(--sos-space-5);
  font-family: var(--sos-font);
  font-size: var(--sos-text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Sits directly under the title when a screen has something worth saying —
   most do not, and "Sign in to your workspace" under "Sign in" is one sentence
   pretending to be two. */
.sos-auth__lede {
  margin: -1rem 0 var(--sos-space-5);
  color: var(--sos-muted);
  font-size: var(--sos-text-sm);
  line-height: 1.5;
}

.sos-auth__footer {
  margin-top: var(--sos-space-5);
  font-size: var(--sos-text-sm);
  text-align: center;
}

/* Shown only below 1024px, where the aside is gone and this is the only trust
   cue left. Above that it repeated the aside's points word for word, three
   inches away — the same claim twice on one screen reads as padding. */
.sos-auth__trust {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sos-space-1) var(--sos-space-4);
  justify-content: center;
  margin-top: var(--sos-space-5);
  padding-top: var(--sos-space-4);
  border-top: 1px solid var(--sos-line-soft);
  color: var(--sos-muted);
  font-size: var(--sos-text-xs);
}

.sos-auth__trust span {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

@media (min-width: 1024px) {
  /* The form column is the narrower one. The aside carries the argument and
     wants the width; the form wants to be a comfortable reading measure and
     nothing more. */
  .sos-auth {
    grid-template-columns: minmax(0, 1.1fr) minmax(26rem, 0.9fr);
  }

  .sos-auth__aside {
    display: flex;
  }

  .sos-auth__card {
    border: 0;
    box-shadow: none;
    padding: 0;
    background: transparent;
  }

  .sos-auth__trust,
  .sos-auth__brand--mobile {
    display: none;
  }
}

/* ---------- Forms ---------- */

.sos-field {
  margin-bottom: var(--sos-space-4);
}

.sos-field__label {
  display: block;
  margin-bottom: var(--sos-space-1);
  font-size: var(--sos-text-sm);
  font-weight: 600;
}

.sos-field__input {
  width: 100%;
  /* 44px min touch target per frontend-standard.md. */
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  color: var(--sos-ink);
  font: inherit;
  background: var(--sos-panel);
  border: 1px solid var(--sos-line);
  border-radius: var(--sos-radius-sm);
  box-shadow: inset 0 1px 2px rgba(16, 29, 38, 0.04);
  transition: border-color var(--sos-fast) var(--sos-ease),
    box-shadow var(--sos-fast) var(--sos-ease);
}

.sos-field__input:hover {
  border-color: var(--sos-muted-soft);
}

.sos-field__input:focus-visible {
  outline: none;
  border-color: var(--sos-accent);
  box-shadow: var(--sos-focus);
}

.sos-field__input[aria-invalid="true"] {
  border-color: var(--sos-danger);
}

.sos-field__error {
  display: block;
  margin-top: var(--sos-space-1);
  color: var(--sos-danger);
  font-size: var(--sos-text-xs);
}

.sos-field--check {
  display: flex;
  gap: var(--sos-space-2);
  align-items: center;
}

.sos-field--check .sos-field__label {
  margin: 0;
  font-weight: 400;
}

/* ---------- Buttons ---------- */

.sos-btn {
  display: inline-flex;
  gap: var(--sos-space-2);
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.65rem 1.25rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--sos-radius-pill);
  cursor: pointer;
  transition: background-color var(--sos-fast) var(--sos-ease),
    border-color var(--sos-fast) var(--sos-ease),
    box-shadow var(--sos-fast) var(--sos-ease),
    transform var(--sos-fast) var(--sos-ease);
}

.sos-btn:focus-visible {
  outline: none;
  box-shadow: var(--sos-focus);
}

.sos-btn--primary {
  width: 100%;
  color: var(--sos-accent-ink);
  background: var(--sos-accent);
  box-shadow: var(--sos-shadow-2);
}

.sos-btn--primary:hover {
  background: var(--sos-accent-strong);
  box-shadow: var(--sos-shadow-3);
}

.sos-btn--primary:active {
  transform: translateY(1px);
  box-shadow: var(--sos-shadow-1);
}

.sos-link {
  color: var(--sos-accent);
}

@media (prefers-reduced-motion: reduce) {
  .sos-btn,
  .sos-field__input {
    transition: none;
  }
}

/* ---------- Alerts ---------- */

.sos-alert {
  display: flex;
  gap: var(--sos-space-2);
  margin-bottom: var(--sos-space-4);
  padding: var(--sos-space-3);
  font-size: var(--sos-text-sm);
  border: 1px solid transparent;
  border-radius: var(--sos-radius-sm);
}

.sos-alert--success {
  color: var(--sos-success);
  background: var(--sos-success-soft);
  border-color: var(--sos-success);
}

.sos-alert--error {
  color: var(--sos-danger);
  background: var(--sos-danger-soft);
  border-color: var(--sos-danger);
}

.sos-alert__list {
  margin: var(--sos-space-1) 0 0;
  padding-left: 1.1rem;
}

/* Visible only to screen readers. */
.sos-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  clip-path: inset(50%);
}
