/* ==========================================================================
   Ek Sutra design system — Material 3 Expressive
   Palette 04 "Fresh & Pastel": teal #3E8E9E · peach #F2B59E ·
   white #FFFFFF · charcoal #33373D · butter #F5DF99
   60% white surfaces · 30% charcoal/teal · 10% peach + butter accents
   To re-skin: change the brand keys and colour roles below (and the dark block).
   ========================================================================== */

:root {
  /* Brand keys (exact palette values — used for shapes, fills and charts) */
  --brand-primary: #3E8E9E;    /* teal */
  --brand-secondary: #F2B59E;  /* peach */
  --brand-accent: #F5DF99;     /* butter */
  --brand-ink: #33373D;        /* charcoal — dark blocks, text on peach/butter */
  --brand-paper: #FFFFFF;      /* text on charcoal */
  /* On charcoal blocks (hero, CTA, featured plan): quiet shapes, secondary text, buttons */
  --brand-ink-raised: #40454C;
  --brand-ink-muted: #C4CAD1;
  --brand-ink-primary: #8FD0DE; --brand-ink-on-primary: #06323B;

  /* Colour roles — light. Text-bearing roles are tone-shifted from the keys to hold WCAG AA.
     primary = actions, selected and positive states · secondary = decorative warm accent · tertiary = highlight / caution */
  --primary: #2D7888;              --on-primary: #FFFFFF;
  --primary-container: #DDEEF2;    --on-primary-container: #0F3D47;
  --secondary: #A2553B;            --on-secondary: #FFFFFF;
  --secondary-container: #FCE9E1;  --on-secondary-container: #4E2212;
  --tertiary: #75601A;             --on-tertiary: #FFFFFF;
  --tertiary-container: #FBF2D0;   --on-tertiary-container: #3B2F00;
  --error: #B3261E;                --on-error: #FFFFFF;
  --error-container: #F9DEDC;      --on-error-container: #5F1410;

  --surface: #FCFDFD;
  --surface-container-lowest: #FFFFFF;
  --surface-container-low: #F4F6F8;
  --surface-container: #EEF1F4;
  --surface-container-high: #E7EBEF;
  --surface-container-highest: #DEE3E8;
  --on-surface: #33373D;
  --on-surface-variant: #5B626B;
  --outline: #858D96;
  --outline-variant: #E1E5EA;
  --inverse-surface: #33373D;
  --inverse-on-surface: #FFFFFF;
  --scrim: rgba(24, 27, 31, .46);

  --shadow-1: 0 1px 2px rgba(51, 55, 61, .05), 0 1px 3px rgba(51, 55, 61, .04);
  --shadow-2: 0 2px 6px rgba(51, 55, 61, .08), 0 6px 16px rgba(51, 55, 61, .08);
  --shadow-3: 0 6px 14px rgba(51, 55, 61, .10), 0 18px 40px rgba(51, 55, 61, .14);

  /* Chart series */
  --chart-1: #3E8E9E; --chart-2: #33373D; --chart-3: #F2B59E; --chart-4: #F5DF99; --chart-5: #A9D3DB; --chart-6: #C9CFD6; --chart-7: #F9DCCF;

  /* Shape — expressive scale */
  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px; --r-2xl: 36px; --r-3xl: 48px; --r-full: 999px;

  /* Type */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-ui: "Roboto Flex", "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Motion — M3 easing plus spring approximations (overridden below where linear() is supported) */
  --ease: cubic-bezier(.2, 0, 0, 1);
  --ease-out: cubic-bezier(.05, .7, .1, 1);
  --ease-in: cubic-bezier(.3, 0, .8, .15);
  --spring: cubic-bezier(.34, 1.46, .5, 1);
  --spring-soft: cubic-bezier(.3, 1.2, .4, 1);
  --t-fast: .18s; --t-med: .35s; --t-slow: .6s;
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    /* Expressive spatial spring (visible overshoot) and a calmer default spring */
    --spring: linear(0, .009, .035 2.1%, .141 4.4%, .723 12.9%, .938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, .991, .977 51%, .974 53.8%, .975 57.1%, .997 69.8%, 1.003 76.9%, 1.004 83.8%, 1);
    --spring-soft: linear(0, .012 1.2%, .05 2.6%, .19 5.6%, .62 13.4%, .82 17.6%, .95 22%, 1.02 26.4%, 1.05 30.6%, 1.056 34.6%, 1.045 40.6%, 1.012 52.4%, 1.002 60.6%, .997 71%, 1);
    --t-med: .55s; --t-slow: .8s;
  }
}

[data-theme="dark"] {
  --primary: #8FD0DE;              --on-primary: #06323B;
  --primary-container: #1F5562;    --on-primary-container: #C9EEF6;
  --secondary: #F6BFAA;            --on-secondary: #4E2212;
  --secondary-container: #6A3625;  --on-secondary-container: #FFDBCE;
  --tertiary: #EFD98F;             --on-tertiary: #3A2F00;
  --tertiary-container: #544500;   --on-tertiary-container: #FBEDB5;
  --error: #F2B8B5;                --on-error: #601410;
  --error-container: #8C1D18;      --on-error-container: #F9DEDC;
  --surface: #17191C;
  --surface-container-lowest: #111315;
  --surface-container-low: #1E2125;
  --surface-container: #23262B;
  --surface-container-high: #2D3136;
  --surface-container-highest: #383C42;
  --on-surface: #E7EAEE;
  --on-surface-variant: #C2C8D0;
  --outline: #8B929B;
  --outline-variant: #42474E;
  --inverse-surface: #E7EAEE;
  --inverse-on-surface: #33373D;
  --scrim: rgba(0, 0, 0, .6);
  --chart-2: #9AA2AC;
  --shadow-1: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-2: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-3: 0 12px 36px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--surface); color: var(--on-surface);
  font: 400 15px/1.5 var(--font-ui); font-variation-settings: "wdth" 100;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--brand-accent); color: var(--brand-ink); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: var(--r-xs); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Type roles ---------- */
.display { font: 600 clamp(44px, 7.2vw, 96px)/.98 var(--font-display); letter-spacing: -.035em; font-variation-settings: "SOFT" 60, "opsz" 144; }
.headline { font: 600 clamp(30px, 4vw, 52px)/1.05 var(--font-display); letter-spacing: -.025em; font-variation-settings: "SOFT" 50, "opsz" 96; }
.title-lg { font: 600 26px/1.2 var(--font-display); letter-spacing: -.015em; font-variation-settings: "SOFT" 50, "opsz" 48; }
.title { font: 650 18px/1.3 var(--font-ui); letter-spacing: -.005em; }
.body-lg { font-size: 17px; line-height: 1.6; }
.label { font: 600 12px/1.2 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--on-surface-variant); }
.muted { color: var(--on-surface-variant); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- Icons (Material Symbols Rounded, variable) ---------- */
.icon {
  font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 24px; line-height: 1;
  display: inline-block; width: 1em; height: 1em; flex: none; overflow: hidden; white-space: nowrap; direction: ltr;
  letter-spacing: normal; text-transform: none; word-wrap: normal; -webkit-font-feature-settings: "liga"; font-feature-settings: "liga";
  font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24;
  transition: font-variation-settings var(--t-fast) var(--ease); user-select: none;
}
.icon--fill { font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24; }
.icon--sm { font-size: 20px; } .icon--lg { font-size: 32px; } .icon--xl { font-size: 44px; }

/* ---------- Ripple + state layer ---------- */
.ripple-host { position: relative; overflow: hidden; isolation: isolate; }
.ripple {
  position: absolute; border-radius: 50%; background: currentColor; opacity: .16; pointer-events: none;
  transform: scale(0); animation: ripple .6s var(--ease-out) forwards; z-index: 0;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* ---------- Buttons — pill at rest, squarer when pressed (shape morph) ---------- */
.btn {
  --bg: var(--primary); --fg: var(--on-primary);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 24px; border: 0; border-radius: var(--r-full);
  background: var(--bg); color: var(--fg); font: 600 15px/1 var(--font-ui); letter-spacing: .01em;
  text-decoration: none; white-space: nowrap; cursor: pointer; overflow: hidden; isolation: isolate; user-select: none;
  transition: border-radius var(--t-med) var(--spring-soft), transform var(--t-med) var(--spring), box-shadow var(--t-fast) var(--ease), background-color var(--t-fast);
}
.btn::before { content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity var(--t-fast); z-index: -1; }
.btn:hover::before { opacity: .09; }
.btn:focus-visible::before { opacity: .12; }
.btn:hover { box-shadow: var(--shadow-1); }
.btn:active { border-radius: var(--r-md); transform: scale(.97); }
.btn .icon { font-size: 20px; margin-left: -4px; }
.btn--tonal { --bg: var(--primary-container); --fg: var(--on-primary-container); }
.btn--accent { --bg: var(--brand-accent); --fg: var(--brand-ink); }
.btn--outlined { --bg: transparent; --fg: var(--primary); box-shadow: inset 0 0 0 1.5px var(--outline); }
.btn--outlined:hover { box-shadow: inset 0 0 0 1.5px var(--primary); }
.btn--text { --bg: transparent; --fg: var(--primary); padding: 0 14px; }
.btn--text:hover { box-shadow: none; }
.btn--danger { --bg: var(--error); --fg: var(--on-error); }
.btn--inverse { --bg: var(--brand-paper); --fg: var(--brand-ink); }
.btn--sm { height: 40px; padding: 0 18px; font-size: 14px; }
.btn--lg { height: 60px; padding: 0 32px; font-size: 17px; }
.btn--xl { height: 76px; padding: 0 44px; font-size: 20px; font-weight: 650; }
.btn--xl .icon, .btn--lg .icon { font-size: 24px; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: var(--r-full); background: transparent; color: var(--on-surface-variant);
  cursor: pointer; overflow: hidden; isolation: isolate; text-decoration: none;
  transition: border-radius var(--t-med) var(--spring-soft), background-color var(--t-fast), transform var(--t-med) var(--spring);
}
.icon-btn::before { content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity var(--t-fast); z-index: -1; }
.icon-btn:hover::before { opacity: .09; }
.icon-btn:active { border-radius: var(--r-sm); transform: scale(.94); }
.icon-btn--tonal { background: var(--primary-container); color: var(--on-primary-container); }
.icon-btn--filled { background: var(--primary); color: var(--on-primary); }
.icon-btn--surface { background: var(--surface-container-high); color: var(--on-surface); }
.icon-btn--sm { width: 36px; height: 36px; } .icon-btn--sm .icon { font-size: 20px; }

/* Connected button group — the selected segment relaxes into a full pill */
.btn-group { display: inline-flex; gap: 3px; }
.btn-group__item {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px;
  border: 0; background: var(--surface-container-high); color: var(--on-surface-variant); font: 600 13px/1 var(--font-ui);
  border-radius: var(--r-xs); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: border-radius var(--t-med) var(--spring-soft), background-color var(--t-fast), color var(--t-fast), padding var(--t-med) var(--spring-soft);
}
.btn-group__item:first-child { border-radius: var(--r-full) var(--r-xs) var(--r-xs) var(--r-full); }
.btn-group__item:last-child { border-radius: var(--r-xs) var(--r-full) var(--r-full) var(--r-xs); }
.btn-group__item:hover { background: var(--surface-container-highest); }
.btn-group__item:active { border-radius: var(--r-sm); }
.btn-group__item.is-selected, .btn-group__item[aria-pressed="true"] { border-radius: var(--r-full); background: var(--primary); color: var(--on-primary); padding: 0 20px; }
.btn-group__item[data-tone="ok"].is-selected { background: var(--primary); color: var(--on-primary); }
.btn-group__item[data-tone="warn"].is-selected { background: var(--brand-accent); color: var(--brand-ink); }
.btn-group__item[data-tone="bad"].is-selected { background: var(--error); color: var(--on-error); }
.btn-group__item[data-tone="info"].is-selected { background: var(--inverse-surface); color: var(--inverse-on-surface); }
.btn-group__item .icon { font-size: 18px; }

/* FAB */
.fab {
  position: relative; display: inline-flex; align-items: center; gap: 12px; height: 56px; padding: 0 22px 0 18px; border: 0;
  border-radius: var(--r-lg); background: var(--primary-container); color: var(--on-primary-container);
  font: 650 15px/1 var(--font-ui); cursor: pointer; overflow: hidden; isolation: isolate; text-decoration: none; box-shadow: var(--shadow-1);
  transition: border-radius var(--t-med) var(--spring-soft), box-shadow var(--t-fast), transform var(--t-med) var(--spring);
}
.fab:hover { box-shadow: var(--shadow-2); border-radius: var(--r-xl); }
.fab:active { transform: scale(.96); border-radius: var(--r-md); }
.fab--primary { background: var(--primary); color: var(--on-primary); }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; overflow: hidden;
  border: 1px solid var(--outline-variant); border-radius: var(--r-sm); background: transparent; color: var(--on-surface-variant);
  font: 600 13px/1 var(--font-ui); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: border-radius var(--t-med) var(--spring-soft), background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.chip:hover { background: var(--surface-container-high); }
.chip.is-selected { background: var(--primary-container); color: var(--on-primary-container); border-color: transparent; border-radius: var(--r-full); }
.chip .icon { font-size: 18px; }
.chip__count { opacity: .7; font-weight: 500; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 8px; border-radius: var(--r-full);
  font: 650 12px/1 var(--font-ui); white-space: nowrap; background: var(--surface-container-high); color: var(--on-surface);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge--ok { background: var(--primary-container); color: var(--on-primary-container); }
.badge--warn { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.badge--bad { background: var(--error-container); color: var(--on-error-container); }
.badge--info { background: var(--surface-container-high); color: var(--on-surface-variant); }
.badge--plain::before { display: none; } .badge--plain { padding: 0 10px; }

/* ---------- Cards ---------- */
.card { background: var(--surface-container-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-xl); padding: 24px; --field-bg: var(--surface-container-lowest); }
.card--low { background: var(--surface-container-low); --field-bg: var(--surface-container-low); }
.card--outlined { background: transparent; }
.card--primary { background: var(--primary-container); color: var(--on-primary-container); border-color: transparent; }
.card--secondary { background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent; }
.card--tertiary { background: var(--tertiary-container); color: var(--on-tertiary-container); border-color: transparent; }
.card--inverse { background: var(--brand-ink); color: var(--brand-paper); border-color: transparent; }
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card__head .title { display: flex; align-items: center; gap: 10px; }
.card--flush .card__head { padding: 20px 24px 0; }
.card.is-interactive { transition: transform var(--t-med) var(--spring), border-radius var(--t-med) var(--spring-soft), box-shadow var(--t-fast); }
.card.is-interactive:hover { transform: translateY(-4px); border-radius: var(--r-2xl); box-shadow: var(--shadow-2); }

/* ---------- Text fields (outlined, floating label) ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; }
.form-grid .field--full { grid-column: 1 / -1; }
.field { position: relative; display: block; min-width: 0; }
.field__input {
  display: block; width: 100%; height: 56px; padding: 0 16px; border: 0; border-radius: var(--r-md); outline: 0; background: transparent;
  box-shadow: inset 0 0 0 1px var(--outline); color: var(--on-surface); font: 400 16px/1.4 var(--font-ui);
  transition: box-shadow var(--t-fast) var(--ease), border-radius var(--t-med) var(--spring-soft);
}
textarea.field__input { height: auto; min-height: 104px; padding: 16px; resize: vertical; }
select.field__input { appearance: none; -webkit-appearance: none; padding-right: 44px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%238C8279'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
select.field__input option { background: var(--surface-container-lowest); color: var(--on-surface); }
.field__input:hover { box-shadow: inset 0 0 0 1px var(--on-surface); }
.field__input:focus { box-shadow: inset 0 0 0 2.5px var(--primary); border-radius: var(--r-lg); }
.field__label {
  position: absolute; left: 12px; top: 18px; max-width: calc(100% - 24px); padding: 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--field-bg, var(--surface-container-lowest)); color: var(--on-surface-variant); font-size: 16px; line-height: 20px; pointer-events: none;
  transform-origin: left top; transition: transform var(--t-fast) var(--ease), color var(--t-fast);
}
.field__input:focus ~ .field__label,
.field__input:not(:placeholder-shown) ~ .field__label,
.field--static .field__label { transform: translateY(-28px) scale(.78); max-width: 120%; }
.field__input:focus ~ .field__label { color: var(--primary); font-weight: 600; }
.field__help { display: block; margin: 5px 16px 0; font-size: 12.5px; color: var(--on-surface-variant); }
.field.is-error .field__input { box-shadow: inset 0 0 0 2px var(--error); }
.field.is-error .field__label, .field.is-error .field__help { color: var(--error); }
.field__lead { position: absolute; left: 14px; top: 16px; color: var(--on-surface-variant); pointer-events: none; }
.field--lead .field__input { padding-left: 48px; }
.field--lead .field__label { left: 44px; }
.field--lead .field__input:focus ~ .field__label, .field--lead .field__input:not(:placeholder-shown) ~ .field__label { transform: translate(-32px, -28px) scale(.78); }

/* Search pill */
.search { position: relative; display: flex; align-items: center; height: 48px; min-width: 0; border-radius: var(--r-full); background: var(--surface-container-high); color: var(--on-surface-variant); transition: background-color var(--t-fast), box-shadow var(--t-fast), border-radius var(--t-med) var(--spring-soft); }
.search:focus-within { background: var(--surface-container-lowest); box-shadow: inset 0 0 0 2px var(--primary); border-radius: var(--r-lg); }
.search .icon { margin-left: 16px; font-size: 22px; }
.search input { flex: 1; min-width: 0; height: 100%; padding: 0 16px 0 10px; border: 0; outline: 0; background: transparent; color: var(--on-surface); font-size: 15px; }
.search input::placeholder { color: var(--on-surface-variant); }
.search kbd { margin-right: 14px; padding: 3px 7px; border-radius: 6px; background: var(--surface-container-highest); font: 600 11px var(--font-ui); color: var(--on-surface-variant); }

/* Checkbox / switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track { width: 52px; height: 32px; border-radius: var(--r-full); background: var(--surface-container-highest); box-shadow: inset 0 0 0 2px var(--outline); position: relative; transition: background-color var(--t-fast), box-shadow var(--t-fast); }
.switch__track::after { content: ""; position: absolute; top: 8px; left: 8px; width: 16px; height: 16px; border-radius: 50%; background: var(--outline); transition: transform var(--t-med) var(--spring), width var(--t-med) var(--spring), height var(--t-med) var(--spring), top var(--t-med) var(--spring), left var(--t-med) var(--spring), background-color var(--t-fast); }
.switch input:checked + .switch__track { background: var(--primary); box-shadow: none; }
.switch input:checked + .switch__track::after { transform: translateX(20px); width: 24px; height: 24px; top: 4px; left: 4px; background: var(--on-primary); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14.5px; }
.table th { position: sticky; top: 0; padding: 12px 16px; text-align: left; font: 650 12px/1.2 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--on-surface-variant); background: var(--surface-container-low); white-space: nowrap; }
.table th:first-child { border-radius: var(--r-md) 0 0 var(--r-md); padding-left: 20px; }
.table th:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; padding-right: 20px; }
.table th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.table th a:hover { color: var(--on-surface); }
.table th .icon { font-size: 16px; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--outline-variant); vertical-align: middle; }
.table td:first-child { padding-left: 20px; } .table td:last-child { padding-right: 20px; }
.table tbody tr { transition: background-color var(--t-fast); }
.table tbody tr:hover { background: color-mix(in srgb, var(--on-surface) 4%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .t-right, .table th.t-right { text-align: right; }
.table .t-strong { font-weight: 650; color: var(--on-surface); }
.table .t-link { color: var(--on-surface); font-weight: 650; text-decoration: none; }
.table .t-link:hover { color: var(--primary); text-decoration: underline; }
.table .t-actions { white-space: nowrap; text-align: right; width: 1%; }
.table .t-actions form { display: inline; }
.table--compact td { padding: 10px 16px; }

/* ---------- Avatars ---------- */
.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: var(--r-full); background: var(--brand-secondary); color: var(--brand-ink); font: 700 14px/1 var(--font-ui); letter-spacing: .02em; }
.avatar--sq { border-radius: var(--r-md); }
.avatar--primary { background: var(--primary); color: var(--on-primary); }
.avatar--accent { background: var(--brand-accent); color: var(--brand-ink); }
.avatar--lg { width: 56px; height: 56px; font-size: 18px; }

/* ---------- Menus ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; z-index: 60; top: calc(100% + 8px); right: 0; min-width: 220px; padding: 8px; border-radius: var(--r-lg);
  background: var(--surface-container-lowest); box-shadow: var(--shadow-3); opacity: 0; visibility: hidden; transform: scale(.9) translateY(-8px); transform-origin: top right;
  transition: opacity var(--t-fast), transform var(--t-med) var(--spring-soft), visibility 0s linear var(--t-fast);
}
.menu--left { right: auto; left: 0; transform-origin: top left; }
.menu--up { top: auto; bottom: calc(100% + 8px); transform-origin: bottom left; }
.menu.is-open { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.menu__item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 14px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--on-surface); font: 500 14.5px var(--font-ui); text-align: left; text-decoration: none; cursor: pointer; }
.menu__item:hover, .menu__item:focus-visible { background: var(--surface-container-high); }
.menu__item .icon { font-size: 20px; color: var(--on-surface-variant); }
.menu__item--danger, .menu__item--danger .icon { color: var(--error); }
.menu__sep { height: 1px; margin: 6px 8px; background: var(--outline-variant); }
.menu__head { padding: 10px 14px 8px; }

/* ---------- Side sheet + dialog ---------- */
.sheet { position: fixed; inset: 0; z-index: 100; visibility: hidden; transition: visibility 0s linear var(--t-med); }
.sheet.is-open { visibility: visible; transition-delay: 0s; }
.sheet__scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity var(--t-med) var(--ease); }
.sheet.is-open .sheet__scrim { opacity: 1; }
.sheet__panel {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(560px, calc(100vw - 24px)); display: flex; flex-direction: column;
  background: var(--surface-container-low); --field-bg: var(--surface-container-low); border-radius: var(--r-2xl); box-shadow: var(--shadow-3);
  transform: translateX(calc(100% + 24px)); transition: transform var(--t-med) var(--spring-soft);
}
.sheet.is-open .sheet__panel { transform: none; }
.sheet__head { display: flex; align-items: center; gap: 12px; padding: 20px 20px 12px 28px; }
.sheet__head h2 { flex: 1; }
.sheet__body { flex: 1; overflow-y: auto; padding: 16px 28px 28px; }
.sheet__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; }

.dialog { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 24px; visibility: hidden; transition: visibility 0s linear var(--t-med); }
.dialog.is-open { visibility: visible; transition-delay: 0s; }
.dialog__scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity var(--t-fast); }
.dialog.is-open .dialog__scrim { opacity: 1; }
.dialog__panel { position: relative; width: min(420px, 100%); padding: 28px; border-radius: var(--r-2xl); background: var(--surface-container-high); box-shadow: var(--shadow-3); opacity: 0; transform: scale(.85); transition: transform var(--t-med) var(--spring), opacity var(--t-fast); }
.dialog.is-open .dialog__panel { opacity: 1; transform: none; }
.dialog__icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 16px; border-radius: var(--r-lg); background: var(--error-container); color: var(--on-error-container); }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* ---------- Snackbar ---------- */
.snackbar {
  position: fixed; z-index: 120; left: 50%; bottom: 28px; display: flex; align-items: center; gap: 12px; min-height: 52px; max-width: min(560px, calc(100vw - 32px));
  padding: 10px 12px 10px 18px; border-radius: var(--r-lg); background: var(--inverse-surface); color: var(--inverse-on-surface); box-shadow: var(--shadow-3);
  font-weight: 500; transform: translate(-50%, 140%); transition: transform var(--t-med) var(--spring);
}
.snackbar.is-open { transform: translate(-50%, 0); }
.snackbar--error { background: var(--error); color: var(--on-error); }
.snackbar .icon-btn { color: inherit; }

/* ---------- Tabs ---------- */
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-full); background: var(--surface-container-high); }
.tabs__tab { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border: 0; border-radius: var(--r-full); background: transparent; color: var(--on-surface-variant); font: 600 14px var(--font-ui); text-decoration: none; cursor: pointer; transition: background-color var(--t-fast), color var(--t-fast), transform var(--t-med) var(--spring); }
.tabs__tab:hover { color: var(--on-surface); }
.tabs__tab.is-active { background: var(--surface-container-lowest); color: var(--on-surface); box-shadow: var(--shadow-1); }
.tabs__tab .icon { font-size: 20px; }

/* ---------- Progress: linear, wavy and the morphing loader ---------- */
.bar { height: 8px; border-radius: var(--r-full); background: var(--surface-container-high); overflow: hidden; }
.bar__fill { height: 100%; width: calc(var(--v, 0) * 1%); border-radius: var(--r-full); background: var(--primary); transform-origin: left; animation: bar-in 1s var(--spring-soft) both; }
.bar--primary .bar__fill { background: var(--brand-primary); } .bar--secondary .bar__fill { background: var(--brand-secondary); } .bar--accent .bar__fill { background: var(--brand-accent); } .bar--neutral .bar__fill { background: var(--inverse-surface); } .bar--thick { height: 14px; }
@keyframes bar-in { from { transform: scaleX(0); } }

.wavy { display: block; width: 100%; height: 12px; color: var(--primary); }
.wavy path { stroke: currentColor; stroke-width: 4; fill: none; stroke-linecap: round; animation: wavy-move 1.2s linear infinite; }
@keyframes wavy-move { to { transform: translateX(-40px); } }

.loader { width: 48px; height: 48px; background: var(--primary); animation: loader-morph 2.4s var(--ease) infinite, loader-spin 2.4s linear infinite; }
@keyframes loader-morph {
  0%, 100% { border-radius: 50%; }
  25% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
  50% { border-radius: 22%; }
  75% { border-radius: 70% 30% 30% 70% / 60% 40% 60% 40%; }
}
@keyframes loader-spin { to { transform: rotate(360deg); } }

/* ---------- Empty state ---------- */
.empty { display: grid; justify-items: center; gap: 10px; padding: 56px 24px; text-align: center; color: var(--on-surface-variant); }
.empty__art { display: grid; place-items: center; width: 96px; height: 96px; margin-bottom: 8px; background: var(--secondary-container); color: var(--on-secondary-container); border-radius: 38% 62% 55% 45% / 50% 42% 58% 50%; animation: blob 9s var(--ease) infinite alternate; }
@keyframes blob { to { border-radius: 60% 40% 42% 58% / 44% 60% 40% 56%; transform: rotate(8deg); } }

/* ---------- Motion utilities ---------- */
.reveal { opacity: 0; transform: translateY(28px) scale(.98); transition: opacity .6s var(--ease-out), transform var(--t-slow) var(--spring-soft); transition-delay: calc(var(--i, 0) * 70ms); }
.reveal.is-in { opacity: 1; transform: none; }
.stagger > * { animation: rise var(--t-slow) var(--spring-soft) both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes rise { from { opacity: 0; transform: translateY(22px) scale(.97); } }
@keyframes pop { from { opacity: 0; transform: scale(.7); } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(var(--rot, 0deg)); } 50% { transform: translateY(-14px) rotate(calc(var(--rot, 0deg) + 2deg)); } }
@keyframes spin-slow { to { transform: rotate(360deg); } }

/* Cross-document view transitions: content pane slides, navigation stays put */
@view-transition { navigation: auto; }
::view-transition-old(page) { animation: vt-out .18s var(--ease-in) both; }
::view-transition-new(page) { animation: vt-in .42s var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-10px) scale(.99); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(18px) scale(.99); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
  @view-transition { navigation: none; }
}

/* ---------- Layout helpers ---------- */
.row { display: flex; align-items: center; gap: 12px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }
.grow { flex: 1; min-width: 0; }
.hide { display: none !important; }
.t-right { text-align: right; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .sheet__panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 92vh; border-radius: var(--r-2xl) var(--r-2xl) 0 0; transform: translateY(105%); }
}
