/* AeroSync styles: the app's own look (dark navy shell, slate neutrals, a chosen accent,
   rounded shapes), made consistent — one set of tokens, one button system, one form,
   table and badge style (decision D13, 2026-10-18 design review). Pages use these
   tokens and components; page <style> blocks keep only page layout. */

/* ───────────── Tokens ───────────── */
:root {
    color-scheme: light;
    /* Neutrals (slate) */
    --c-bg: #f8fafc;
    --c-surface: #ffffff;
    --c-surface-2: #f1f5f9;
    --c-surface-3: #e2e8f0;
    --c-border: #e2e8f0;
    --c-border-strong: #cbd5e1;     /* form controls */
    --c-text: #0f172a;
    --c-text-muted: #64748b;        /* 4.8:1 on white — never fade text below this */
    /* Accent: set by the colour scheme (Settings > Appearance), indigo by default */
    --c-accent: #5b5ef0;
    --c-accent-hover: #4f46e5;
    --c-on-accent: #ffffff;
    --c-accent-soft: #eef2ff;
    /* Status */
    --c-danger: #dc2626;  --c-danger-hover: #b91c1c; --c-danger-text: #b91c1c; --c-danger-bg: #fef2f2; --c-danger-border: #fecaca;
    --c-warning: #f59e0b; --c-warning-text: #92400e; --c-warning-bg: #fffbeb; --c-warning-border: #fde68a;
    --c-success: #059669; --c-success-text: #047857; --c-success-bg: #ecfdf5; --c-success-fill: #047857;
    --c-info: #3b82f6;    --c-info-text: #1d4ed8;    --c-info-bg: #eff6ff;
    /* Shell: dark navy top bar and side menu */
    --c-shell: #0f172a;
    --c-shell-text: #e2e8f0;
    --c-shell-hover: #1e293b;
    --c-shell-border: #1e293b;

    /* Type */
    --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --fs-md: 1rem;
    --fs-lg: 1.1rem;
    --fs-xl: 1.25rem;
    /* Space */
    --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem;
    /* Shape */
    --radius-sm: 6px;    /* controls */
    --radius: 8px;       /* cards, tables, panels */
    --radius-lg: 12px;   /* tiles */
    --shadow-hover: 0 8px 16px rgba(15, 23, 42, 0.12);
    --shadow-overlay: 0 4px 14px rgba(15, 23, 42, 0.12);
    /* Layers */
    --z-sidebar: 40; --z-topbar: 50; --z-drawer: 200; --z-toast: 300; --z-modal: 400; --z-picker: 500;
    /* Controls */
    --control-height: 2.25rem;
    --control-font-size: 0.92rem;   /* buttons */
    --input-font-size: 1rem;        /* text in inputs */
    --control-pad-x: 0.85rem;
    --topbar-h: 56px;
}

/* Variables that point at other variables resolve where they're declared, so these live on
   <body>, which carries the theme-dark and scheme-* classes. */
body {
    --c-link: var(--c-link-light, var(--c-accent));
    /* Legacy names used by page templates — keep them pointing at the tokens. */
    --bg: var(--c-bg);
    --text: var(--c-text);
    --text-muted: var(--c-text-muted);
    --muted: var(--c-text-muted);
    --panel: var(--c-surface);
    --panel-border: var(--c-border);
    --accent: var(--c-accent);
    --accent-dark: var(--c-accent-hover);
    --accent-light: var(--c-accent-soft);
    --sidebar-bg: var(--c-shell);
    --sidebar-text: var(--c-shell-text);
    --sidebar-hover: var(--c-shell-hover);
    --topbar-bg: var(--c-shell);
    --topbar-border: var(--c-shell-border);
}

.theme-dark {
    color-scheme: dark;
    --c-bg: #0b1220;
    --c-surface: #0f172a;
    --c-surface-2: #111827;
    --c-surface-3: #1f2937;
    --c-border: #1f2937;
    --c-border-strong: #334155;
    --c-text: #e5e7eb;
    --c-text-muted: #94a3b8;
    --c-link: var(--c-link-dark, #a5b4fc);
    --c-danger-text: #fca5a5; --c-danger-bg: #2a0e0e; --c-danger-border: #7f1d1d;
    --c-warning-text: #fcd34d; --c-warning-bg: #2a1d05; --c-warning-border: #78350f;
    --c-success-text: #6ee7b7; --c-success-bg: #052e22;
    --c-info-text: #93c5fd;    --c-info-bg: #0b1d3a;
    --c-shell: #0b1220;
    --c-shell-hover: #111827;
    --c-shell-border: #111827;
    --shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.4);
    --shadow-overlay: 0 4px 14px rgba(0, 0, 0, 0.45);
}

/* Colour schemes. Same hues as before; where white text on the colour was hard to read, the
   shade is a touch deeper (indigo, blue, rose) or button text is dark (emerald, amber). Links
   use a shade that reads on the page background. */
.scheme-indigo  { --c-accent: #5b5ef0; --c-accent-hover: #4f46e5; --c-on-accent: #ffffff; --c-link-light: #5b5ef0; --c-link-dark: #a5b4fc; --c-accent-soft: #eef2ff; }
.scheme-slate   { --c-accent: #64748b; --c-accent-hover: #475569; --c-on-accent: #ffffff; --c-link-light: #475569; --c-link-dark: #cbd5e1; --c-accent-soft: #f1f5f9; }
.scheme-blue    { --c-accent: #2563eb; --c-accent-hover: #1d4ed8; --c-on-accent: #ffffff; --c-link-light: #2563eb; --c-link-dark: #93c5fd; --c-accent-soft: #eff6ff; }
.scheme-emerald { --c-accent: #10b981; --c-accent-hover: #059669; --c-on-accent: #0f172a; --c-link-light: #047857; --c-link-dark: #6ee7b7; --c-accent-soft: #ecfdf5; }
.scheme-rose    { --c-accent: #e11d48; --c-accent-hover: #be123c; --c-on-accent: #ffffff; --c-link-light: #be123c; --c-link-dark: #fda4af; --c-accent-soft: #fff1f2; }
.scheme-amber   { --c-accent: #f59e0b; --c-accent-hover: #d97706; --c-on-accent: #0f172a; --c-link-light: #b45309; --c-link-dark: #fcd34d; --c-accent-soft: #fffbeb; }
.theme-dark.scheme-indigo, .theme-dark.scheme-slate, .theme-dark.scheme-blue,
.theme-dark.scheme-emerald, .theme-dark.scheme-rose, .theme-dark.scheme-amber { --c-accent-soft: #1e293b; }

/* ───────────── Base ───────────── */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
@media (min-width: 1440px) { html { font-size: 17px; } }
@media (min-width: 1920px) { html { font-size: 18px; } }
@media (min-width: 2560px) { html { font-size: 19px; } }
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    background: var(--c-bg);
    color: var(--c-text);
    font-variant-numeric: tabular-nums;   /* hours and dates line up in every column */
    touch-action: manipulation;
}
a { color: var(--c-link); }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.theme-dark :focus-visible { outline-color: var(--c-link); }
[hidden] { display: none !important; }   /* else button's inline-flex below beats the attribute */
.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: var(--s-2); top: -100px; z-index: calc(var(--z-topbar) + 1); background: var(--c-surface); color: var(--c-text); padding: var(--s-2) var(--s-3); border-radius: var(--radius-sm); }
.skip-link:focus { top: var(--s-2); }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Text helpers */
.text-muted { color: var(--c-text-muted); }
.text-sm { font-size: var(--fs-sm); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.label-text { font-size: var(--fs-sm); color: var(--c-text-muted); font-weight: 600; }
.row { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ───────────── Shell: top bar, side menu, content ───────────── */
.topbar {
    position: sticky; top: 0; z-index: var(--z-topbar);
    height: var(--topbar-h);
    background: var(--c-shell); border-bottom: 1px solid var(--c-shell-border);
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
    padding: 0 var(--s-4);
}
.topbar-left { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.topbar-title { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; color: var(--c-shell-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-short { display: none; }
.hamburger { background: transparent; border: none; cursor: pointer; padding: 6px; border-radius: var(--radius-sm); min-height: 0; display: inline-flex; flex-direction: column; justify-content: center; gap: 3px; }
.hamburger:hover { background: var(--c-shell-hover); }
.hamburger .bar { display: block; width: 20px; height: 2px; background: var(--c-shell-text); }
.topbar-right { display: flex; align-items: center; gap: var(--s-2); color: var(--c-shell-text); font-size: 0.85rem; min-width: 0; }
.topbar-right .meta-text { white-space: nowrap; }
.logo-img { height: calc(var(--topbar-h) - 16px); max-height: 100%; width: auto; display: block; object-fit: contain; }
.topbar-auth-form { display: inline; margin: 0; }
.btn-like.topbar-auth-link, .topbar-auth-link {
    color: var(--c-shell-text); background: transparent; border: none; padding: 0; margin-left: var(--s-2);
    min-height: 0; font: inherit; font-size: inherit; font-weight: 400; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.topbar-auth-link:hover { color: #fff; text-decoration: underline; background: transparent; }
/* Language flags (D15): the current one framed, the other dimmed. Top bar; side menu on phones
   (two classes so they beat .sidebar-footer button). */
.lang-flags { display: inline-flex; align-items: center; gap: 2px; margin: 0; }
.topbar-lang { margin-left: var(--s-2); }
.lang-flags .lang-flag { background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); min-height: 0; padding: 3px; line-height: 0; opacity: 0.5; }
.lang-flags .lang-flag img { display: block; width: 21px; height: 14px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2); }
.lang-flags .lang-flag:hover { background: var(--c-shell-hover); opacity: 1; }
.lang-flags .lang-flag.is-current { opacity: 1; border-color: rgba(255, 255, 255, 0.5); }
.sidebar-lang { display: none; }

.layout { min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
    width: 224px; flex: none;
    background: var(--c-shell); color: var(--c-shell-text);
    padding: var(--s-3);
    position: fixed; top: var(--topbar-h); left: 0;
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto; overflow-x: hidden;
    display: flex; flex-direction: column;
    z-index: var(--z-sidebar);
    transition: width 0.2s ease, padding 0.2s ease;
}
body.is-dragging .sidebar, body.is-dragging .content, body.is-dragging .sidebar-resize-handle { transition: none !important; }
.sidebar-resize-handle {
    position: fixed; top: var(--topbar-h); width: 6px; height: calc(100vh - var(--topbar-h));
    cursor: col-resize; z-index: calc(var(--z-sidebar) + 5); background: var(--c-border); opacity: 0.15; transition: opacity 0.15s;
}
.sidebar-resize-handle:hover, .sidebar-resize-handle.dragging { opacity: 1; background: var(--c-accent); }
.brand { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; margin-bottom: var(--s-4); color: var(--c-shell-text); }
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar a {
    color: var(--c-shell-text); text-decoration: none; display: block;
    padding: var(--s-2) var(--s-3); border-radius: var(--radius-sm);
    font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar a:hover { background: var(--c-shell-hover); }
.sidebar a.active, .sidebar a[aria-current="page"] { background: var(--c-shell-hover); font-weight: 800; color: #fff; }
.sidebar-footer {
    margin-top: auto; padding-top: var(--s-4); border-top: 1px solid var(--c-shell-hover);
    font-size: 0.85rem; color: var(--c-shell-text); opacity: 0.8; line-height: 1.38;
}
.sidebar-footer .footer-item { margin: 0.3rem 0; overflow-wrap: anywhere; }
.sidebar-footer a, .sidebar-footer .footer-legal a { color: inherit; padding: 0; display: inline; font-weight: 400; font-size: inherit; text-decoration: none; }
.sidebar-footer a:hover { background: transparent; text-decoration: underline; }
.sidebar-footer button { background: none; border: none; color: inherit; cursor: pointer; padding: 0; min-height: 0; font: inherit; }
.sidebar-footer button:hover { background: none; text-decoration: underline; }

.content {
    padding: 1.25rem 1.5rem 2.5rem;
    margin-left: 224px; width: calc(100% - 224px); min-width: 0;
    transition: margin-left 0.2s ease, width 0.2s ease;
}
.header { font-size: var(--fs-xl); font-weight: 600; line-height: 1.3; margin: 0 0 var(--s-4); color: var(--c-text); }
.header:empty { display: none; }
.header.center { text-align: center; }
.public-footer { margin-top: var(--s-5); text-align: center; font-size: 0.85rem; color: var(--c-text-muted); }
.public-footer a { color: inherit; }
body.sidebar-hidden .sidebar { display: none; }
body.sidebar-hidden .content { margin-left: 0 !important; width: 100% !important; }
body.sidebar-hidden .sidebar-resize-handle { left: 0 !important; }
.layout-no-sidebar .content { margin-left: 0; width: 100%; }

/* ───────────── Surfaces ───────────── */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--s-4); overflow-x: auto; }
.card.is-plain { background: transparent; border: 0; padding: 0; overflow: visible; }
.band { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--s-4); }
.section-title { font-size: var(--fs-lg); font-weight: 700; margin: var(--s-5) 0 var(--s-3); padding-bottom: var(--s-2); border-bottom: 2px solid var(--c-border); }
.section-title:first-child { margin-top: 0; }
.empty-msg { color: var(--c-text-muted); font-style: italic; padding: var(--s-4) 0; margin: 0; }
.static-value { margin: 0; padding: var(--s-1) 0; font-size: var(--input-font-size); }   /* a fixed value: plain text, not a disabled box */

/* Sign-in and account pages (registration/_auth_page.html). The column has a fixed width, so a
   long error message wraps inside it instead of widening the form. */
.auth-card { max-width: 30rem; margin: 6vh auto var(--s-5); padding: var(--s-6) var(--s-5); box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12); overflow: visible; }
.auth { width: 100%; max-width: 22rem; margin: 0 auto; }
.auth-title { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; text-align: center; margin: 0 0 var(--s-5); color: var(--c-text); text-wrap: balance; }
.auth p { margin: 0 0 var(--s-3); line-height: 1.5; }
.auth-center { text-align: center; }
.auth .auth-note { font-size: 0.9rem; color: var(--c-text-muted); }
.auth .field { margin-bottom: var(--s-3); }
.auth .field > label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.auth input[type="text"], .auth input[type="email"], .auth input[type="password"] { width: 100%; }
.auth .form-error { margin: 0 0 var(--s-4); padding: var(--s-2) var(--s-3); border: 1px solid var(--c-danger-border); border-radius: var(--radius-sm); background: var(--c-danger-bg); color: var(--c-danger-text); font-size: 0.875rem; line-height: 1.4; }
.auth .errorlist { list-style: none; padding: 0; margin: var(--s-1) 0 0; color: var(--c-danger-text); font-size: 0.875rem; }
.auth .helptext { font-size: 0.85rem; color: var(--c-text-muted); margin: var(--s-1) 0 0; }
.auth .helptext ul { margin: var(--s-1) 0 0; padding-left: 1.1rem; }
.auth-actions { display: grid; gap: var(--s-2); margin: var(--s-4) 0 0; }
.auth-actions .button { width: 100%; }
.auth-actions + .auth-note { margin-top: var(--s-3); }
.auth .code-input { text-align: center; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }   /* the 6-digit sign-in code (D14) */
.auth .auth-links { margin: var(--s-5) 0 0; text-align: center; font-size: 0.9rem; }

/* Messages */
.flash-messages { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }
.flash { padding: var(--s-3) var(--s-4); border-radius: var(--radius); border: 1px solid var(--c-border); border-left-width: 4px; background: var(--c-surface); margin-bottom: var(--s-3); }
.flash-messages .flash { margin-bottom: 0; }
.flash p { margin: 0; }
.flash-success { border-left-color: #10b981; }
.flash-info { border-left-color: var(--c-info); }
.flash-warning { border-left-color: var(--c-warning); background: var(--c-warning-bg); color: var(--c-warning-text); }
.flash-error { border-left-color: #ef4444; background: var(--c-danger-bg); color: var(--c-danger-text); }

/* Badges / pills */
.badge { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.7rem; font-weight: 700; line-height: 1.6; white-space: nowrap; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-due-soon { background: #fef3c7; color: #92400e; }
.badge-ok { background: rgba(34, 197, 94, 0.12); color: #15803d; }
.badge-neutral { background: var(--c-surface-2); color: var(--c-text-muted); border: 1px solid var(--c-border); }
.badge-info { background: var(--c-accent-soft); color: var(--c-link); }
.theme-dark .badge-overdue { background: var(--c-danger-bg); color: var(--c-danger-text); }
.theme-dark .badge-due-soon { background: var(--c-warning-bg); color: var(--c-warning-text); }
.theme-dark .badge-ok { color: var(--c-success-text); }

/* ───────────── Buttons: one system ─────────────
   .button (secondary) + is-primary | is-success | is-ghost | is-danger | is-danger-ghost | is-small.
   A bare <button> is primary. .is-small, .main-action-btn and .tile-action-btn are the one
   small action style (light box, accent text, fills on hover). */
button, .button, .btn-like {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    min-height: var(--control-height); padding: 0 var(--control-pad-x);
    border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-size: var(--control-font-size); font-weight: 600; line-height: 1.2;
    text-decoration: none; white-space: nowrap; cursor: pointer;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, filter 0.15s ease;
}
button { background: var(--c-accent); color: var(--c-on-accent); }
button:hover { background: var(--c-accent-hover); }
.button, .btn-like { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-strong); }
.button:hover, .btn-like:hover { background: var(--c-surface-2); color: var(--c-text); }
.button.is-primary, .button.is-info { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); }
.button.is-primary:hover, .button.is-info:hover { background: var(--c-accent-hover); border-color: var(--c-accent-hover); color: var(--c-on-accent); }
.button.is-success { background: var(--c-success-fill); border-color: var(--c-success-fill); color: #fff; }
.button.is-success:hover { filter: brightness(0.92); }
.button.is-light { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-strong); }
.button.is-ghost { background: transparent; border-color: transparent; color: var(--c-link); }
.button.is-ghost:hover, .button.is-light:hover { background: var(--c-surface-2); }
.button.is-warning { background: var(--c-warning); border-color: var(--c-warning); color: #111827; }
.button.is-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.button.is-danger:hover { background: var(--c-danger-hover); border-color: var(--c-danger-hover); color: #fff; }
.button.is-danger.is-light, .button.is-danger-ghost { background: var(--c-surface); color: var(--c-danger-text); border-color: var(--c-danger-border); }
.button.is-danger.is-light:hover, .button.is-danger-ghost:hover { background: var(--c-danger-bg); color: var(--c-danger-text); }
.button.is-full { width: 100%; }
button:disabled, .button:disabled, .button[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.button-group { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }

.button.is-small, button.is-small, .main-action-btn, .tile-action-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.2rem;
    min-height: 1.85rem; padding: 0.3rem 0.6rem; border-radius: 4px;
    font-size: 0.8rem; font-weight: 600; line-height: 1; text-decoration: none; cursor: pointer;
    background: var(--c-bg); color: var(--c-link); border: 1px solid var(--c-border);
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.button.is-small:hover, button.is-small:hover, .main-action-btn:hover, .tile-action-btn:hover { background: var(--c-accent); color: var(--c-on-accent); border-color: var(--c-accent); }
.button.is-small.is-danger-ghost, .main-action-btn.danger, .tile-action-btn.danger { color: var(--c-danger-text); border-color: #ef4444; background: var(--c-bg); }
.button.is-small.is-danger-ghost:hover, .main-action-btn.danger:hover, .tile-action-btn.danger:hover { background: #ef4444; color: #fff; border-color: #ef4444; }
.button.is-small.is-primary { background: var(--c-accent); color: var(--c-on-accent); border-color: var(--c-accent); }

/* Segmented choice (radio buttons that look like buttons) */
.segmented { display: inline-flex; border: 1px solid var(--c-border-strong); border-radius: var(--radius-sm); overflow: hidden; margin: 0; padding: 0; background: var(--c-surface); }
.segmented legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.segmented label { display: inline-flex; align-items: center; min-height: var(--control-height); padding: 0 var(--control-pad-x); font-size: var(--control-font-size); font-weight: 600; cursor: pointer; color: var(--c-text); }
.segmented label + label { border-left: 1px solid var(--c-border-strong); }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label:has(input:checked) { background: var(--c-accent); color: var(--c-on-accent); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--c-accent); outline-offset: -3px; }
.segmented label:hover:not(:has(input:checked)) { background: var(--c-surface-2); }

/* ───────────── Forms ───────────── */
.label, .form-label { font-weight: 600; }
input[type="text"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="email"],
input[type="password"], input[type="search"], input[type="url"], input[type="tel"], textarea, select {
    min-height: var(--control-height);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--c-border-strong);
    background: var(--c-surface);
    color: var(--c-text);
    font: inherit; font-size: var(--input-font-size); line-height: 1.3;
    max-width: 100%;
}
select { padding-top: 0; padding-bottom: 0; }
textarea { min-height: 80px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 0; border-color: var(--c-accent); }
input::placeholder, textarea::placeholder { color: var(--c-text-muted); opacity: 0.85; }
input[readonly], select[readonly], textarea[readonly], .hours-readonly { background-color: var(--c-bg) !important; cursor: not-allowed !important; opacity: 0.85; border-color: var(--c-border) !important; }
input.fp-date-input[readonly], input.fp-date-input-past[readonly] { cursor: pointer !important; background-color: var(--c-surface) !important; opacity: 1; border-color: var(--c-border-strong) !important; }
input:disabled, textarea:disabled, select:disabled { background-color: var(--c-bg); opacity: 0.85; cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--c-accent); cursor: pointer; flex: none; }
.theme-dark input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); }
@media (prefers-color-scheme: dark) { .theme-system input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); } }

/* A checkbox (or radio) always comes before its question, on the same line. */
.log-type-options { display: flex; gap: 0.5rem 1.25rem; min-height: var(--control-height); align-items: center; flex-wrap: wrap; }
.log-type-options label { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 500; cursor: pointer; margin: 0; }
.check-row { display: flex; align-items: center; gap: var(--s-2); font-weight: 600; cursor: pointer; margin: 0; }
.check-row + .form-help { margin-top: var(--s-1); padding-left: calc(1.1rem + var(--s-2)); }

.form-shell { max-width: 760px; margin: 0 auto; }
.form-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 10px; padding: 1.1rem 1.1rem 1.25rem; }
.form-card .field, .field { margin-bottom: var(--s-4); }
.form-card .form-label, .form-card .field > label, .form-card .label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.form-card .form-control, .form-card .control { display: block; }
.form-card input[type="text"], .form-card input[type="number"], .form-card input[type="date"], .form-card input[type="email"],
.form-card input[type="password"], .form-card textarea, .form-card select { width: 100%; }
.form-card .form-group-box { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--s-4); margin-bottom: var(--s-4); }
.form-actions, .form-card .form-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; margin-top: var(--s-5); }
.form-actions .spacer { flex: 1; }
.form-card .option-list { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius-sm); }
.form-card .option-item { display: flex; align-items: center; gap: var(--s-2); cursor: pointer; }
.form-card .checkbox-input { width: 1.1rem; height: 1.1rem; cursor: pointer; }
.form-help, .form-card .form-help, .help { font-size: 0.85rem; color: var(--c-text-muted); margin: var(--s-1) 0 0; }
.field-error, .help.is-danger { color: var(--c-danger-text); font-size: 0.875rem; margin: var(--s-1) 0 0; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s-4); }
.fieldset { border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--s-4); margin: 0 0 var(--s-4); }
.fieldset > legend { font-weight: 600; padding: 0 var(--s-2); }

/* ───────────── Tables ───────────── */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th { text-align: left; font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--c-text-muted); background: var(--c-surface-2); padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--c-border); white-space: nowrap; }
.data-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td.num, .data-table th.num { text-align: right; }
.data-table .actions { text-align: right; white-space: nowrap; }
.data-table .actions > * + * { margin-left: var(--s-1); }

/* ───────────── Aircraft hero (detail / edit) ───────────── */
.hero-shell { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; margin-bottom: 1.5rem; }
.hero-image-wrap { position: relative; border: 1px solid var(--c-border); border-radius: 14px; overflow: hidden; background: linear-gradient(160deg, rgba(29, 78, 216, 0.08), rgba(220, 38, 38, 0.06) 55%, rgba(5, 150, 105, 0.08)); aspect-ratio: 16 / 9; box-shadow: 0 10px 32px rgba(15, 23, 42, 0.08); flex: 1 1 420px; min-width: 0; }
.hero-image { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--c-bg); }
.hero-image-placeholder { width: 100%; height: 100%; background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.16), transparent 28%), radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.12), transparent 24%), linear-gradient(145deg, rgba(17, 24, 39, 0.92), rgba(30, 41, 59, 0.94)); }
.hero-summary { border: 1px solid var(--c-border); border-radius: 14px; padding: 1.25rem; background: var(--c-surface); display: flex; flex-direction: column; gap: 1.2rem; box-shadow: 0 10px 32px rgba(15, 23, 42, 0.05); flex: 1 1 340px; min-width: 0; overflow: hidden; }
.hero-registration { font-size: clamp(1.6rem, 2vw, 2.2rem); font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; }
.hero-submeta { display: flex; flex-wrap: wrap; gap: 0.5rem; color: var(--c-text-muted); font-size: 0.9rem; }
.hero-pill { border: 1px solid var(--c-border); background: var(--c-bg); border-radius: 999px; padding: 0.32rem 0.7rem; white-space: nowrap; }
.summary-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; width: 100%; }
.summary-card { border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 0.85rem; background: var(--c-bg); min-height: 80px; display: flex; flex-direction: column; justify-content: center; gap: 0.25rem; overflow: hidden; }
.summary-card .k { font-size: 0.76rem; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.2rem; }
.summary-card .v { font-weight: 800; font-size: 1.05rem; }
.summary-card .sub { font-size: 0.8rem; color: var(--c-text-muted); margin-top: 0.2rem; }
.hero-details { border-top: 1px solid var(--c-border); padding-top: 0.2rem; }
.details-grid { display: grid; grid-template-columns: minmax(auto, 180px) 1fr; gap: 0.5rem 1rem; margin-bottom: 1rem; font-size: 0.95rem; }
.details-grid .label { font-weight: 600; color: var(--c-text-muted); }

/* ───────────── Date picker, flight data banner, save toast ───────────── */
.flatpickr-calendar { z-index: var(--z-picker) !important; overflow: visible !important; }
.flatpickr-current-month { padding: 0 !important; display: flex !important; align-items: center !important; justify-content: center !important; height: auto !important; line-height: 1 !important; }
.flatpickr-month { height: 44px !important; }
.flatpickr-current-month .flatpickr-monthDropdown-months { padding: 0 5px !important; height: auto !important; font-size: 1rem !important; }
.flatpickr-current-month input.cur-year { padding: 0 !important; margin: 0 !important; height: auto !important; vertical-align: middle !important; font-size: 1rem !important; font-weight: 700 !important; width: 6ch !important; }
.flatpickr-calendar.hasWeeks .flatpickr-days { border-left: none !important; }
.flatpickr-day.has-flight-dot { position: relative !important; }
.flight-dot-indicator, .flatpickr-day.has-flight-dot::before {
    content: '' !important; position: absolute !important; bottom: 4px !important; left: 50% !important;
    transform: translateX(-50%) !important; width: 6px !important; height: 6px !important;
    background-color: #fbbf24 !important; border-radius: 50% !important; z-index: 5 !important; display: block !important;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.6); pointer-events: none;
}
.flatpickr-day.selected .flight-dot-indicator, .flatpickr-day.today.selected .flight-dot-indicator, .flatpickr-day:hover .flight-dot-indicator,
.flatpickr-day.selected::before, .flatpickr-day.today.selected::before, .flatpickr-day:hover::before { background-color: #fff !important; }
.flight-load-banner {
    position: fixed; top: 4rem; right: var(--s-4); z-index: var(--z-toast);
    display: none; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-4);
    border-radius: var(--radius); font-size: 0.82rem; font-weight: 500; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); max-width: 380px;
}
.flight-load-banner.loading { display: flex; background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.3); color: #2563eb; }
.flight-load-banner.error { display: flex; background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--c-danger-text); }
.flight-load-banner.success { display: flex; background: rgba(16, 185, 129, 0.08); border: 1px solid rgba(16, 185, 129, 0.3); color: var(--c-success-text); }
.flight-load-spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: flight-spin 0.7s linear infinite; flex-shrink: 0; }
@keyframes flight-spin { to { transform: rotate(360deg); } }
.app-toast {
    position: fixed; bottom: 2rem; right: 2rem; z-index: var(--z-toast);
    background: #10b981; color: #fff; padding: 0.75rem 1.25rem; border-radius: var(--radius); font-weight: 600; font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); transform: translateY(120%); opacity: 0; pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.app-toast.is-error { background: #ef4444; }
.app-toast.is-shown { transform: translateY(0); opacity: 1; }
.demo-flag { margin-left: 0.75rem; color: #f59e0b; font-weight: 700; }

/* ───────────── Responsive ───────────── */
@media (max-width: 1024px) {
    .content { padding: var(--s-4) var(--s-5) var(--s-6); }
}
@media (max-width: 767px) {
    .sidebar { transform: translateX(-100%); width: 260px !important; transition: transform 0.25s ease, width 0s; z-index: var(--z-drawer); overscroll-behavior: contain; }
    body.mobile-sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop { display: none; position: fixed; inset: 0; top: var(--topbar-h); background: rgba(0, 0, 0, 0.45); z-index: calc(var(--z-drawer) - 1); cursor: pointer; }
    body.mobile-sidebar-open .sidebar-backdrop { display: block; }
    .sidebar-resize-handle { display: none !important; }
    .content { margin-left: 0 !important; width: 100% !important; padding: var(--s-4); }
    .title-long { display: none; }
    .title-short { display: inline; }
    .topbar-title { font-size: 0.95rem; }
    /* Phone top bar: name and the CloudBase credit only; account links are in the menu. */
    .topbar { padding: 0 var(--s-3); }
    .topbar-right .meta-text, .topbar-right .topbar-user, .topbar-right .topbar-logout { display: none; }
    body:not(.is-signed-out) .topbar-lang { display: none; }
    .sidebar-lang { display: block; }
    .is-signed-out .logo-img { display: none; }
    .logo-img { height: 24px; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .details-grid { grid-template-columns: 1fr; }
    .hero-summary, .hero-image-wrap { flex: 1 1 100%; }
    .data-table { min-width: 40rem; }   /* scroll sideways rather than squeeze columns */
    .flex-row-wrap { flex-wrap: wrap !important; gap: var(--s-2) !important; }
    input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], select, textarea { width: 100%; }
    .button-group { flex-wrap: wrap !important; }
}
@media (max-width: 400px) {
    .content { padding: var(--s-3); }
}

/* File inputs match the buttons */
input[type="file"] { font: inherit; font-size: 0.9rem; color: var(--c-text-muted); max-width: 100%; }
input[type="file"]::file-selector-button {
    font: inherit; font-size: var(--control-font-size); font-weight: 600; margin-right: 0.75rem; cursor: pointer;
    min-height: var(--control-height); padding: 0 var(--control-pad-x); border-radius: var(--radius-sm);
    background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border-strong);
}
input[type="file"]::file-selector-button:hover { background: var(--c-surface-2); }

/* Wide tables: the last (Actions) column stays in view while the rest scrolls sideways. */
.data-table.sticky-actions th:last-child,
.data-table.sticky-actions td:last-child { position: sticky; right: 0; z-index: 1; background: var(--c-surface); box-shadow: inset 1px 0 0 var(--c-border); }
.data-table.sticky-actions th:last-child { background: var(--c-surface-2); }
