/*
  base.css: the visual system of every page (docs/ARAYUZ-TASARIMI.md). Mobile first, one dark theme, Manrope
  (self-hosted, static/fonts), no external assets, no inline styles anywhere (CSP style-src 'self'). Feature
  packages add their own file under /static/css, link it in the head_extra block and reuse these classes and
  tokens instead of redefining them. Full reference with examples: templates/README.md.

  Tokens (custom properties on :root):
    colours   --ink --paper --surface --line --ink-soft --accent (Pudra) --live (Yayin kirmizisi, only the
              "simdi" line and the live badge, unused so far) --amber --error, plus the working names the pages
              use: --bg --text --muted --border --primary(-hover/-soft/-text) --danger and the status pairs
              --ok/--info/--warn/--crit -bg/-fg/-line
    type      --fs-1..6 = 13/15/17/20/26/34 px, --lh-body 1.55, --font, --mono
    space     --space-1..6 (fluid), --gap
    radii     --radius-panel 14px, --radius-control 10px, --radius-pill (aliases --radius, --radius-small)
    shadow    --shadow-panel: the one shadow, for panels and popovers only (--shadow is none, --shadow-lift is
              the same as --shadow-panel)
    motion    --dur-fast --dur --dur-slow --ease --stagger (all animation is off under prefers-reduced-motion)
    layout    --header-height --nav-width --topbar (sticky offset) --content-max --touch

  Breakpoints: 700px (tables become tables instead of cards), 768px (left icon-only menu), 1024px (menu with
  labels, two columns). Under 768px the menu is a tab bar under the top header.

  Classes (stable names; README.md lists them with examples):
    layout   .page .page-header .page-actions .page-lead .grid-2 .grid-3 .stack .row .row-between .card
             .card-title .card-header .card-actions .section .section-title .divider .kv
    nav      .site-header .brand .site-user .site-nav .nav-main .nav-more .nav-secondary .nav-icon .nav-label
    text     .muted .small .mono .tech-code .plain-list .visually-hidden .skip-link .nowrap .truncate .break
    forms    .field .field-invalid .field-error .field-help .field-check .req .inline-form .form-actions
             .form-grid .span-all .fieldset .fieldset-plain .check-grid
    buttons  .btn .btn-primary .btn-secondary .btn-danger .btn-ghost .btn-small .btn-block .link-button
    status   .badge .badge-ok .badge-info .badge-warn .badge-crit .badge-neutral .badge-accent .badge-hint
             .state-<publication state> .status-<package status> (colour plus text, never colour only)
    hints    .ipucu .ipucu-btn .ipucu-pop (made by the ipucu / ipucu_metin template globals)
    alerts   .alert .alert-info .alert-ok .alert-warn .alert-critical .alert-detail .alert-actions .banners
    tables   .table-wrap (scrolls inside, never the page) .table .table-cards (rows become cards < 700px,
             each td needs data-label) .num .actions-cell
    feedback .toast-region .toast .toast-ok .toast-info .toast-warn .toast-critical .toast-close
    motion   .stagger (children appear one after the other on page load) .rise .panel-slide
    dialog   .dialog .dialog-body .dialog-actions
    misc     .empty-state .empty-title .empty-icon .pagination .chip-nav .chip .avatar .code-box .copy-row
*/

/* Manrope (SIL OFL 1.1, see static/fonts/OFL.txt): latin + latin-ext (Turkish letters), 400/600/700 */
@font-face {
  font-family: Manrope;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/manrope-latin-ext-400-normal.woff2") format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: Manrope;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/manrope-latin-400-normal.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: Manrope;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/manrope-latin-ext-600-normal.woff2") format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: Manrope;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/manrope-latin-600-normal.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: Manrope;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/manrope-latin-ext-700-normal.woff2") format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: Manrope;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/manrope-latin-700-normal.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;

  /* Palette (docs/ARAYUZ-TASARIMI.md): one dark theme built on charcoal, slate, blush, amber, crimson */
  --ink: #ece4e0; /* Metin: body text on the dark page */
  --paper: #32373b; /* Zemin (kombur gri): page background */
  --surface: #3a4044; /* Yuzey: panels, forms, sidebar */
  --line: #4a5859; /* Cizgi (arduvaz): dividers */
  --ink-soft: #b9aea9; /* Soluk metin: secondary text (AA on the surface) */
  --accent: #f4d6cc; /* Pudra: the main action, links */
  --live: #c83e4d; /* Yayin kirmizisi: the "simdi" line, the live badge, danger button fill */
  --amber: #f4b860; /* Dikkat amberi: states that need a look */
  --error: #f4979f; /* error TEXT on dark (crimson is too dark for text) */

  /* Working names used by the pages */
  --bg: var(--paper);
  --surface-2: #42494d; /* hover, insets */
  --text: var(--ink);
  --muted: var(--ink-soft);
  --border: var(--line);
  --border-strong: #7d9192; /* input outlines: 3:1 against the surface */
  --primary: var(--accent);
  --primary-hover: #f8e3db;
  --primary-soft: rgb(244 214 204 / 12%);
  --primary-text: #32373b; /* text on a blush fill */
  --danger: var(--error);
  --danger-fill: var(--live); /* crimson fill, white text */
  --danger-hover: #a9323f;
  --ok-bg: #2f4a3b; /* success is the one hue outside the palette: a muted sage */
  --ok-fg: #a9d8b5;
  --ok-line: #3f6b50;
  --info-bg: #3a4a4b;
  --info-fg: #cfe0e0;
  --info-line: #4a5859;
  --warn-bg: #4a3e2a;
  --warn-fg: #f4c67e;
  --warn-line: #6e5730;
  --crit-bg: #4a2a2f;
  --crit-fg: #f4a3ab;
  --crit-line: #7a3640;
  --neutral-bg: #444b4f;
  --neutral-fg: #e0d8d4;
  --scrim: rgb(20 22 24 / 60%);

  /* Type scale 13 / 15 / 17 / 20 / 26 / 34 */
  --fs-1: 13px;
  --fs-2: 15px;
  --fs-3: 17px;
  --fs-4: 20px;
  --fs-5: 26px;
  --fs-6: 34px;
  --lh-body: 1.55;
  --font: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-mono: var(--mono);

  /* Spacing */
  --space-1: clamp(4px, 0.25rem + 0.1vw, 6px);
  --space-2: clamp(8px, 0.45rem + 0.2vw, 10px);
  --space-3: clamp(12px, 0.65rem + 0.35vw, 16px);
  --space-4: clamp(16px, 0.9rem + 0.5vw, 24px);
  --space-5: clamp(24px, 1.2rem + 1vw, 36px);
  --space-6: clamp(32px, 1.6rem + 2vw, 56px);
  --gap: var(--space-3);

  /* Radii: panel 14, button/field 10, badge pill */
  --radius-panel: 14px;
  --radius-control: 10px;
  --radius-pill: 999px;
  --radius: var(--radius-panel);
  --radius-small: var(--radius-control);

  /* One shadow, for panels and popovers only */
  --shadow-panel: 0 8px 28px rgb(0 0 0 / 35%);
  --shadow: none;
  --shadow-lift: var(--shadow-panel);

  /* Motion */
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 360ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --stagger: 45ms;

  /* Layout */
  --touch: 44px;
  --header-height: 56px;
  --tabs-height: 52px;
  --topbar: calc(var(--header-height) + var(--tabs-height));
  --nav-height: 0px; /* there is no bottom bar any more (screens-a.css offsets sticky bars with it) */
  --nav-width: 72px;
  --content-max: 1180px;
  --focus: 0 0 0 3px rgb(244 184 96 / 55%);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar) + var(--space-3));
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-2);
  line-height: var(--lh-body);
  overflow-x: hidden;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--primary-hover);
}

img,
video,
svg {
  max-width: 100%;
}

img,
video {
  height: auto;
}

h1,
h2,
h3 {
  line-height: 1.25;
  overflow-wrap: anywhere;
}

h1 {
  font-size: clamp(var(--fs-4), 1.1rem + 1.2vw, var(--fs-5));
  margin: 0;
  letter-spacing: -0.01em;
}

h2 {
  font-size: var(--fs-3);
  margin: var(--space-5) 0 var(--space-2);
}

h3 {
  font-size: var(--fs-2);
  margin: var(--space-4) 0 var(--space-2);
}

p {
  margin: 0 0 var(--space-2);
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.88em;
}

hr,
.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-4) 0;
}

/* Accessibility helpers */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
}

.skip-link:focus {
  left: 8px;
  top: 8px;
  background: var(--surface);
  padding: 8px 12px;
  z-index: 100;
  border-radius: var(--radius-small);
  box-shadow: var(--shadow-lift);
}

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* Header ---------------------------------------------------------------------------------------------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 0 var(--space-3);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--touch);
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-text);
  font-size: var(--fs-1);
  font-weight: 800;
}

.site-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--touch);
  color: var(--muted);
  font-size: var(--fs-1);
  text-decoration: none;
  overflow: hidden;
  min-width: 0;
}

.site-user span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: var(--fs-1);
}

/* Navigation: tab bar under the top header on phones (< 768px) ------------------------------------------- */
.site-nav {
  position: sticky;
  top: var(--header-height);
  z-index: 39;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.nav-main {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-main > li {
  flex: 1 1 0;
  min-width: 0;
}

.nav-main a,
.nav-main summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tabs-height);
  padding: 4px 2px 2px;
  color: var(--muted);
  text-decoration: none;
  font-size: var(--fs-1);
  text-align: center;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex: none;
}

.nav-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-main a[aria-current="page"],
.nav-more[data-current] > details > summary {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
}

.nav-more summary {
  list-style: none;
}

.nav-more summary::-webkit-details-marker {
  display: none;
}

/* "Daha fazla" sheet: drops from the tab bar, full width, scrolls inside */
.nav-more ul {
  position: absolute;
  left: 8px;
  right: 8px;
  top: calc(100% + 4px);
  max-height: calc(100vh - var(--topbar) - 16px);
  overflow-y: auto;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
}

.nav-secondary {
  display: none;
}

.nav-more ul a,
.nav-more .link-button,
.nav-secondary a,
.nav-secondary .link-button {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-height: var(--touch);
  padding: 0 16px;
  font-size: var(--fs-2);
  width: 100%;
  color: var(--text);
  text-decoration: none;
  border-bottom: 0;
}

.nav-more ul a[aria-current="page"],
.nav-secondary a[aria-current="page"] {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-soft);
}

.nav-more ul .nav-icon,
.nav-secondary .nav-icon {
  width: 20px;
  height: 20px;
  color: var(--muted);
}

.nav-brand {
  display: none;
}

/* Banners ------------------------------------------------------------------------------------------------ */
.banners {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--space-3);
}

.banners:empty {
  display: none;
}

.banners .alert {
  margin-top: var(--space-2);
}

/* Page --------------------------------------------------------------------------------------------------- */
.page {
  padding: var(--space-4) var(--space-3) var(--space-6);
  max-width: var(--content-max);
  margin: 0 auto;
  min-width: 0;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--gap);
  margin-bottom: var(--space-4);
}

.page-header > div:first-child {
  min-width: 0;
}

.page-lead {
  color: var(--muted);
  margin: var(--space-1) 0 0;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page-actions:empty {
  display: none;
}

.stack > * + * {
  margin-top: var(--gap);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.row-between {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px var(--gap);
}

.grid-2,
.grid-3 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  min-width: 0;
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: var(--gap);
}

.grid-2 > .card + .card,
.grid-3 > .card + .card {
  margin-top: 0;
}

.card-title {
  font-weight: 700;
  font-size: var(--fs-3);
  margin: 0 0 var(--space-2);
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px var(--gap);
  margin-bottom: var(--space-3);
}

.card-header .card-title {
  margin: 0;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--space-3);
}

.section {
  margin-top: var(--space-5);
}

.section-title {
  font-size: var(--fs-3);
  margin: 0 0 var(--space-3);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: var(--fs-1);
}

.nowrap {
  white-space: nowrap;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.break {
  overflow-wrap: anywhere;
}

.tech-code {
  color: var(--muted);
  font-size: var(--fs-1);
  margin: 4px 0 0;
}

.plain-list {
  margin: 0;
  padding-left: 1.2rem;
}

/* Key-value list: label above value on phones, side by side from 700px */
.kv {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px var(--gap);
  margin: 0;
}

.kv dt {
  color: var(--muted);
  font-size: var(--fs-1);
}

.kv dd {
  margin: 0 0 var(--space-2);
  overflow-wrap: anywhere;
}

.code-box {
  display: block;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  font-family: var(--mono);
  font-size: var(--fs-1);
  overflow-wrap: anywhere;
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.copy-row .code-box {
  flex: 1 1 16rem;
  min-width: 0;
}

/* Alerts ------------------------------------------------------------------------------------------------- */
.alert {
  border-radius: var(--radius);
  padding: 10px 14px;
  border: 1px solid transparent;
  overflow-wrap: anywhere;
}

.alert + .alert {
  margin-top: var(--space-2);
}

.alert p {
  margin: 0;
}

.alert p + p {
  margin-top: 4px;
}

.alert-detail {
  font-size: var(--fs-1);
  margin-top: 4px !important;
}

.alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--space-2);
}

.alert-info {
  background: var(--info-bg);
  color: var(--info-fg);
  border-color: var(--info-line);
}

.alert-ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
  border-color: var(--ok-line);
}

.alert-warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-color: var(--warn-line);
}

.alert-critical {
  background: var(--crit-bg);
  color: var(--crit-fg);
  border-color: var(--crit-line);
}

.page > .alert,
.page > .toast-region + .alert {
  margin-bottom: var(--space-3);
}

/* Toast: one bottom message for every result ("?durum=" redirects and smo.toast()); it hides itself after 8 s
   (paused on hover and focus), also without JavaScript ---------------------------------------------------- */
.toast-region {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 16px;
  border-radius: var(--radius-panel);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
  pointer-events: auto;
  animation:
    toast-in var(--dur) var(--ease) both,
    toast-out var(--dur) ease 8s forwards;
}

.toast:hover,
.toast:focus-within {
  animation-play-state: running, paused;
}

.toast p {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 2px;
}

.toast-ok {
  border-left: 4px solid var(--ok-fg);
}

.toast-info {
  border-left: 4px solid var(--info-fg);
}

.toast-warn {
  border-left: 4px solid var(--amber);
}

.toast-critical {
  border-left: 4px solid var(--danger);
}

.toast-close {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: -4px -4px -4px 0;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.toast-close:hover {
  background: var(--surface-2);
  color: var(--text); /* --muted on --surface-2 is only 4.23:1 */
}

.toast[hidden] {
  display: none;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* Forms -------------------------------------------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: var(--gap);
  min-width: 0;
}

.field label {
  font-weight: 600;
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 8px 12px;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
}

.field input:not([type="checkbox"]):not([type="radio"]):focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--focus);
  outline: none;
}

.field textarea {
  resize: vertical;
}

.field textarea.mono,
.field input.mono {
  font-family: var(--mono);
  font-size: var(--fs-1);
}

.field input[readonly],
.field textarea[readonly] {
  background: var(--surface-2);
  color: var(--text); /* --muted on --surface-2 is only 4.23:1 in the dark theme */
}

.field-invalid input,
.field-invalid select,
.field-invalid textarea {
  border-color: var(--danger);
}

.field-error {
  color: var(--danger);
  margin: 0;
  font-size: var(--fs-1);
}

.field-help {
  color: var(--muted);
  margin: 0;
  font-size: var(--fs-1);
}

/* Works for both markups: <div class="field field-check"><input><label> and <label class="field-check"><input><span>.
   The box stays at the left, level with the first line of the text; a long unbroken text (@handle) wraps inside. */
.field-check {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px 10px;
  min-width: 0;
  min-height: var(--touch);
  padding-block: 10px;
  box-sizing: border-box;
}

.field-check input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--primary);
}

.field-check label,
.field-check-text {
  flex: 1 1 0;
  min-width: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.field-check .field-help {
  flex-basis: 100%;
  padding-left: 32px;
}

.req {
  color: var(--danger);
}

.inline-form {
  display: inline;
  margin: 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Multi-column forms: columns align at the top so an error message never shifts the neighbours */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 0 var(--gap);
  align-items: start;
  align-content: start;
}

.form-grid > .span-all {
  grid-column: 1 / -1;
}

.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin: 0 0 var(--gap);
  min-width: 0;
}

.fieldset legend {
  font-weight: 600;
  padding: 0 6px;
}

/* Groups controls (for example to disable them together) without a frame */
.fieldset-plain {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

/* A card or section jumped to by #anchor stays clear of the sticky header */
.card[id],
.section[id] {
  scroll-margin-top: calc(var(--topbar) + var(--space-3));
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: 0 var(--gap);
  align-items: start;
}

.check-grid > * {
  min-width: 0;
}

.check-grid .field {
  margin-bottom: 0;
}

/* Buttons ------------------------------------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--radius-small);
  border: 1px solid transparent;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  max-width: 100%;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: var(--primary-text);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-fill);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-hover);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
}

.btn-ghost:hover {
  background: var(--primary-soft);
}

.btn-small {
  min-height: 36px;
  padding: 0 12px;
  font-size: var(--fs-1);
}

.btn-block {
  width: 100%;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.link-button {
  display: flex;
  align-items: center;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--primary);
  cursor: pointer;
  text-align: left;
}

/* Badges: colour plus text ---------------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-1);
  font-weight: 600;
  line-height: 1.5;
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  white-space: nowrap;
  vertical-align: middle;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* On phones a long badge (e.g. a workspace name) wraps inside its card instead of widening the page */
@media (max-width: 699px) {
  .badge {
    white-space: normal;
  }
}

.badge-neutral {
  background: var(--neutral-bg);
  color: var(--neutral-fg);
}

.badge-accent {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-info,
.state-approved,
.state-sending,
.status-ready {
  background: var(--info-bg);
  color: var(--info-fg);
}

.badge-ok,
.state-published,
.state-simulated {
  background: var(--ok-bg);
  color: var(--ok-fg);
}

.badge-warn,
.state-suggested,
.state-retry_wait,
.state-needs_check,
.status-incomplete,
.status-inconsistent {
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.badge-crit,
.state-failed,
.state-missed,
.status-invalid,
.status-unsupported,
.status-unauthorized_producer,
.status-conflict,
.status-legal_hold {
  background: var(--crit-bg);
  color: var(--crit-fg);
}

/* Tables: scroll inside the wrapper, never the page ----------------------------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table th {
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--text); /* --muted on --surface-2 is only 4.23:1 in the dark theme */
  background: var(--surface-2);
  white-space: nowrap;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table .actions-cell {
  text-align: right;
  white-space: nowrap;
}

/* Rows become cards on phones (every td carries data-label) */
@media (max-width: 699px) {
  .table-cards {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .table-cards .table,
  .table-cards tbody {
    display: block;
    background: transparent;
  }

  .table-cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .table-cards tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 14px;
    margin-bottom: var(--space-2);
    box-shadow: var(--shadow);
  }

  .table-cards td {
    display: grid;
    grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    text-align: left;
    overflow-wrap: anywhere;
  }

  .table-cards td:last-child {
    border-bottom: 0;
  }

  .table-cards td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: var(--fs-1);
    font-weight: 600;
  }

  .table-cards td[data-label=""]::before {
    content: none;
  }

  .table-cards td[data-label=""] {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-cards .num,
  .table-cards .actions-cell {
    text-align: left;
    white-space: normal;
  }
}

/* Dialog (confirmations; the same form also exists as a page without JavaScript) ------------------------ */
.dialog {
  width: min(32rem, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  color: var(--text);
  background: var(--surface);
}

.dialog::backdrop {
  background: var(--scrim);
}

.dialog-body {
  padding: var(--space-4);
}

.dialog-body h2 {
  margin: 0 0 var(--space-2);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* Empty state, chips, pagination -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: var(--space-5) var(--space-3);
  color: var(--muted);
}

.empty-icon {
  width: 40px;
  height: 40px;
  color: var(--border-strong);
  margin: 0 auto var(--space-2);
  display: block;
}

.empty-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.chip-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  margin: 0 0 var(--space-3);
  list-style: none;
  scrollbar-width: thin;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-1);
  text-decoration: none;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* Selected: a filled blush pill (also the settings tab strip). */
.chip[aria-current="true"] {
  border-color: var(--accent);
  color: var(--primary-text);
  background: var(--accent);
  font-weight: 600;
}

.chip-count {
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.chip[aria-current="true"] .chip-count {
  background: var(--primary-text);
  color: var(--accent);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}

.pagination a,
.pagination span {
  display: inline-grid;
  place-items: center;
  min-width: var(--touch);
  min-height: var(--touch);
  padding: 0 10px;
  border-radius: var(--radius-small);
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
}

.pagination [aria-current="page"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
  font-weight: 600;
}

.pagination .gap {
  border: 0;
  background: none;
  min-width: auto;
}

/* Sign-in page ------------------------------------------------------------------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-4) var(--space-3);
}

.auth-card {
  width: min(26rem, 100%);
  text-align: center;
}

/* An error box above the sign-in button keeps its distance from it (B-KP-02). */
.auth-card .alert {
  margin-bottom: var(--space-3);
}

.auth-card .brand {
  justify-content: center;
  margin-bottom: var(--space-3);
}

.auth-title {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-5);
  line-height: 1.2;
}

/* One calm sentence about the product; the sign-in button follows with room around it. */
.auth-lead {
  margin: 0 auto var(--space-4);
  max-width: 34ch;
  color: var(--muted);
}

.auth-action {
  margin: 0 0 var(--space-3);
}

.auth-note {
  margin: 0;
}

.auth-legal {
  margin: var(--space-3) 0 0;
}

/* Legal pages (Gizlilik, Kullanım koşulları): readable line length, plain headings. */
.legal {
  max-width: 46rem;
}

.legal h2 {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--fs-4);
}

.legal h2:first-of-type {
  margin-top: var(--space-3);
}

.legal ul {
  padding-left: 1.2rem;
}

.legal li + li {
  margin-top: var(--space-2);
}

.legal a {
  overflow-wrap: anywhere;
}

.legal-meta {
  margin: 0;
}

.legal-links {
  margin-top: var(--space-5);
}

/* Error and re-authentication pages: one card, a plain title, the message, then what to do ---------------- */
.error-card {
  max-width: 40rem;
  margin: var(--space-5) auto 0;
}

.error-title {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-5);
  line-height: 1.25;
}

.error-message {
  margin: 0 0 var(--space-3);
  max-width: 65ch;
}

.error-message.is-severe {
  color: var(--error);
}

.error-problems {
  margin-bottom: var(--space-3);
}

.error-tech {
  margin-top: var(--space-4);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.error-tech .tech-code:first-child {
  margin-top: 0;
}

/* Account page -------------------------------------------------------------------------------------------- */
.me-grid {
  align-items: stretch;
}

.me-grid .card {
  height: 100%;
}

.me-sessions {
  max-width: 40rem;
}

.me-sessions .form-actions {
  margin-top: var(--space-3);
}

/* Settings: a human title first, the technical key as small secondary text ---------------------------------- */
.setting-name {
  min-width: 0;
}

.setting-key {
  margin: 2px 0 0;
}

.setting-desc {
  margin: 0 0 var(--space-3);
  max-width: 75ch;
  color: var(--muted);
}

.settings-list > .setting-card + .setting-card {
  margin-top: var(--gap);
}

.settings-reauth {
  margin-bottom: var(--space-3);
}

.settings-group + .settings-group {
  margin-top: var(--space-5);
}

.moved-card {
  max-width: 44rem;
}

.moved-title {
  font-size: var(--fs-4);
}

.btn-google {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-google:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Hints: the "?" button and its popover (ipucu / ipucu_metin) ---------------------------------------------- */
.badge-hint {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  vertical-align: middle;
}

.ipucu {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-inline-start: 4px;
  font-family: var(--font);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
}

.ipucu-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-1);
  font-weight: 700;
  line-height: 1;
  cursor: help;
}

/* The visible circle stays small, the tap target is 44px */
.ipucu-btn::after {
  content: "";
  position: absolute;
  inset: -12px;
}

.ipucu-btn:hover,
.ipucu-btn[aria-expanded="true"] {
  border-color: var(--primary);
  color: var(--primary);
}

/* Fixed, so a table wrapper that scrolls never clips it; app.js sets left/top on open */
.ipucu-pop {
  display: none;
  position: fixed;
  z-index: 70;
  width: min(18rem, calc(100vw - 16px));
  padding: 12px 14px;
  background: #f4d6cc;
  color: #32373b;
  border: 1px solid #f4d6cc;
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-panel);
  font-size: var(--fs-1);
  line-height: var(--lh-body);
  text-align: left;
  overflow-wrap: anywhere;
}

.ipucu-title {
  display: block;
  margin-bottom: 2px;
  font-size: var(--fs-2);
  font-weight: 700;
}

.ipucu[data-open] .ipucu-pop,
html:not(.js) .ipucu:hover .ipucu-pop,
html:not(.js) .ipucu:focus-within .ipucu-pop {
  display: block;
}

/* Motion base -------------------------------------------------------------------------------------------- */
/* Page-load stagger: add .stagger to a list; its children appear one after the other (first 12, then together) */
.stagger > * {
  animation: rise var(--dur-slow) var(--ease) both;
}

.stagger > :nth-child(2) {
  animation-delay: calc(1 * var(--stagger));
}

.stagger > :nth-child(3) {
  animation-delay: calc(2 * var(--stagger));
}

.stagger > :nth-child(4) {
  animation-delay: calc(3 * var(--stagger));
}

.stagger > :nth-child(5) {
  animation-delay: calc(4 * var(--stagger));
}

.stagger > :nth-child(6) {
  animation-delay: calc(5 * var(--stagger));
}

.stagger > :nth-child(7) {
  animation-delay: calc(6 * var(--stagger));
}

.stagger > :nth-child(8) {
  animation-delay: calc(7 * var(--stagger));
}

.stagger > :nth-child(9) {
  animation-delay: calc(8 * var(--stagger));
}

.stagger > :nth-child(10) {
  animation-delay: calc(9 * var(--stagger));
}

.stagger > :nth-child(11) {
  animation-delay: calc(10 * var(--stagger));
}

.stagger > :nth-child(n + 12) {
  animation-delay: calc(11 * var(--stagger));
}

.rise {
  animation: rise var(--dur-slow) var(--ease) both;
}

/* A side panel slides in from the right; on phones (a full-screen sheet) it comes up from the bottom */
.panel-slide {
  animation: panel-in-up var(--dur-slow) var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes panel-in-right {
  from {
    opacity: 0;
    transform: translateX(24px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes panel-in-up {
  from {
    opacity: 0;
    transform: translateY(32px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* From 700px: key-value side by side --------------------------------------------------------------------- */
@media (min-width: 700px) {
  .kv {
    grid-template-columns: minmax(9rem, max-content) minmax(0, 1fr);
  }

  .kv dd {
    margin-bottom: var(--space-1);
  }

  .toast-region {
    left: auto;
    right: var(--space-4);
    width: min(26rem, calc(100vw - 32px));
  }
}

/* From 768px: left menu, icons only (the labels stay as accessible names; links carry a title) ----------- */
@media (min-width: 768px) {
  :root {
    --topbar: var(--header-height);
  }

  body.has-nav {
    display: grid;
    grid-template-columns: var(--nav-width) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "nav header"
      "nav banners"
      "nav main";
  }

  body.has-nav .site-header {
    grid-area: header;
  }

  body.has-nav .banners {
    grid-area: banners;
    width: 100%;
  }

  body.has-nav .page {
    grid-area: main;
    width: 100%;
  }

  .site-nav {
    grid-area: nav;
    top: 0;
    height: 100vh;
    border-bottom: 0;
    border-right: 1px solid var(--line);
    padding: 8px 0 16px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .site-nav .nav-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--header-height);
    padding: 0;
    margin-bottom: 4px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
  }

  .nav-main {
    flex-direction: column;
    gap: 2px;
    padding: 0 8px;
  }

  .nav-main a,
  .nav-main summary,
  .nav-secondary a,
  .nav-secondary .link-button {
    flex-direction: row;
    justify-content: center;
    gap: 12px;
    min-height: var(--touch);
    padding: 0;
    font-size: var(--fs-2);
    font-weight: 500;
    color: var(--text);
    border-bottom: 0;
    border-radius: var(--radius-control);
  }

  .nav-main a:hover,
  .nav-secondary a:hover,
  .nav-secondary .link-button:hover {
    background: var(--surface-2);
  }

  .nav-main a:hover .nav-icon,
  .nav-secondary a:hover .nav-icon,
  .nav-secondary .link-button:hover .nav-icon {
    color: var(--text); /* --muted on --surface-2 is only 4.23:1 */
  }

  .nav-main a[aria-current="page"],
  .nav-secondary a[aria-current="page"] {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
    border-bottom: 0;
  }

  .nav-main .nav-icon,
  .nav-secondary .nav-icon {
    width: 20px;
    height: 20px;
    color: var(--muted);
  }

  .nav-main a[aria-current="page"] .nav-icon,
  .nav-secondary a[aria-current="page"] .nav-icon {
    color: var(--primary);
  }

  .nav-more {
    display: none;
  }

  .nav-secondary {
    display: block;
    margin: 8px 8px 0;
    padding: 8px 0 0;
    list-style: none;
    border-top: 1px solid var(--line);
  }

  /* Icon only: the text stays in the page for screen readers */
  .site-nav .nav-label,
  .site-nav .nav-secondary .link-button > span,
  .site-nav .nav-brand > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .site-header .brand {
    visibility: hidden;
  }

  .panel-slide {
    animation-name: panel-in-right;
  }
}

/* From 1024px: menu with labels, two columns ------------------------------------------------------------- */
@media (min-width: 1024px) {
  :root {
    --nav-width: 248px;
  }

  .site-nav .nav-brand {
    justify-content: flex-start;
    padding: 0 20px;
  }

  .nav-main a,
  .nav-main summary,
  .nav-secondary a,
  .nav-secondary .link-button {
    justify-content: flex-start;
    padding: 0 12px;
  }

  .site-nav .nav-label,
  .site-nav .nav-secondary .link-button > span,
  .site-nav .nav-brand > span:last-child {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }

  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .page {
    padding: var(--space-5) var(--space-5) var(--space-6);
  }

  .banners {
    padding: 0 var(--space-5);
  }
}

/* Reduced motion: no entrance animation, no transitions; a toast still leaves after 8 s without fading */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .stagger > *,
  .rise,
  .panel-slide {
    animation: none;
  }

  .toast {
    animation: toast-out 0.01ms linear 8s forwards;
  }
}

@media print {
  .site-nav,
  .site-header,
  .toast-region,
  .page-actions,
  .ipucu {
    display: none !important;
  }

  body.has-nav {
    display: block;
    padding: 0;
  }
}
