/* ============================================================
   app.css — base layer for the Crenley Admin Console.
   Reads only from tokens.css. Screen-specific CSS layers on top.
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- type roles ---------------------------------------------------- */

.t-display {
  font-size: var(--t-display);
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.12;
}
.t-h1 {
  font-size: var(--t-h1);
  font-weight: 700;
  letter-spacing: -0.6px;
  line-height: 1.2;
}
.t-h2 {
  font-size: var(--t-h2);
  font-weight: 600;
  letter-spacing: -0.4px;
  line-height: 1.25;
}
.t-h3 {
  font-size: var(--t-h3);
  font-weight: 600;
  letter-spacing: -0.2px;
  line-height: 1.35;
}
.t-body-sm {
  font-size: var(--t-body-sm);
}
.t-caption {
  font-size: var(--t-caption);
  color: var(--ink-3);
  line-height: 1.45;
}
.t-overline {
  font-size: var(--t-overline);
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

/* Muted companion text next to a primary value. Tables give it its own
   block-level variant; everywhere else it sits inline. */
.secondary {
  font-size: var(--t-caption);
  color: var(--ink-3);
}

/* Everything people compare — times, counts, codes, IDs. */
.data,
.data-lg,
.data-sm,
code,
kbd {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}
.data-lg {
  font-size: var(--t-data-lg);
  font-weight: 700;
  letter-spacing: -0.6px;
}
.data {
  font-size: var(--t-data);
  font-weight: 500;
  letter-spacing: -0.3px;
}
.data-sm {
  font-size: var(--t-data-sm);
  font-weight: 500;
  letter-spacing: -0.2px;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

a {
  color: var(--link);
  text-decoration: none;
  border-radius: var(--sp-4);
}
a:hover {
  text-decoration: underline;
}

/* ---- focus: always visible, never removed -------------------------- */

:focus {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--sp-16);
  top: -100px;
  z-index: 100;
  padding: var(--sp-8) var(--sp-16);
  border-radius: var(--r-xs);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  font-size: var(--t-body-sm);
  font-weight: 600;
  transition: top 120ms ease;
}
.skip-link:focus-visible {
  top: var(--sp-16);
}

/* ---- fields -------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.field > label,
.label {
  font-size: var(--t-body-sm);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.1px;
}

.input {
  height: var(--control);
  width: 100%;
  padding: 0 var(--sp-16);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: var(--t-body);
  line-height: normal;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}
.input::placeholder {
  color: var(--ink-3);
}
.input:hover:not(:disabled) {
  border-color: var(--ink-3);
}
.input:focus-visible {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--link) 22%, transparent);
}
.input:disabled {
  background: var(--surface-sunken);
  color: var(--ink-3);
  cursor: not-allowed;
}
.input[aria-invalid="true"] {
  border-color: var(--stop);
}
.input[aria-invalid="true"]:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--stop) 22%, transparent);
}
.input--sm {
  height: var(--control-sm);
  font-size: var(--t-body-sm);
}
.input--mono {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-6);
  font-size: var(--t-body-sm);
  color: var(--stop);
}
.field-error:empty {
  display: none;
}
.field-hint {
  font-size: var(--t-caption);
  color: var(--ink-3);
}

/* A label row with something aligned opposite it — a hint, a link, a count. */
.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-12);
}
.field-head a {
  font-size: var(--t-body-sm);
  font-weight: 500;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-8);
  height: var(--control);
  padding: 0 var(--sp-20);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: var(--t-body);
  font-weight: 600;
  letter-spacing: -0.1px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn--primary {
  background: var(--brand-fill);
  color: var(--on-brand);
}
.btn--primary:hover:not(:disabled) {
  background: var(--brand-fill-hover);
}

.btn--secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--surface-sunken);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--surface-sunken);
  color: var(--ink);
}

.btn--sm {
  height: var(--control-sm);
  padding: 0 var(--sp-12);
  font-size: var(--t-body-sm);
}
.btn--block {
  width: 100%;
}

/* ---- checkbox ------------------------------------------------------ */

.check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-8);
  font-size: var(--t-body-sm);
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.check input {
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  flex: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--sp-6);
  background: var(--surface);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.check input:checked {
  background: var(--brand-fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E")
    center / 12px no-repeat;
  border-color: var(--brand-fill);
}
.check input:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* A duty type is never colour alone — the dot always sits next to its label. */
.duty-dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: var(--r-pill);
}

/* ---- status: chip + icon + label, never colour alone ---------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-6);
  padding: var(--sp-4) var(--sp-8);
  border-radius: var(--r-pill);
  font-size: var(--t-overline);
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.chip--ok {
  background: var(--ok-tint);
  color: var(--ok);
}
.chip--warn {
  background: var(--warn-tint);
  color: var(--warn);
}
.chip--stop {
  background: var(--stop-tint);
  color: var(--stop);
}
.chip--info {
  background: var(--info-tint);
  color: var(--info);
}
.chip--muted {
  background: var(--surface-sunken);
  color: var(--ink-2);
}

/* ---- alert --------------------------------------------------------- */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-12);
  padding: var(--sp-12) var(--pad-card);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: var(--t-body-sm);
  line-height: 1.5;
}
.alert svg {
  flex: none;
  margin-top: 1px;
}
.alert strong {
  display: block;
  font-weight: 600;
  margin-bottom: var(--sp-2);
}
.alert--stop {
  background: var(--stop-tint);
  border-color: color-mix(in srgb, var(--stop) 28%, transparent);
  color: var(--stop);
}
.alert--warn {
  background: var(--warn-tint);
  border-color: color-mix(in srgb, var(--warn) 28%, transparent);
  color: var(--warn);
}
.alert--info {
  background: var(--info-tint);
  border-color: color-mix(in srgb, var(--info) 28%, transparent);
  color: var(--info);
}
.alert--ok {
  background: var(--ok-tint);
  border-color: color-mix(in srgb, var(--ok) 28%, transparent);
  color: var(--ok);
}

/* ---- confirmation dialog: centred and modal, wherever it is used ---- */


dialog.confirm {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
dialog.confirm::backdrop {
  background: rgba(7, 12, 26, 0.55);
}
dialog.confirm .dlg-body {
  padding: var(--pad-card-lg);
}
dialog.confirm h2 {
  font-size: var(--t-h3);
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: var(--sp-8);
}
dialog.confirm p {
  font-size: var(--t-body-sm);
  color: var(--ink-2);
  margin-bottom: var(--sp-12);
}
dialog.confirm ul {
  margin: 0 0 var(--sp-8);
  padding-left: 18px;
  font-size: var(--t-body-sm);
  color: var(--ink-2);
}
dialog.confirm li {
  margin-bottom: var(--sp-6);
}
dialog.confirm .dlg-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-8);
  padding: var(--sp-12) var(--pad-card-lg);
  border-top: 1px solid var(--divider);
  background: var(--surface-sunken);
}

/* ---- theme switch (3-state: light / system / dark) ----------------- */

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
}
.theme-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}
.theme-switch button:hover {
  color: var(--ink);
  background: var(--surface-sunken);
}
.theme-switch button[aria-pressed="true"] {
  background: var(--surface-sunken);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.theme-switch button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

#duty-panel .section-head, .panel .section-head{
  padding: 1rem 1rem 0 1rem;
}