/* ==========================================================================
   SKCE workspace — design system
   --------------------------------------------------------------------------
   One stylesheet for every workspace page. Reference: docs/design-system.md.

   1  Tokens          6  Buttons           11 Badges, tags, chips
   2  Base            7  Forms             12 Alerts, flash, toasts
   3  Shell           8  Cards, stats      13 Dialog, menu, popovers
   4  Page header     9  Tables            14 Empty, placeholder, busy
   5  Layout helpers  10 Toolbar, pager    15 Auth, errors, utilities
   ========================================================================== */

/* ============================================================== 1 Tokens == */
:root {
  color-scheme: light;

  /* neutrals — cool grey with a hint of blue */
  --gray-0: #ffffff;
  --gray-25: #fcfcfd;
  --gray-50: #f7f8fa;
  --gray-100: #f0f2f5;
  --gray-150: #e8ebf0;
  --gray-200: #e1e5eb;
  --gray-300: #ccd2da;
  --gray-400: #98a2b1;
  --gray-500: #626d80;
  --gray-600: #4d5767;
  --gray-700: #374050;
  --gray-800: #222936;
  --gray-900: #121722;

  /* primary — actions, links, focus, selection */
  --blue-50: #eef4fd;
  --blue-100: #dbe7fb;
  --blue-200: #bcd3f7;
  --blue-300: #8db5f0;
  --blue-400: #5a90e4;
  --blue-500: #3571d4;
  --blue-600: #1f5cc0;
  --blue-700: #1a4c9f;
  --blue-800: #1a3f80;
  --blue-900: #1a3565;

  /* brand — the copper of the SKCE mark; brand moments only */
  --copper-50: #fdf5ee;
  --copper-100: #f9e5d3;
  --copper-300: #e9a46b;
  --copper-500: #c96a27;
  --copper-600: #aa551f;
  --copper-700: #88431c;

  /* semantic */
  --green-50: #ecf8f1;
  --green-200: #b5e2c7;
  --green-600: #177245;
  --green-700: #125c38;
  --amber-50: #fff7e8;
  --amber-200: #f6d79d;
  --amber-600: #945a00;
  --amber-700: #7a4a00;
  --red-50: #fdeff0;
  --red-200: #f3c1c4;
  --red-600: #c02630;
  --red-700: #a01f28;
  --teal-50: #eaf7f5;
  --teal-100: #d4efea;
  --teal-200: #aee0d8;
  --teal-600: #0e7a6e;
  --violet-50: #f4f1fe;
  --violet-100: #e8e1fc;
  --violet-600: #6a45d1;
  --violet-700: #5535ae;
  --indigo-50: #eef1fe;
  --indigo-100: #dde3fc;
  --indigo-600: #4453d6;
  --indigo-700: #3641b0;
  --rose-50: #fdf0f5;
  --rose-100: #fadfe9;
  --rose-600: #c0306e;
  --rose-700: #9e2459;

  /* data identity — each node set keeps one colour everywhere */
  --data-resistivity: var(--blue-600);
  --data-resistivity-bg: var(--blue-50);
  --data-processed: var(--teal-600);
  --data-processed-bg: var(--teal-50);
  --data-geology: var(--copper-600);
  --data-geology-bg: var(--copper-50);

  /* areas — each part of the workspace keeps one colour: its sidebar icon, the
     page icon and the accents of its pages (body.area-*, set from the nav) */
  --area-home: var(--copper-600);
  --area-home-bg: var(--copper-50);
  --area-projects: var(--blue-600);
  --area-projects-bg: var(--blue-50);
  --area-soundings: var(--teal-600);
  --area-soundings-bg: var(--teal-50);
  --area-sections: var(--violet-600);
  --area-sections-bg: var(--violet-50);
  --area-forms: var(--indigo-600);
  --area-forms-bg: var(--indigo-50);
  --area-operators: var(--green-600);
  --area-operators-bg: var(--green-50);
  --area-activity: var(--rose-600);
  --area-activity-bg: var(--rose-50);
  --area-insights: var(--amber-600);
  --area-insights-bg: var(--amber-50);
  --area-backups: var(--gray-600);
  --area-backups-bg: var(--gray-100);
  --area-users: var(--gray-700);
  --area-users-bg: var(--gray-100);
  --accent: var(--primary);
  --accent-bg: var(--primary-subtle);

  /* tables — the heading band, every other row of a list, the row-number
     gutter, and the faint tints of worked-out columns (the data kind they
     come from; --tint on a table picks one) */
  --table-head: #f1f3f7;
  --table-stripe: #f8f9fb;
  --table-gutter: #f4f6f9;
  --tint-neutral: rgba(18, 23, 34, 0.035);
  --tint-resistivity: rgba(31, 92, 192, 0.06);
  --tint-processed: rgba(14, 122, 110, 0.07);
  --tint-geology: rgba(170, 85, 31, 0.07);

  /* chart series, fixed order (Okabe–Ito, colour-vision safe) */
  --series-1: #0072b2;
  --series-2: #e69f00;
  --series-3: #009e73;
  --series-4: #d55e00;
  --series-5: #56b4e9;
  --series-6: #cc79a7;
  --series-7: #8c6d1f;
  --series-8: #4d4d4d;

  /* DailyActivity tasks keep one colour everywhere: TASK_CHOICES order onto the
     series; "others" stays neutral (read with SKCE.taskColor(key)) */
  --task-data-entry: var(--series-1);
  --task-processing: var(--series-2);
  --task-interpretation: var(--series-3);
  --task-report: var(--series-4);
  --task-drawing-map: var(--series-5);
  --task-tendering: var(--series-6);
  --task-accounting: var(--series-7);
  --task-studying: var(--series-8);
  --task-others: var(--gray-400);

  /* roles */
  --bg-app: var(--gray-50);
  --bg-surface: var(--gray-0);
  --bg-subtle: var(--gray-25);
  --bg-muted: var(--gray-100);
  --bg-hover: #f3f5f8;
  --bg-selected: var(--blue-50);
  --bg-inverse: var(--gray-900);
  --bg-raised: var(--bg-surface);
  --bg-segment: var(--bg-surface);

  --border: var(--gray-200);
  --border-subtle: var(--gray-150);
  --border-strong: var(--gray-300);
  --border-focus: var(--blue-500);

  --text: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-500);
  --text-disabled: var(--gray-400);
  --text-inverse: #ffffff;
  --text-inverse-muted: rgba(255, 255, 255, 0.72);
  --text-link: var(--blue-600);

  --primary: var(--blue-600);
  --primary-hover: var(--blue-700);
  --primary-subtle: var(--blue-50);
  --primary-text: var(--blue-700);
  /* the brand blue as text or an icon on a surface (--primary is a fill) */
  --primary-fg: var(--blue-600);

  --success: var(--green-600);
  --success-bg: var(--green-50);
  --success-border: var(--green-200);
  --warning: var(--amber-600);
  --warning-bg: var(--amber-50);
  --warning-border: var(--amber-200);
  --danger: var(--red-600);
  --danger-hover: var(--red-700);
  --danger-bg: var(--red-50);
  --danger-border: var(--red-200);
  /* solid fills that carry white text */
  --danger-fill: var(--danger);
  --danger-fill-hover: var(--danger-hover);
  --avatar-bg: linear-gradient(135deg, var(--copper-300), var(--copper-600));

  /* veils: glass bars over scrolling content, the dimmed page behind a
     dialog or the mobile menu, a busy overlay; hairlines on small keys */
  --bg-glass: rgba(255, 255, 255, 0.95);
  --scrim: rgba(18, 23, 34, 0.4);
  --backdrop: rgba(18, 23, 34, 0.45);
  --busy-veil: rgba(247, 248, 250, 0.72);
  --hover-veil: rgba(0, 0, 0, 0.05);
  --edge-subtle: rgba(18, 23, 34, 0.04);
  --swatch-edge: rgba(18, 23, 34, 0.14);
  --auth-glow-1: rgba(201, 106, 39, 0.10);
  --auth-glow-2: rgba(31, 92, 192, 0.10);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23626d80' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  --select-arrow-sm: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23626d80' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 5.5l3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");

  /* type */
  --font-sans: 'Vazirmatn', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --text-2xs: 0.6875rem;  /* 11 */
  --text-xs: 0.75rem;     /* 12 */
  --text-sm: 0.8125rem;   /* 13 */
  --text-base: 0.875rem;  /* 14 */
  --text-md: 1rem;        /* 16 */
  --text-lg: 1.125rem;    /* 18 */
  --text-xl: 1.375rem;    /* 22 */
  --text-2xl: 1.75rem;    /* 28 */
  --leading-tight: 1.25;
  --leading-normal: 1.5;

  /* space (4px grid) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;

  --shadow-xs: 0 1px 2px rgba(18, 23, 34, 0.05);
  --shadow-sm: 0 1px 3px rgba(18, 23, 34, 0.08), 0 1px 2px rgba(18, 23, 34, 0.04);
  --shadow-md: 0 6px 16px -4px rgba(18, 23, 34, 0.12), 0 2px 4px -2px rgba(18, 23, 34, 0.06);
  --shadow-lg: 0 16px 40px -8px rgba(18, 23, 34, 0.18), 0 4px 10px -4px rgba(18, 23, 34, 0.08);
  --ring: 0 0 0 3px rgba(53, 113, 212, 0.28);
  --ring-danger: 0 0 0 3px rgba(192, 38, 48, 0.22);

  --ease: cubic-bezier(0.2, 0, 0, 1);
  --fast: 120ms;
  --normal: 180ms;

  --sidebar-w: 248px;
  --control-h: 36px;
  --control-h-sm: 30px;

  --z-sticky: 20;
  --z-header: 30;
  --z-dropdown: 50;
  --z-drawer: 60;
  --z-dialog: 100;
  --z-toast: 110;
}

/* =========================================================== Dark theme == */
/* html[data-theme="dark"]: chosen in the user menu, kept in the skce_theme
   cookie and rendered by the server (so a page never flashes light).
   Every colour scale flips: its low steps, which components use for tints,
   backgrounds and borders, turn into deep shades; its high steps, used for
   text and icons, turn bright. So each component keeps its meaning and its
   colour family (a resistivity blue stays blue, a warning amber). The
   semantic tokens that do not follow a scale, the solid fills that carry
   white text and the veils are set directly. Contrast of the pairs that
   matter is checked by apps/workspace/tests/test_theme.py. On paper the
   theme is always light: it applies to screens only. */
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;

    --gray-0: #161b22;
    --gray-25: #1a2029;
    --gray-50: #0d1117;
    --gray-100: #1f2630;
    --gray-150: #262e39;
    --gray-200: #2d3540;
    --gray-300: #3d4756;
    --gray-400: #626d7d;
    --gray-500: #8b95a5;
    --gray-600: #aeb7c4;
    --gray-700: #c9d0da;
    --gray-800: #dde2e9;
    --gray-900: #e6eaf0;

    --blue-50: #152640;
    --blue-100: #1b3152;
    --blue-200: #27477a;
    --blue-300: #3a67a8;
    --blue-400: #5a8fe0;
    --blue-500: #6a9cf0;
    --blue-600: #7fb0ff;
    --blue-700: #a8c8ff;
    --blue-800: #c6dcff;
    --blue-900: #deeaff;

    --copper-50: #2c1f14;
    --copper-100: #3d2a1a;
    --copper-300: #b8652d;
    --copper-500: #d98a4a;
    --copper-600: #e39c5f;
    --copper-700: #f0bd8c;

    --green-50: #10261b;
    --green-200: #1f5a3a;
    --green-600: #4cc98a;
    --green-700: #80ddac;
    --amber-50: #2b200b;
    --amber-200: #5c4512;
    --amber-600: #e8b04b;
    --amber-700: #f3c979;
    --red-50: #2e1518;
    --red-200: #6b2a30;
    --red-600: #f16d73;
    --red-700: #f7979b;
    --teal-50: #0f2926;
    --teal-100: #143632;
    --teal-200: #1e5049;
    --teal-600: #43c7b5;
    --violet-50: #211a3b;
    --violet-100: #2b2250;
    --violet-600: #a98cf8;
    --violet-700: #c4b0ff;
    --indigo-50: #1b2042;
    --indigo-100: #232b57;
    --indigo-600: #919dff;
    --indigo-700: #b4bcff;
    --rose-50: #2e1623;
    --rose-100: #3e1e30;
    --rose-600: #f171a8;
    --rose-700: #f89bc3;

    /* chart series: the same eight hues, bright enough for a dark ground */
    --series-1: #3d9be0;
    --series-2: #f0b429;
    --series-3: #22c197;
    --series-4: #f07c3a;
    --series-5: #7cc8f0;
    --series-6: #e08fc0;
    --series-7: #c9a24a;
    --series-8: #a0a7b3;

    --bg-hover: #222a35;
    --bg-inverse: #2a313c;
    --bg-raised: #1c222b;
    --bg-segment: #2f3744;
    --primary: #2f6fdf;
    --primary-hover: #3d7ae6;
    --danger-fill: #c9383f;
    --danger-fill-hover: #d9464d;
    --avatar-bg: linear-gradient(135deg, #b8652d, #8f4a21);

    --table-head: #1c222b;
    --table-stripe: #191f27;
    --table-gutter: #1a2029;
    --tint-neutral: rgba(255, 255, 255, 0.03);
    --tint-resistivity: rgba(127, 176, 255, 0.08);
    --tint-processed: rgba(67, 199, 181, 0.09);
    --tint-geology: rgba(227, 156, 95, 0.09);

    --bg-glass: rgba(22, 27, 34, 0.95);
    --scrim: rgba(0, 0, 0, 0.55);
    --backdrop: rgba(0, 0, 0, 0.6);
    --busy-veil: rgba(13, 17, 23, 0.72);
    --hover-veil: rgba(255, 255, 255, 0.08);
    --edge-subtle: rgba(255, 255, 255, 0.05);
    --swatch-edge: rgba(255, 255, 255, 0.16);
    --auth-glow-1: rgba(227, 156, 95, 0.08);
    --auth-glow-2: rgba(127, 176, 255, 0.07);
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b95a5' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    --select-arrow-sm: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%238b95a5' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 5.5l3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.55), 0 2px 4px -2px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6), 0 4px 10px -4px rgba(0, 0, 0, 0.4);
    --ring: 0 0 0 3px rgba(106, 156, 240, 0.35);
    --ring-danger: 0 0 0 3px rgba(241, 109, 115, 0.3);
  }
}

/* The current area (on <body>, from the active nav item) and each nav item's
   own area set --accent / --accent-bg for everything inside them. */
.area-home { --accent: var(--area-home); --accent-bg: var(--area-home-bg); }
.area-projects { --accent: var(--area-projects); --accent-bg: var(--area-projects-bg); }
.area-soundings { --accent: var(--area-soundings); --accent-bg: var(--area-soundings-bg); }
.area-sections { --accent: var(--area-sections); --accent-bg: var(--area-sections-bg); }
.area-forms { --accent: var(--area-forms); --accent-bg: var(--area-forms-bg); }
.area-operators { --accent: var(--area-operators); --accent-bg: var(--area-operators-bg); }
.area-activity { --accent: var(--area-activity); --accent-bg: var(--area-activity-bg); }
.area-insights { --accent: var(--area-insights); --accent-bg: var(--area-insights-bg); }
.area-backups { --accent: var(--area-backups); --accent-bg: var(--area-backups-bg); }
.area-users { --accent: var(--area-users); --accent-bg: var(--area-users-bg); }

/* ================================================================ 2 Base == */
*, *::before, *::after { box-sizing: border-box; }

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

body.ws {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-app);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.ws :where(h1, h2, h3, h4) {
  margin: 0;
  color: var(--text);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: -0.012em;
}
.ws :where(h1) { font-size: var(--text-xl); }
.ws :where(h2) { font-size: var(--text-lg); }
.ws :where(h3) { font-size: var(--text-md); }
.ws :where(h4) { font-size: var(--text-base); }
.ws :where(p) { margin: 0 0 var(--space-3); }
.ws :where(p:last-child) { margin-bottom: 0; }
.ws :where(a) { color: var(--text-link); text-decoration: none; }
.ws :where(a:hover) { text-decoration: underline; text-underline-offset: 2px; }
.ws :where(small) { font-size: var(--text-xs); }
.ws :where(hr) { border: 0; border-top: 1px solid var(--border); margin: var(--space-6) 0; }
.ws :where(code, kbd, samp) { font-family: var(--font-mono); font-size: 0.92em; }
.ws :where(img, svg, canvas) { max-width: 100%; }
.ws :where(ul, ol) { margin: 0; padding-left: var(--space-5); }

.ws :focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

kbd {
  display: inline-flex;
  align-items: center;
  min-width: 1.5em;
  height: 1.5em;
  padding: 0 0.35em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: var(--text-2xs);
  line-height: 1;
  justify-content: center;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -48px;
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--text-inverse);
  font-weight: 600;
}
.skip-link:focus { top: var(--space-4); text-decoration: none; }

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

/* =============================================================== 3 Shell == */
.ws-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.ws-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  z-index: var(--z-drawer);
}

.ws-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  min-height: 64px;
  color: var(--text);
  border-bottom: 1px solid var(--border-subtle);
}
.ws-brand:hover { text-decoration: none; }
.ws-brand img { width: 32px; height: 32px; flex: none; }
.ws-brand__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.ws-brand__text strong { font-size: var(--text-md); font-weight: 700; letter-spacing: 0.02em; }
.ws-brand__text span { color: var(--text-muted); font-size: var(--text-xs); }

.ws-nav { flex: 1; padding: var(--space-3) var(--space-3) var(--space-4); }
.ws-nav__section + .ws-nav__section { margin-top: var(--space-4); }
.ws-nav__label {
  margin: 0 0 var(--space-1);
  padding: 0 var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.ws-nav ul { list-style: none; margin: 0; padding: 0; }
.ws-nav li + li { margin-top: 1px; }
.ws-nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-3);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-weight: 500;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.ws-nav__item > i:first-child { width: 18px; text-align: center; color: var(--accent); opacity: 0.8; font-size: 0.95em; }
.ws-nav__item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.ws-nav__item:hover > i:first-child { opacity: 1; }
.ws-nav__item.is-active { background: var(--accent-bg); color: var(--text); font-weight: 600; }
.ws-nav__item.is-active > i:first-child { opacity: 1; }
.ws-nav__item.is-active::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--space-3));
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.ws-sidebar__footer { padding: var(--space-3); border-top: 1px solid var(--border-subtle); }

.ws-user { position: relative; }
.ws-user > summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  list-style: none;
}
.ws-user > summary::-webkit-details-marker { display: none; }
.ws-user > summary:hover { background: var(--bg-hover); }
.ws-user__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ws-user__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-user__role { color: var(--text-muted); font-size: var(--text-xs); }
.ws-user__chevron { margin-left: auto; color: var(--text-muted); font-size: 0.75em; transition: transform var(--fast) var(--ease); }
.ws-user[open] .ws-user__chevron { transform: rotate(180deg); }

.avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--avatar-bg);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.avatar--sm { width: 24px; height: 24px; font-size: var(--text-2xs); }
.avatar--neutral { background: var(--bg-muted); color: var(--text-secondary); }

.ws-main { display: flex; flex-direction: column; min-width: 0; }

.ws-topbar { display: none; }

.ws-content { flex: 1; padding: var(--space-6) var(--space-8) var(--space-12); min-width: 0; }
.ws-content--flush { padding: 0; }
.ws-content--narrow > * { max-width: 820px; }

/* Mobile: the sidebar becomes a drawer behind a top bar. */
@media (max-width: 960px) {
  .ws-shell { grid-template-columns: minmax(0, 1fr); }
  .ws-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 300px);
    transform: translateX(-100%);
    /* hidden drawers must not take keyboard focus or cast a shadow */
    visibility: hidden;
    box-shadow: none;
    transition: transform var(--normal) var(--ease), visibility 0s linear var(--normal);
  }
  .ws-shell.is-nav-open .ws-sidebar {
    transform: none;
    visibility: visible;
    box-shadow: var(--shadow-lg);
    transition: transform var(--normal) var(--ease);
  }
  .ws-scrim {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-drawer) - 1);
    background: var(--scrim);
  }
  .ws-topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: 56px;
    padding: 0 var(--space-4);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
  }
  .ws-topbar img { width: 28px; height: 28px; }
  .ws-topbar strong { font-size: var(--text-md); letter-spacing: 0.02em; }
  .ws-content { padding: var(--space-4) var(--space-4) var(--space-10); }
}
@media (min-width: 961px) {
  .ws-scrim { display: none !important; }
}

/* ========================================================= 4 Page header == */
.ws-page-header {
  padding: var(--space-5) var(--space-8) 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.ws-page-header:not(:has(.tabs)) { padding-bottom: var(--space-5); }
.ws-page-header__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.ws-page-header__titles { min-width: 0; flex: 1 1 320px; }
.ws-page-header__row > .ws-page-icon + .ws-page-header__titles { flex-basis: 260px; }
.ws-page-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: calc(-1 * var(--space-1));
  border-radius: var(--radius-lg);
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 1.15rem;
  box-shadow: inset 0 0 0 1px var(--edge-subtle);
}
.ws-page-header h1 { font-size: var(--text-xl); letter-spacing: -0.018em; }
.ws-page-header__title-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.ws-page-header__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-4);
  margin-top: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}
/* items flow as text, so "6 soundings" keeps its one space; the icon gets the gap */
.ws-page-header__meta > * { min-width: 0; }
.ws-page-header__meta i { margin-right: var(--space-2); color: var(--text-muted); font-size: 0.9em; }
.ws-page-header__actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.ws-page-header .tabs { margin-top: var(--space-4); border-bottom: 0; margin-bottom: -1px; }

@media (max-width: 960px) {
  .ws-page-header { padding: var(--space-4) var(--space-4) 0; }
  .ws-page-header:not(:has(.tabs)) { padding-bottom: var(--space-4); }
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  padding: 0;
  list-style: none;
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.crumbs li { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; }
.crumbs li + li::before {
  content: "";
  width: 5px;
  height: 5px;
  border-top: 1.5px solid var(--gray-400);
  border-right: 1.5px solid var(--gray-400);
  transform: rotate(45deg);
  margin-right: 2px;
}
.crumbs a { color: var(--text-secondary); }
.crumbs a:hover { color: var(--text); }
.crumbs [aria-current="page"] { color: var(--text); font-weight: 500; }

/* ======================================================= 5 Layout helpers == */
.stack { display: flex; flex-direction: column; gap: var(--space-6); }
.stack-4 { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-3 { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-2 { display: flex; flex-direction: column; gap: var(--space-2); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.cluster-3 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.cluster--between { justify-content: space-between; }
.cluster--end { justify-content: flex-end; }
.cluster--center { justify-content: center; }
.spacer { flex: 1 1 auto; }

.grid { display: grid; gap: var(--space-4); }
.grid-2 { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: var(--space-4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: var(--space-4); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-stats { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: var(--space-6); }
.split { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.split--wide-aside { grid-template-columns: minmax(0, 1fr) 420px; }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .split, .split--wide-aside { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

.narrow { max-width: 820px; }
.narrower { max-width: 560px; }

/* ============================================================= 6 Buttons == */
.btn {
  --btn-bg: var(--bg-surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  --btn-bg-hover: var(--bg-hover);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-h);
  padding: 0 var(--space-4);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
              color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
  user-select: none;
}
.btn:hover { background: var(--btn-bg-hover); text-decoration: none; color: var(--btn-fg); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn > i { font-size: 0.95em; }

.btn--primary { --btn-bg: var(--primary); --btn-fg: #fff; --btn-border: var(--primary); --btn-bg-hover: var(--primary-hover); }
.btn--primary:hover { border-color: var(--primary-hover); }
.btn--danger { --btn-bg: var(--danger-fill); --btn-fg: #fff; --btn-border: var(--danger-fill); --btn-bg-hover: var(--danger-fill-hover); }
.btn--danger:hover { border-color: var(--danger-fill-hover); }
.btn--danger:focus-visible { box-shadow: var(--ring-danger); }
.btn--danger-soft { --btn-bg: var(--bg-surface); --btn-fg: var(--danger); --btn-border: var(--danger-border); --btn-bg-hover: var(--danger-bg); }
/* a second, lighter way to the page's main action (the blue button stays the one primary) */
.btn--primary-soft { --btn-bg: var(--primary-subtle); --btn-fg: var(--primary-text); --btn-border: var(--blue-200); --btn-bg-hover: var(--blue-100); }
.btn--ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--text-secondary); --btn-bg-hover: var(--bg-hover); box-shadow: none; }
.btn--ghost:hover { color: var(--text); }
.btn--link { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--text-link); --btn-bg-hover: transparent; box-shadow: none; padding: 0; height: auto; }
.btn--link:hover { text-decoration: underline; }

.btn--sm { height: var(--control-h-sm); padding: 0 var(--space-3); font-size: var(--text-sm); gap: 6px; }
.btn--lg { height: 42px; padding: 0 var(--space-5); font-size: var(--text-md); }
.btn--icon { width: var(--control-h); padding: 0; }
.btn--icon.btn--sm { width: var(--control-h-sm); }
.btn--block { width: 100%; }

.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; opacity: 1; }
.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-color: var(--btn-fg) var(--btn-fg) transparent transparent;
  border-radius: 50%;
  animation: ws-spin 0.7s linear infinite;
}
@keyframes ws-spin { to { transform: rotate(360deg); } }

.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; box-shadow: none; }
.btn-group > .btn + .btn { margin-left: -1px; }
.btn-group > .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.btn-group > .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group > .btn:focus-visible { position: relative; z-index: 1; }

/* segmented control: a radio-like choice between 2-4 options */
.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--radius);
  background: var(--bg-muted);
  gap: 2px;
}
.segmented > a, .segmented > button, .segmented > label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: calc(var(--control-h-sm) - 4px);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.segmented > a:hover, .segmented > button:hover, .segmented > label:hover { color: var(--text); text-decoration: none; }
.segmented > .is-active, .segmented > label:has(input:checked) {
  background: var(--bg-segment);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.segmented input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.segmented > label:has(input:focus-visible) { box-shadow: var(--ring); }

/* =============================================================== 7 Forms == */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { color: var(--text); font-size: var(--text-sm); font-weight: 600; }
/* a group of choices is a fieldset: no box, its legend is the field's label */
fieldset.field { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset.field > legend.field__label { margin-bottom: var(--space-2); padding: 0; }
.field__label .optional { color: var(--text-muted); font-weight: 400; }
.field__hint { color: var(--text-muted); font-size: var(--text-xs); }
.field__error { color: var(--danger); font-size: var(--text-xs); font-weight: 500; }
.field__error ul { list-style: none; margin: 0; padding: 0; }
.field--inline { flex-direction: row; align-items: center; gap: var(--space-3); }

.input, .select, .textarea {
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.input::placeholder, .textarea::placeholder, .cell-input::placeholder { color: var(--text-disabled); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--gray-400); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--border-focus); box-shadow: var(--ring); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] {
  background: var(--bg-muted);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}
.input[readonly] { cursor: default; }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"],
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); }
.input[aria-invalid="true"]:focus, .field.has-error .input:focus { box-shadow: var(--ring-danger); }
.textarea { height: auto; min-height: 88px; padding: var(--space-2) var(--space-3); resize: vertical; line-height: var(--leading-normal); }
.select {
  appearance: none;
  padding-right: var(--space-8);
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.select[multiple] { height: auto; min-height: 140px; padding: var(--space-1); background-image: none; }
.select[multiple] option { padding: 4px var(--space-2); border-radius: var(--radius-sm); }
.input--sm, .select--sm { height: var(--control-h-sm); font-size: var(--text-sm); }
.input--num { text-align: right; font-variant-numeric: tabular-nums; }
input[type="number"].input { font-variant-numeric: tabular-nums; }

.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > i { position: absolute; left: 11px; color: var(--text-muted); font-size: 0.9em; pointer-events: none; }
.input-icon > .input { padding-left: 32px; }

.check, .radio { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.check__input, .radio__input, .check input[type="checkbox"], .radio input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
  flex: none;
}
.radio-group { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
/* A choice between a few options, each with a line saying what it means
   (a user's access): the chosen one is highlighted. */
.option-list { display: grid; gap: var(--space-2); min-width: 0; margin: 0; padding: 0; border: 0; }
.option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.option:hover { border-color: var(--border-strong); }
.option:has(input:checked) { border-color: var(--blue-300); background: var(--bg-selected); }
.option:has(input:focus-visible) { box-shadow: var(--ring); }
.option:has(input:disabled) { cursor: default; opacity: 0.75; }
.option > input { margin-top: 2px; }
.option__title { display: block; color: var(--text); font-weight: 600; }
.option__text { display: block; margin-top: 1px; color: var(--text-muted); font-size: var(--text-xs); }

.form-grid { display: grid; gap: var(--space-4) var(--space-5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .field--wide { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid, .form-grid--3 { grid-template-columns: minmax(0, 1fr); } }

.form-section + .form-section { margin-top: var(--space-6); padding-top: var(--space-6); border-top: 1px solid var(--border-subtle); }
.form-section__title { margin-bottom: var(--space-1); font-size: var(--text-md); }
.form-section__intro { margin-bottom: var(--space-4); color: var(--text-secondary); font-size: var(--text-sm); }

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.form-actions--start { justify-content: flex-start; }
.form-actions--between { justify-content: space-between; }

/* A save bar pinned to the bottom of the viewport on long editable pages. */
.action-bar {
  position: sticky;
  bottom: var(--space-4);
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(6px);
}
.action-bar__status { color: var(--text-secondary); font-size: var(--text-sm); }
.action-bar__keys { color: var(--text-muted); font-size: var(--text-xs); white-space: nowrap; }
@media (max-width: 760px) { .action-bar__keys { display: none; } }
.action-bar__status.is-dirty { color: var(--warning); font-weight: 600; }

/* ======================================================= 8 Cards, stats == */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.card__header--plain { border-bottom: 0; padding-bottom: 0; }
.card__title { margin: 0; font-size: var(--text-md); font-weight: 600; }
/* an icon tile in front of a card's title (and subtitle) */
.card__lead { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.card__lead > div { min-width: 0; }
/* a link to another area shows that area's colour on its icon */
.menu__item[class*="area-"] > i { color: var(--accent); }

/* Icon tile: a coloured square behind an icon. The page's accent unless a
   colour modifier is given; data kinds and areas have their own. */
.icon-tile {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--tile-bg, var(--accent-bg));
  color: var(--tile-fg, var(--accent));
  font-size: 0.95rem;
}
.icon-tile--sm { width: 30px; height: 30px; border-radius: var(--radius); font-size: 0.85rem; }
.icon-tile--lg { width: 44px; height: 44px; border-radius: var(--radius-lg); font-size: 1.1rem; }
.icon-tile--blue { --tile-fg: var(--blue-600); --tile-bg: var(--blue-50); }
.icon-tile--teal { --tile-fg: var(--teal-600); --tile-bg: var(--teal-50); }
.icon-tile--violet { --tile-fg: var(--violet-600); --tile-bg: var(--violet-50); }
.icon-tile--indigo { --tile-fg: var(--indigo-600); --tile-bg: var(--indigo-50); }
.icon-tile--green { --tile-fg: var(--green-600); --tile-bg: var(--green-50); }
.icon-tile--rose { --tile-fg: var(--rose-600); --tile-bg: var(--rose-50); }
.icon-tile--amber { --tile-fg: var(--amber-600); --tile-bg: var(--amber-50); }
.icon-tile--copper { --tile-fg: var(--copper-600); --tile-bg: var(--copper-50); }
.icon-tile--red { --tile-fg: var(--red-600); --tile-bg: var(--red-50); }
.icon-tile--gray { --tile-fg: var(--gray-600); --tile-bg: var(--gray-100); }
.icon-tile--resistivity { --tile-fg: var(--data-resistivity); --tile-bg: var(--data-resistivity-bg); }
.icon-tile--processed { --tile-fg: var(--data-processed); --tile-bg: var(--data-processed-bg); }
.icon-tile--geology { --tile-fg: var(--data-geology); --tile-bg: var(--data-geology-bg); }
.card__subtitle { margin: 2px 0 0; color: var(--text-muted); font-size: var(--text-sm); }
.card__body { padding: var(--space-5); }
.card__body--flush { padding: 0; }
.card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.card > .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.card > .table-wrap:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card--interactive { transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease); }
.card--interactive:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
a.card { display: block; color: inherit; }
a.card:hover { text-decoration: none; }

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  color: inherit;
}
a.stat:hover { border-color: var(--border-strong); text-decoration: none; }
.stat__label { color: var(--text-secondary); font-size: var(--text-sm); font-weight: 500; }
.stat__value { font-size: var(--text-2xl); font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat__meta { color: var(--text-muted); font-size: var(--text-xs); }
.stat__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-md);
  background: var(--tile-bg, var(--bg-muted));
  color: var(--tile-fg, var(--text-secondary));
}
/* a stat whose label shares a row with its icon tile */
.stat__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); }
.stat__head > .icon-tile { margin: -2px -4px 0 0; }
a.stat:hover .icon-tile { filter: saturate(1.15); }

/* progress / completeness bar; pair with a text label */
.meter {
  position: relative;
  height: 6px;
  min-width: 48px;
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  overflow: hidden;
}
.meter > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--primary); }
.meter--fixed { width: 96px; flex: none; }
.meter--resistivity > span { background: var(--data-resistivity); }
.meter--processed > span { background: var(--data-processed); }
.meter--geology > span { background: var(--data-geology); }

.dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-2) var(--space-5);
  margin: 0;
  font-size: var(--text-sm);
}
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }

/* ============================================================== 9 Tables == */
.table-wrap {
  position: relative;
  width: 100%;
  overflow: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.table-wrap--tall { max-height: calc(100vh - 240px); }

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
}
.table th, .table td {
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: middle;
}
/* the heading band: shaded, so the columns' names stand apart from the rows */
.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--table-head);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
/* a unit or a short explanation under a column's name */
.th-sub {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: var(--text-2xs);
  font-weight: 400;
}
.table tbody tr:last-child > * { border-bottom: 0; }
.table > tbody > tr > * { transition: background-color var(--fast) var(--ease); }
/* every other row of a list is faintly shaded, so a long row is easy to follow
   across; editable grids keep plain rows, where the cells are the wells */
:where(.table:not(.grid-table)) > tbody > tr:nth-child(even) > :not(.row-index) { background-color: var(--table-stripe); }
.table--hover > tbody > tr:hover > * { background-color: var(--bg-hover); }
.table > tbody > tr.is-selected > * { background-color: var(--bg-selected); }
.table tbody tr.is-muted > * { color: var(--text-muted); }
.table .num, .table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .center { text-align: center; }
.table .nowrap { white-space: nowrap; }
.table .shrink { width: 1%; white-space: nowrap; }
.table th a { color: inherit; }
.table th a:hover { color: var(--text); text-decoration: none; }
.table td.actions { width: 1%; white-space: nowrap; text-align: right; }
.table td.actions .btn { vertical-align: middle; }
.table td.actions .cluster { flex-wrap: nowrap; }
.table td.actions form { display: inline-flex; margin: 0; }
.table tfoot td { background: var(--bg-subtle); font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; }
.table--compact th, .table--compact td { padding: 6px var(--space-3); }
.table--bordered th + th, .table--bordered td + td { border-left: 1px solid var(--border-subtle); }
.table__primary { color: var(--text); font-weight: 600; }
a.table__primary:hover { color: var(--primary-fg); }
.table__sub { display: block; margin-top: 1px; color: var(--text-muted); font-size: var(--text-xs); font-weight: 400; }
/* a person in a cell: their initials in a small avatar, then the name */
.person { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; }

/* The row-number column of numbered tables and grids: a shaded gutter, as in a
   spreadsheet (.col-index on its heading). A row with a group colour
   (tr.has-accent, --row-accent) shows it as a strip down the gutter. */
.table .row-index, .table .col-index {
  width: 1%;
  padding-left: var(--space-3);
  padding-right: var(--space-3);
  border-right: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
.table > tbody > tr > .row-index { background-color: var(--table-gutter); }
.table > tbody > tr.has-accent > .row-index { box-shadow: inset 3px 0 0 var(--row-accent); }

/* A worked-out (read-only) column: a faint tint of the data it comes from,
   laid over whatever shades the row, so it reads apart from typed columns. */
.table .is-derived { background-image: linear-gradient(var(--tint, var(--tint-neutral)), var(--tint, var(--tint-neutral))); }
.table td.is-derived { color: var(--text-secondary); }
/* the value a row exists for (ρa of a reading): stronger, in its data colour */
.table .num-key { color: var(--key, var(--text)); font-weight: 600; }

/* A colour key: a dot in a group's colour (--swatch); a ring when the colour
   is only implied (a layer that takes the formation below it). */
.swatch {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--swatch, var(--gray-300));
  box-shadow: inset 0 0 0 1px var(--swatch-edge);
  vertical-align: middle;
}
.swatch--ring { background: var(--bg-surface); box-shadow: inset 0 0 0 2px var(--swatch, var(--gray-300)); }
.badge > .swatch { width: 8px; height: 8px; }

/* A value drawn as a bar in its own column (the layer profiles of the
   editors): --bar from 0 to 1, in the row's colour (--bar-color). */
.table .bar-cell { width: 36%; min-width: 96px; padding-right: var(--space-4); }
.bar {
  display: block;
  width: calc(var(--bar, 0) * 100%);
  min-width: 3px;
  max-width: 100%;
  height: 10px;
  border-radius: 3px;
  background: var(--bar-color, var(--gray-400));
  transition: width var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
/* no formation at all: a hatched grey bar */
.bar--blank {
  background: repeating-linear-gradient(135deg, var(--gray-300) 0 3px, var(--gray-150) 3px 6px);
}

/* sortable headers */
.sort-link { display: inline-flex; align-items: center; gap: 4px; }
.sort-link i { color: var(--text-disabled); font-size: 0.85em; }
.sort-link.is-sorted { color: var(--text); }
.sort-link.is-sorted i { color: var(--primary-fg); }

/* Editable grids: inputs fill cells, chrome only on hover/focus. */
.grid-table td { padding: 3px 6px; }
.grid-table th { padding: 8px 10px; }
/* the row being edited: its gutter turns blue, like a spreadsheet's */
.grid-table > tbody > tr:focus-within > .row-index { background-color: var(--blue-100); color: var(--primary-text); }
.cell-input {
  width: 100%;
  min-width: 72px;
  height: 32px;
  padding: 0 var(--space-2);
  /* a soft well at rest, so every cell of a grid reads as a place to type */
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.cell-input.num, td.num .cell-input { text-align: right; }
.cell-input:hover { border-color: var(--border-strong); background: var(--bg-surface); }
.cell-input:focus { outline: none; border-color: var(--border-focus); background: var(--bg-surface); box-shadow: var(--ring); }
.cell-input[readonly], .cell-input:disabled { color: var(--text-secondary); background: transparent; border-color: transparent; cursor: default; }
.cell-input[readonly]:hover { border-color: transparent; }
.cell-input[aria-invalid="true"], .cell-input.is-invalid { border-color: var(--danger); background: var(--danger-bg); }
select.cell-input { appearance: none; padding-right: 22px; background-image: var(--select-arrow-sm); background-repeat: no-repeat; background-position: right 5px center; }
textarea.cell-input { height: 32px; padding-top: 6px; resize: vertical; line-height: 1.35; }
/* a cell input with a colour key at its start (the MN of a reading, the
   formation of a layer) */
.cell-field { position: relative; display: block; }
.cell-field > .swatch { position: absolute; top: 50%; left: 10px; margin-top: -5px; pointer-events: none; }
.cell-field > .swatch + .cell-input { padding-left: 28px; }
.grid-table tr.is-invalid td { background: var(--danger-bg); }
.grid-table tr.is-new > :first-child { box-shadow: inset 3px 0 0 var(--success); }
.grid-table tr.is-deleted td { opacity: 0.45; text-decoration: line-through; }
.grid-table .cell-error { display: block; padding: 2px var(--space-2) 0; color: var(--danger); font-size: var(--text-2xs); }

/* ================================================= 10 Toolbar, pagination == */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.toolbar__group { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.toolbar__label { color: var(--text-muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.toolbar__search { flex: 1 1 260px; max-width: 360px; }
.toolbar--sticky {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
}
@media (max-width: 960px) { .toolbar--sticky { top: 56px; } }

.pager { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.pager__summary { color: var(--text-secondary); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.pager__pages { display: flex; align-items: center; gap: 2px; }
.pager__page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 var(--space-2);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
a.pager__page:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.pager__page.is-current { background: var(--primary); color: #fff; font-weight: 600; }
.pager__page.is-disabled { color: var(--text-disabled); }
.pager__gap { color: var(--text-muted); padding: 0 4px; }

/* ======================================================== 11 Badges, tags == */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.badge--neutral { background: var(--bg-muted); color: var(--text-secondary); border-color: var(--border); }
.badge--primary { background: var(--primary-subtle); color: var(--primary-text); border-color: var(--blue-200); }
.badge--success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.badge--warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.badge--danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.badge--resistivity { background: var(--data-resistivity-bg); color: var(--data-resistivity); border-color: var(--blue-200); }
.badge--processed { background: var(--data-processed-bg); color: var(--data-processed); border-color: var(--teal-200); }
.badge--geology { background: var(--data-geology-bg); color: var(--data-geology); border-color: var(--copper-100); }
.badge--brand { background: var(--copper-50); color: var(--copper-700); border-color: var(--copper-100); }
.badge .dot, .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* count pills in tabs and nav */
.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  color: var(--text-secondary);
  font-size: var(--text-2xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.count--empty { background: var(--warning-bg); color: var(--warning); }

/* removable / locked value chips (formations) */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 4px 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
}
.tag__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
}
.tag__remove:hover { background: var(--danger-bg); color: var(--danger); }
.tag__lock { display: inline-flex; width: 22px; justify-content: center; color: var(--text-muted); font-size: 0.8em; }
.tag--locked { background: var(--bg-muted); border-color: var(--border); }
.tag-list { display: flex; flex-wrap: wrap; gap: var(--space-2); }
ul.tag-list { margin: 0; padding: 0; list-style: none; }

/* filter chips: toggle links in toolbars */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--control-h-sm);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.chip:hover { border-color: var(--gray-400); color: var(--text); text-decoration: none; }
.chip.is-active { background: var(--primary-subtle); border-color: var(--blue-300); color: var(--primary-text); font-weight: 600; }
.chip.is-active .chip__x { display: inline-block; }
.chip__x { display: none; font-size: 0.85em; }

/* ============================================ 12 Alerts, flash, toasts == */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}
.alert > i { margin-top: 3px; flex: none; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { display: block; margin-bottom: 2px; color: var(--text); font-weight: 600; }
.alert--info { background: var(--primary-subtle); border-color: var(--blue-200); color: var(--blue-800); }
.alert--info > i { color: var(--primary-fg); }
.alert--success { background: var(--success-bg); border-color: var(--success-border); color: var(--green-700); }
.alert--success > i { color: var(--success); }
.alert--warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--amber-700); }
.alert--warning > i { color: var(--warning); }
.alert--danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--red-700); }
.alert--danger > i { color: var(--danger); }
.alert .alert__title { color: inherit; }
.alert__close {
  margin: -4px -6px -4px auto;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font: inherit;
}
.alert__close:hover { opacity: 1; background: var(--hover-veil); }

.flash-stack { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }

.toast-region {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 260px;
  max-width: min(440px, calc(100vw - 2 * var(--space-5)));
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-inverse);
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
  pointer-events: auto;
  animation: ws-toast-in var(--normal) var(--ease);
}
.toast > i { margin-top: 3px; }
.toast--success > i { color: #6ee7a8; }
.toast--error > i { color: #fda4a9; }
.toast--warning > i { color: #fcd07a; }
.toast--info > i { color: #9cc0f5; }
.toast__close { margin-left: auto; padding: 0 4px; border: 0; background: transparent; color: rgba(255, 255, 255, 0.7); cursor: pointer; font: inherit; }
.toast__close:hover { color: #fff; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all var(--normal) var(--ease); }
@keyframes ws-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* =========================================== 13 Dialog, menu, popovers == */
dialog.dialog {
  width: min(480px, calc(100vw - 2 * var(--space-4)));
  max-height: calc(100vh - 2 * var(--space-8));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.dialog--wide { width: min(720px, calc(100vw - 2 * var(--space-4))); }
/* SKCE.showText: a long text (a note) whole, line breaks kept */
.text-dialog__text { color: var(--text); overflow-wrap: anywhere; line-height: 1.7; }
.text-dialog__text > p { margin: 0; white-space: pre-wrap; }
.text-dialog[open] { display: flex; flex-direction: column; }
.text-dialog .dialog__body { min-height: 0; overflow-y: auto; }  /* the one part that scrolls */
dialog.dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); }
dialog.dialog[open] { animation: ws-dialog-in var(--normal) var(--ease); }
@keyframes ws-dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.dialog__header { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-5) var(--space-5) var(--space-2); }
.dialog__icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary-subtle);
  color: var(--primary-fg);
}
.dialog--danger .dialog__icon { background: var(--danger-bg); color: var(--danger); }
.dialog__title { margin: 0; font-size: var(--text-md); font-weight: 600; }
.dialog__body { padding: 0 var(--space-5) var(--space-5); color: var(--text-secondary); font-size: var(--text-base); overflow-wrap: anywhere; }
.dialog__header + .dialog__body { padding-left: calc(var(--space-5) + 36px + var(--space-3)); }
.dialog__body--plain { padding: var(--space-2) var(--space-5) var(--space-5) !important; }
.dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.menu {
  position: absolute;
  z-index: var(--z-dropdown);
  min-width: 200px;
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  box-shadow: var(--shadow-lg);
}
.menu--up { bottom: calc(100% + 6px); left: 0; right: 0; }
.menu--right { right: 0; top: calc(100% + 6px); }
.menu form { margin: 0; }
.menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.menu__item > i { width: 16px; color: var(--text-muted); text-align: center; }
.menu__item:hover { background: var(--bg-hover); text-decoration: none; }
.menu__item--danger { color: var(--danger); }
.menu__item--danger > i { color: var(--danger); }
.menu__sep { height: 1px; margin: var(--space-1) 0; background: var(--border-subtle); }
/* the theme choice in the user menu: Light (the default) or Dark */
.menu__theme {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
}
.menu__label { color: var(--text-muted); font-size: var(--text-xs); font-weight: 600; }
.menu__theme .segmented > button { height: 26px; padding: 0 var(--space-2); font-size: var(--text-xs); }
.menu__theme .segmented > button > i { font-size: 0.9em; }

/* dropdown built on <details> */
.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }

/* combobox (autocomplete) listbox */
.combobox { position: relative; }
.combobox__list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: var(--z-dropdown);
  max-height: 280px;
  margin: 0;
  padding: var(--space-1);
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  box-shadow: var(--shadow-lg);
}
.combobox__option {
  display: flex;
  flex-direction: column;
  padding: 7px var(--space-3);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
}
.combobox__option small { color: var(--text-muted); }
.combobox__option .swatch { margin: -2px 8px 0 0; }
.combobox__option[aria-selected="true"], .combobox__option:hover { background: var(--bg-selected); }
.combobox__empty { padding: var(--space-3); color: var(--text-muted); font-size: var(--text-sm); }
/* a clear (×) button inside a combobox input */
.combobox__clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.combobox__clear:hover { background: var(--bg-hover); color: var(--text); }
.combobox:has(.combobox__clear) > .input { padding-right: 36px; }

/* Jalali date picker popover */
.datepicker {
  position: absolute;
  z-index: var(--z-dropdown);
  width: 288px;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
}
.datepicker__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); }
.datepicker__title { font-weight: 600; direction: rtl; }
.datepicker__title .num { direction: ltr; unicode-bidi: isolate; }
.datepicker__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; direction: rtl; }
.datepicker__grid--months { grid-template-columns: repeat(3, 1fr); gap: var(--space-1); }
.datepicker__dow { padding: 4px 0; color: var(--text-muted); font-size: var(--text-2xs); font-weight: 600; text-align: center; }
.datepicker__day, .datepicker__month {
  height: 32px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.datepicker__month { height: 38px; }
.datepicker__day:hover, .datepicker__month:hover { background: var(--bg-hover); }
.datepicker__day.is-today, .datepicker__month.is-today { box-shadow: inset 0 0 0 1px var(--blue-300); }
.datepicker__day.is-selected, .datepicker__month.is-selected { background: var(--primary); color: #fff; font-weight: 600; }
.datepicker__day:focus-visible, .datepicker__month:focus-visible { outline: none; box-shadow: var(--ring); }
.datepicker__foot { display: flex; justify-content: space-between; margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px solid var(--border-subtle); }

/* ================================================ 14 Empty, busy states == */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-12) var(--space-6);
  text-align: center;
}
.empty--compact { padding: var(--space-8) var(--space-5); }
.empty__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-full);
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 1.25rem;
}
.empty__title { margin: 0; color: var(--text); font-size: var(--text-md); font-weight: 600; }
.empty__text { max-width: 46ch; margin: 0; color: var(--text-secondary); font-size: var(--text-sm); }
.empty__actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); flex-wrap: wrap; justify-content: center; }

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--busy-veil);
  backdrop-filter: blur(1.5px);
}
.busy-overlay__box {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-lg);
  font-weight: 500;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--blue-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: ws-spin 0.7s linear infinite;
  flex: none;
}

/* ============================================================== Tabs == */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3) 10px;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.tabs__item:hover { color: var(--text); text-decoration: none; border-bottom-color: var(--border-strong); }
.tabs__item.is-active { color: var(--primary-text); border-bottom-color: var(--primary); font-weight: 600; }
.tabs__item.is-disabled { color: var(--text-disabled); pointer-events: none; }
.tabs__item > i { font-size: 0.9em; }
.tabs__item--resistivity > i { color: var(--data-resistivity); }
.tabs__item--processed > i { color: var(--data-processed); }
.tabs__item--geology > i { color: var(--data-geology); }

/* ============================================================ History == */
/* An object's change history (views/history.py): one row per add, change or
   delete, an icon tile in the action's colour, then who and when. */
.history { margin: 0; padding: 0; list-style: none; }
.history__item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.history__item:last-child { border-bottom: 0; }
.history__body { flex: 1; min-width: 0; }
.history__text { margin: 0; overflow-wrap: anywhere; }
.history__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.history__who { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-secondary); }

/* ================================================ 15 Auth & error pages == */
.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: var(--space-6) var(--space-4);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--auth-glow-1), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, var(--auth-glow-2), transparent 60%),
    var(--bg-app);
}
.auth__card {
  width: min(400px, 100%);
  padding: var(--space-8);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-md);
}
.auth__brand { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); margin-bottom: var(--space-6); text-align: center; }
.auth__brand img { width: 64px; height: 64px; }
.auth__brand h1 { font-size: var(--text-xl); }
.auth__brand p { margin: 0; color: var(--text-muted); font-size: var(--text-sm); }
.auth__foot { margin-top: var(--space-5); color: var(--text-muted); font-size: var(--text-xs); text-align: center; }

.error-page { display: grid; place-items: center; min-height: 100vh; padding: var(--space-6); background: var(--bg-app); }
.error-page__card { width: min(460px, 100%); text-align: center; }
.error-page__code { color: var(--copper-600); font-size: var(--text-sm); font-weight: 700; letter-spacing: 0.12em; }
.error-page__card h1 { margin: var(--space-2) 0 var(--space-3); font-size: var(--text-2xl); }
.error-page__card p { color: var(--text-secondary); }

/* ============================================================ Utilities == */
/* Pinned to the corner of its containing block: left at its place in the flow,
   a hidden element deep in a scrolled list stretched the whole page (the
   sequence map scrolled 1,200px of nothing). */
.sr-only {
  position: absolute !important;
  top: 0; left: 0;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.hidden, [hidden] { display: none !important; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.warning-text { color: var(--warning); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nowrap { white-space: nowrap; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.fw-600 { font-weight: 600; }
.rtl { direction: rtl; unicode-bidi: isolate; text-align: right; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.m-0 { margin: 0 !important; }
.mt-2 { margin-top: var(--space-2) !important; }
.mt-4 { margin-top: var(--space-4) !important; }
.mt-6 { margin-top: var(--space-6) !important; }
.mb-2 { margin-bottom: var(--space-2) !important; }
.mb-4 { margin-bottom: var(--space-4) !important; }
.mb-6 { margin-bottom: var(--space-6) !important; }
.w-full { width: 100%; }
.maxw-xs { max-width: 200px; }
.maxw-sm { max-width: 320px; }
.maxw-md { max-width: 480px; }

.data-dot--resistivity { color: var(--data-resistivity); }
.data-dot--processed { color: var(--data-processed); }
.data-dot--geology { color: var(--data-geology); }

/* Full-bleed pages (maps): the content fills the space under the header. */
.ws.is-fullbleed .ws-main { height: 100vh; }
.ws.is-fullbleed .ws-content { display: flex; flex-direction: column; padding: 0; min-height: 0; }
@media (max-width: 960px) { .ws.is-fullbleed .ws-main { height: 100dvh; } }

/* Table screens (body.is-fit: the project page, the soundings list, bulk
   editing): the page is exactly the window and the table (.table-wrap--tall
   inside a .fit-fill) takes what the header and toolbar leave, scrolling
   inside. Scrolling the page first, then the table, was pointless. Phones and
   short windows keep an ordinary page, where the table does not scroll on
   its own either. */
@media (min-width: 961px) and (min-height: 600px) {
  .ws.is-fit .ws-main { height: 100vh; }
  .ws.is-fit .ws-content { display: flex; flex-direction: column; min-height: 0; padding-bottom: var(--space-6); }
  .ws.is-fit .fit-fill { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
  .ws.is-fit .fit-fill > .table-wrap--tall { flex: 1 1 auto; min-height: 0; max-height: none; }
  .ws.is-fit .fit-fill > .action-bar { position: static; }
}
@media (max-width: 960px), (max-height: 599px) { .table-wrap--tall { max-height: none; } }

@media print {
  .ws-sidebar, .ws-topbar, .ws-page-header__actions, .action-bar, .toolbar, .toast-region, .no-print { display: none !important; }
  .ws-shell { display: block; }
  body.ws { background: #fff; }
  .card, .table-wrap, .stat { box-shadow: none; break-inside: avoid; }
  .table thead th { position: static; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  canvas { max-width: 100% !important; }
}
