/* ============================================================
   SOLTIS — global.css
   Brand: Soltis hardware & home retail
   Navy primary (#2A445A), mid-blue (#417F9E), light-blue/teal (#6FBECF)
   Typography: Open Sans (300/400/500/600/700/800)

   Migrated from Old Framework palette in one pass:
     • Tokens, fonts, gradients, shadows replaced wholesale.
     • Old Framework tokens kept as aliases (mapped to Soltis values) so
       any utility class or template still referencing them keeps
       rendering instead of falling back to the CSS browser-default.
     • Custom Old Framework .woff2 fonts dropped — Open Sans loads from the
       Google Fonts CDN at the top of this file.

   To revert: this file is committed; check the git history.
   ============================================================ */

/* ── Fonts (Open Sans + JetBrains Mono via Google Fonts — cached after first load) ── */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Design Tokens ───────────────────────────────────────────────────────── */
:root {
  /* Brand — Soltis Navy */
  --color-brand-primary: #2A445A;
  --color-brand-primary-hover: #233949;
  --color-brand-primary-active: #1B2C38;
  --color-brand-primary-subtle: rgba(42, 68, 90, 0.08);

  /* Secondary — Soltis blues & greys (from brand guide pg. 2) */
  --color-secondary-blue: #417F9E;
  /* mid-blue — links active, accents */
  --color-secondary-teal: #6FBECF;
  /* light-blue / teal — highlights */
  --color-secondary-grey: #555454;
  /* warm dark grey — body text */
  --color-secondary-grey-light: #E8E8E8;
  /* light grey — separators, bg */
  --color-secondary-black: #000000;

  /* Old Framework palette aliases — query.css still references these. Mapped
     to Soltis equivalents so the existing references render correctly:
       green  → success green  (already used for "ok"/"success" rendering)
       yellow → warning amber  (already used for "warning"/"in progress")
       pink   → was Old Framework accent, never used outside swatches — alias to teal
   */
  --color-secondary-green: #1F8A5B;
  --color-secondary-yellow: #E6A23C;
  --color-secondary-pink: #6FBECF;

  /* Semantic */
  --color-success: #1F8A5B;
  --color-success-subtle: rgba(31, 138, 91, 0.12);
  --color-success-border: rgba(31, 138, 91, 0.30);
  --color-warning: #E6A23C;
  --color-warning-subtle: rgba(230, 162, 60, 0.14);
  --color-warning-border: rgba(230, 162, 60, 0.32);
  --color-error: #D14343;
  --color-error-subtle: rgba(209, 67, 67, 0.10);
  --color-error-border: rgba(209, 67, 67, 0.26);
  --color-info: #417F9E;
  --color-info-subtle: rgba(65, 127, 158, 0.10);
  --color-info-border: rgba(65, 127, 158, 0.28);

  /* Labels */
  --color-label-primary: #1C1C1C;
  --color-label-secondary: #555454;
  --color-label-tertiary: rgba(85, 84, 84, 0.65);
  --color-label-quaternary: rgba(85, 84, 84, 0.35);
  --color-label-on-dark: #FFFFFF;
  --color-label-on-dark-secondary: rgba(255, 255, 255, 0.72);

  /* Surfaces */
  --surface-primary: #FFFFFF;
  /* page background */
  --surface-secondary: #F7F8F9;
  /* subtle panels */
  --surface-tertiary: #FFFFFF;
  /* cards */
  --surface-muted: #E8E8E8;
  /* chips / disabled panels */
  --surface-dark: #2A445A;
  /* code blocks, headers, footer */
  --surface-brand: #2A445A;

  /* Glass */
  --glass-light: rgba(255, 255, 255, 0.72);
  --glass-light-strong: rgba(255, 255, 255, 0.92);
  --glass-dark: rgba(42, 68, 90, 0.78);
  --glass-dark-strong: rgba(42, 68, 90, 0.92);
  --glass-white-32: rgba(255, 255, 255, 0.32);
  --glass-white-16: rgba(255, 255, 255, 0.16);
  --glass-blur: saturate(1.6) blur(18px);

  /* Separators */
  --separator-default: rgba(28, 28, 28, 0.08);
  --separator-strong: rgba(28, 28, 28, 0.16);
  --separator-dark: rgba(255, 255, 255, 0.12);
  --separator-dark-strong: rgba(255, 255, 255, 0.22);

  /* Gradients — navy sweeps */
  --gradient-hero: linear-gradient(135deg, #2A445A 0%, #417F9E 55%, #6FBECF 100%);
  --gradient-navy: linear-gradient(180deg, #2A445A 0%, #1B2C38 100%);
  --gradient-blue: linear-gradient(135deg, #417F9E 0%, #6FBECF 100%);
  --gradient-teal: linear-gradient(135deg, #6FBECF 0%, #417F9E 100%);
  --gradient-surface: linear-gradient(180deg, #FFFFFF 0%, #F7F8F9 100%);

  /* Old Framework gradient aliases — global.css uses --gradient-hero-warm
     internally; map to the new navy hero so the existing rule keeps rendering. */
  --gradient-hero-warm: linear-gradient(135deg, #2A445A 0%, #417F9E 55%, #6FBECF 100%);
  --gradient-brasil: linear-gradient(135deg, #2A445A 0%, #417F9E 100%);
  --gradient-sunset: linear-gradient(135deg, #417F9E 0%, #6FBECF 100%);
  --gradient-pedra: linear-gradient(135deg, #2A445A 0%, #1B2C38 100%);

  /* Typography — Open Sans for everything (display + body). The Old Framework
     fonts are gone; we don't load them. */
  --font-display: 'Open Sans', -apple-system, 'Helvetica Neue', sans-serif;
  --font-body: 'Open Sans', -apple-system, 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Spacing — 8px grid */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 40px;
  --space-8: 48px;
  --space-9: 56px;
  --space-10: 64px;
  --space-11: 80px;
  --space-12: 96px;
  --space-13: 120px;
  --space-14: 160px;

  /* Border Radius — contained, architectural */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-3xl: 24px;
  --radius-pill: 980px;

  /* Legacy Old Framework "pedra" radii — kept as aliases. These were Old Framework's signature
     organic asymmetric corners; nothing in current Soltis CSS uses them, but
     templates referenced them so we keep the names mapped to plain rounded
     values (caller still gets a recognizable rounded shape). */
  --radius-pedra-card: var(--radius-2xl);
  --radius-pedra-alt: var(--radius-xl);
  --radius-pedra-reverse: var(--radius-2xl);

  /* Shadows — cool navy-tinted */
  --shadow-xs: 0 1px 2px rgba(20, 32, 44, 0.04);
  --shadow-sm: 0 2px 4px rgba(20, 32, 44, 0.06);
  --shadow-md: 0 4px 12px rgba(20, 32, 44, 0.08);
  --shadow-lg: 0 8px 24px rgba(20, 32, 44, 0.10);
  --shadow-xl: 0 16px 48px rgba(20, 32, 44, 0.14);
  --shadow-2xl: 0 24px 64px rgba(20, 32, 44, 0.18);
  --shadow-glow-brand: 0 0 24px rgba(42, 68, 90, 0.25);

  /* Legacy aliases — Old Framework named the brand-glow "orange" and used a neumorphic
     raised shadow; map both to the new brand glow so existing classes light
     up correctly without code changes. */
  --shadow-glow-orange: 0 0 24px rgba(42, 68, 90, 0.25);
  --shadow-neu-raised: 0 8px 24px rgba(20, 32, 44, 0.10), 0 1px 0 rgba(255, 255, 255, 0.6) inset;

  /* Motion */
  --ease-default: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: cubic-bezier(0, 0, 0.58, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-soltis: cubic-bezier(0.22, 0.68, 0, 1);
  --ease: cubic-bezier(0.22, 0.68, 0, 1);
  /* legacy alias */
  --dur-instant: 100ms;
  --dur-fast: 200ms;
  --dur-normal: 320ms;
  --dur-slow: 500ms;
  --dur-slower: 800ms;

  /* Z-Index */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
  --z-nav: 600;
  --z-tooltip: 700;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--color-label-primary);
  background: var(--surface-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-brand-primary);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-default);
}

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

code,
pre {
  font-family: var(--font-mono);
}

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

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-tooltip);
  padding: var(--space-2) var(--space-4);
  background: var(--color-brand-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: var(--space-4);
  color: #fff;
}

/* ── Navigation ──────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  height: 64px;
  background: var(--glass-light-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--separator-default);
  transition: height var(--dur-fast) var(--ease-default);
}

.site-header nav {
  display: flex;
  gap: var(--space-5);
}

.site-header nav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-label-secondary);
  padding: var(--space-2) 0;
  position: relative;
}

.site-header nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--color-brand-primary);
  border-radius: 1px;
  transition: width var(--dur-normal) var(--ease-spring);
}

.site-header nav a:hover {
  color: var(--color-brand-primary);
}

.site-header nav a:hover::after {
  width: 100%;
}

.header-logo {
  font-weight: 800;
  font-size: 18px;
  color: var(--color-brand-primary);
  letter-spacing: -0.02em;
}

.user-area {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 120px;
  justify-content: flex-end;
}

.header-username {
  font-size: 14px;
  color: var(--color-label-secondary);
  font-weight: 500;
}

.header-btn {
  background: transparent;
  border: 1.5px solid var(--separator-strong);
  color: var(--color-label-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}

.header-btn:hover {
  background: var(--color-brand-primary-subtle);
  color: var(--color-brand-primary);
  border-color: var(--color-brand-primary);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: var(--radius-xl);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease);
  text-decoration: none;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: var(--color-brand-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-brand-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-orange);
}

.btn-secondary {
  background: var(--surface-tertiary);
  color: var(--color-brand-primary);
  border: 1.5px solid var(--color-brand-primary);
}

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

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

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

.btn-danger {
  background: var(--color-error-subtle);
  color: var(--color-error);
  border: 1.5px solid var(--color-error-border);
}

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

.btn-accent {
  background: var(--gradient-hero-warm);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-orange);
}

.btn-outline {
  background: transparent;
  color: var(--color-label-secondary);
  border: 1.5px solid var(--separator-strong);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--color-brand-primary);
  color: var(--color-brand-primary);
}

.btn-sm {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-lg);
}

.btn-lg {
  font-size: 16px;
  padding: 12px 28px;
  border-radius: var(--radius-2xl);
}

.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
}

.btn-icon.btn-sm {
  padding: 6px;
  width: 30px;
  height: 30px;
}

.btn-loading {
  pointer-events: none;
  opacity: 0.75;
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btnSpin 0.7s linear infinite;
}

@keyframes btnSpin {
  to {
    transform: rotate(360deg);
  }
}

.btn-group {
  display: inline-flex;
}

.btn-group .btn {
  border-radius: 0;
  border-right-width: 0;
}

.btn-group .btn:first-child {
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
}

.btn-group .btn:last-child {
  border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
  border-right-width: 1.5px;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: var(--separator-default);
  color: var(--color-label-secondary);
}

.badge-brand {
  background: var(--color-brand-primary-subtle);
  color: var(--color-brand-primary);
}

.badge-success {
  background: var(--color-success-subtle);
  color: var(--color-success);
}

.badge-warning {
  background: var(--color-warning-subtle);
  color: #B38600;
}

.badge-error {
  background: var(--color-error-subtle);
  color: var(--color-error);
}

.badge-info {
  background: var(--color-info-subtle);
  color: var(--color-info);
}

.badge-muted {
  background: var(--separator-default);
  color: var(--color-label-tertiary);
}

.badge-system {
  background: rgba(26, 26, 26, 0.05);
  color: var(--color-label-tertiary);
  font-style: italic;
}

.readonly-badge {
  background: var(--color-warning-subtle);
  color: #B38600;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-warning-border);
}

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border-left: 4px solid;
  margin-bottom: var(--space-4);
  font-size: 14px;
  line-height: 1.5;
}

.alert-success {
  background: var(--color-success-subtle);
  border-color: var(--color-success);
  color: #064e2a;
}

.alert-warning {
  background: var(--color-warning-subtle);
  border-color: var(--color-warning);
  color: #7a4f00;
}

.alert-error {
  background: var(--color-error-subtle);
  border-color: var(--color-error);
  color: #7f1d1d;
}

.alert-info {
  background: var(--color-info-subtle);
  border-color: var(--color-info);
  color: #1e3a5f;
}

.alert-body {
  flex: 1;
}

.alert-title {
  font-weight: 700;
  margin-bottom: 2px;
}

.alert-close {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.5;
  padding: 0;
  line-height: 1;
}

.alert-close:hover {
  opacity: 1;
}

/* ── Modals ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 18, 8, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-5);
}

.modal {
  background: var(--surface-tertiary);
  border-radius: var(--radius-2xl);
  /* Padding moved to .modal-header and .modal-body so the body can scroll
     INSIDE the rounded container without scrollbar overlapping the corners,
     and the header can stay pinned to the top when content overflows. */
  width: 100%;
  max-width: 440px;
  /* Cap height so tall content scrolls internally instead of overflowing
     the viewport. The overlay has padding: var(--space-5) all around, so
     we leave the same room (×2 for top+bottom) before clamping. */
  max-height: calc(100vh - var(--space-5) * 2);
  display: flex;
  flex-direction: column;
  overflow: hidden;           /* contains the rounded corners while .modal-body scrolls */
  box-shadow: var(--shadow-2xl);
  animation: modalIn var(--dur-normal) var(--ease-spring);
}

.modal-md {
  /* Editorial-form sized: the modal hugs its content, doesn't stretch
     to the viewport. Use for single-column forms with ~600px content. */
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
}

.modal-lg {
  /* Viewport-relative — leaves a 5% gutter on each side so the overlay
     remains tappable to dismiss. No fixed max-width: on ultra-wide screens
     the modal still scales (capped at a comfortable 90% so it doesn't
     edge-to-edge in 4K). max-height is already viewport-relative on the
     base .modal rule above. */
  width: 90vw;
  max-width: 90vw;
  max-height: 90vh;
}

.modal-xl {
  /* Two-column form / dashboard sized. Wider than md (room for a sidebar
     panel next to the form) but capped so it doesn't go edge-to-edge.
     Below 1024px we still leave 5vw of gutter. */
  width: 92vw;
  max-width: 1024px;
  max-height: 90vh;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
  }
}

.modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--space-4);
  color: var(--color-label-primary);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6) var(--space-6) var(--space-4);
  /* No margin-bottom — the spacing to the body is handled by .modal-body's
     padding-top below. Keeps the boundary clean when the body scrolls. */
  flex-shrink: 0;             /* never let the header shrink when body grows */
}

.modal-body {
  padding: var(--space-4) var(--space-6) var(--space-6);
  overflow-y: auto;           /* this is what scrolls when content is tall */
  flex: 1 1 auto;
  /* Smooth scrolling on iOS, hidden when there's nothing to scroll. */
  -webkit-overflow-scrolling: touch;
}

/* When there's no header (Modal.open without title), the body owns the
   full top padding so the content isn't pushed against the rounded edge. */
.modal > .modal-body:first-child {
  padding-top: var(--space-6);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-label-primary);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-label-tertiary);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--dur-fast);
}

.modal-close:hover {
  color: var(--color-label-primary);
  background: var(--separator-default);
}

/* ── Login Modal ─────────────────────────────────────────────────────────── */
#login-modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 18, 8, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

.login-box {
  background: var(--surface-tertiary);
  border-radius: var(--radius-2xl);
  padding: var(--space-7);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-2xl);
  animation: modalIn var(--dur-normal) var(--ease-spring);
}

.login-box h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: var(--space-1);
  color: var(--color-label-primary);
}

.login-box p {
  font-size: 14px;
  color: var(--color-label-tertiary);
  margin-bottom: var(--space-5);
}

.login-input {
  width: 100%;
  border: 1.5px solid var(--separator-strong);
  border-radius: var(--radius-lg);
  padding: 11px 14px;
  font-size: 15px;
  font-family: var(--font-body);
  outline: none;
  margin-bottom: var(--space-3);
  transition: border-color var(--dur-fast);
  background: var(--surface-tertiary);
}

.login-input:focus {
  border-color: var(--color-brand-primary);
}

.login-btn {
  width: 100%;
  background: var(--color-brand-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-xl);
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}

.login-btn:hover {
  background: var(--color-brand-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-orange);
}

.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.login-cancel {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--color-label-tertiary);
  font-size: 14px;
  font-family: var(--font-body);
  cursor: pointer;
  padding: var(--space-2);
  margin-top: var(--space-1);
}

.login-cancel:hover {
  color: var(--color-label-primary);
}

.login-error {
  color: var(--color-error);
  font-size: 13px;
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-error-subtle);
  border-radius: var(--radius-md);
}

.code-inputs {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-bottom: var(--space-5);
}

.code-input {
  width: 52px;
  height: 62px;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  font-family: var(--font-mono);
  border: 2px solid var(--separator-strong);
  border-radius: var(--radius-lg);
  outline: none;
  text-transform: uppercase;
  background: var(--surface-tertiary);
  color: var(--color-brand-primary);
  transition: border-color var(--dur-fast);
}

.code-input:focus {
  border-color: var(--color-brand-primary);
  background: var(--color-brand-primary-subtle);
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.input {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--separator-strong);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-label-primary);
  background: var(--surface-tertiary);
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.input:focus {
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 3px var(--color-brand-primary-subtle);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--surface-primary);
}

.input-sm {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: var(--radius-md);
}

.input-lg {
  padding: 13px 16px;
  font-size: 16px;
  border-radius: var(--radius-xl);
}

select.input {
  cursor: pointer;
}

.form-panel {
  background: var(--surface-tertiary);
  border: 1px solid var(--separator-default);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.form-panel h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: var(--space-2);
  color: var(--color-label-primary);
}

.form-note {
  font-size: 13px;
  color: var(--color-label-tertiary);
  margin-bottom: var(--space-5);
}

.form-row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-label-secondary);
}

.form-field-check {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}

.form-field-check label {
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.form-error {
  font-size: 13px;
  color: var(--color-error);
  padding: var(--space-2) var(--space-3);
  background: var(--color-error-subtle);
  border-radius: var(--radius-md);
  margin-top: var(--space-3);
}

.mt {
  margin-top: var(--space-4);
}

/* ── Database shared ─────────────────────────────────────────────────────── */
.db-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

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

.db-header h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--color-label-primary);
  letter-spacing: -0.015em;
}

.db-header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.total-count {
  font-size: 13px;
  color: var(--color-label-tertiary);
}

.db-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--color-label-tertiary);
  margin-bottom: var(--space-5);
}

.db-breadcrumb a {
  color: var(--color-brand-primary);
}

.db-breadcrumb a:hover {
  text-decoration: underline;
}

.db-breadcrumb span {
  color: var(--color-label-quaternary);
}

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.db-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-tertiary);
  white-space: nowrap;
}

.db-table th {
  background: var(--surface-dark);
  color: var(--color-label-on-dark);
  font-weight: 600;
  text-align: left;
  padding: 11px 16px;
  font-size: 12px;
  letter-spacing: 0.03em;
}

.db-table th:first-child {
  border-radius: var(--radius-xl) 0 0 0;
}

.db-table th:last-child {
  border-radius: 0 var(--radius-xl) 0 0;
}

.db-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--separator-default);
  font-size: 13px;
  color: var(--color-label-secondary);
}

.db-table tr:last-child td {
  border-bottom: none;
}

.db-table tr:hover td {
  background: var(--surface-primary);
}

.db-table-data .db-table th:first-child,
.db-table-data .db-table th:last-child {
  border-radius: 0;
}

.td-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.td-name strong {
  font-weight: 600;
  color: var(--color-label-primary);
}

.rename-form {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.empty {
  text-align: center;
  color: var(--color-label-tertiary);
  padding: var(--space-9) var(--space-4);
  font-style: italic;
  font-size: 14px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-5);
  justify-content: center;
}

.page-info {
  font-size: 13px;
  color: var(--color-label-tertiary);
}

/* ── Code blocks ─────────────────────────────────────────────────────────── */
.code-block {
  background: var(--surface-dark);
  color: var(--color-label-on-dark);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  margin-top: var(--space-3);
}

pre {
  background: var(--surface-dark);
  color: var(--color-label-on-dark);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: 12px;
  overflow-x: auto;
  line-height: 1.6;
}

code:not(pre code) {
  font-size: 13px;
  background: var(--color-brand-primary-subtle);
  color: var(--color-brand-primary);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

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

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width:734px) {
  .site-header {
    padding: 0 var(--space-4);
  }

  .site-header nav {
    display: none;
  }

  .db-wrap {
    padding: var(--space-5) var(--space-4);
  }

  .db-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .modal-lg {
    max-width: calc(100vw - 32px);
  }

  .code-inputs {
    gap: var(--space-2);
  }

  .code-input {
    width: 44px;
    height: 54px;
    font-size: 22px;
  }
}

/* ── Accessibility ───────────────────────────────────────────────────────── */
@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;
  }
}

@media (prefers-contrast:more) {
  :root {
    --separator-default: rgba(26, 26, 26, 0.25);
    --separator-strong: rgba(26, 26, 26, 0.40);
    --color-label-tertiary: rgba(26, 26, 26, 0.65);
  }
}