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

:root {
  /* ─── Layout ─────────────────────────────────────────────────── */
  --layout-max-width: 3600px;
  --spacing-y: 0.0rem;
  --spacing-x: 3.0rem;
  --toolbar-h: 3rem;

  /* ─── Brand ──────────────────────────────────────────────────── */
  --primary:       #163E64;
  --primary-dark:  #0f2847;
  --on-primary:    #fff;
  --focus-ring:    0 0 0 3px rgba(22, 62, 100, 0.2);

  /* ─── Backgrounds ────────────────────────────────────────────── */
  --bg:            #fff;
  --bg-subtle:     #f8fafc;
  --bg-muted:      #f1f5f9;
  --bg-hover:      #f5f8ff;
  --bg-th:         #163E64;

  /* ─── Table text ────────────────────────────────────────────── */
  --text-th:       #ffffff;
  --text-th-alt:   #000000;
  --th-icon:       #ffffff;

  /* ─── Text ───────────────────────────────────────────────────── */
  --text:          #1a1a1a;
  --text-muted:    #64748b;
  --text-placeholder: #94a3b8;

  /* ─── Borders ────────────────────────────────────────────────── */
  --border:        #dee2e6;
  --border-input:  #cbd5e1;

  /* ─── Semantic ───────────────────────────────────────────────── */
  --danger:        #b91c1c;
  --danger-bg:     #fef2f2;
  --success:       #059669;
  --success-bg:    #d4edda;

  /* ─── Geometry, shadow, motion, type ─────────────────────────── */
  --radius-sm:     4px;
  --radius-md:     6px;
  --radius-lg:     8px;
  --radius-xl:     12px;
  --shadow-sm:     0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md:     0 8px 20px rgba(15, 23, 42, 0.12);
  --shadow-lg:     0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
  --shadow-dropdown: 0 12px 18px -6px rgba(15, 23, 42, 0.16);
  --t:             0.15s ease;
  --font-size-base-px: 14;
  --font-size-input: calc(0.9 * var(--font-size-base-px) * 1px);
}

/* ─── Reset / base ───────────────────────────────────────────── */
html {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-size: calc(1px * var(--font-size-base-px));
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar {
  display: none;
}

body {
  font-family: inherit;
  line-height: 1.5;
  margin: 0;
  height: 100vh;
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body::-webkit-scrollbar {
  display: none;
}

/* ─── Links ──────────────────────────────────────────────────── */
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ─── Buttons: base ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: calc(0.5rem - 1px) calc(1rem - 1px);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font: inherit;
  transition: background var(--t), color var(--t), border-color var(--t), box-shadow var(--t);
}

.btn .icon,
.btn-icon .icon {
  width: 1.125rem;
  height: 1.125rem;
}

.btn-block { width: 100%; justify-content: center; }

.btn:focus-visible,
.btn-icon:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ─── Buttons: primary (main CTA — brand filled) ────────────── */
.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  border: 1px solid var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

/* ─── Buttons: secondary (lighter alternative) ───────────────── */
.btn-secondary {
  background: var(--bg);
  color: var(--primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--primary);
}

/* ─── Buttons: outline (teal — for dark card-header rows) ────── */
.btn-outline {
  background: #4a7c8e;
  color: var(--on-primary);
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-outline:hover {
  background: #5a8c9e;
  border-color: rgba(255, 255, 255, 0.5);
}

/* ─── Buttons: danger ────────────────────────────────────────── */
.btn-danger {
  background: var(--danger);
  color: var(--on-primary);
}
.btn-danger:hover {
  background: #991b1b;
}

/* ─── Buttons: outline-danger ────────────────────────────────── */
.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger);
  color: var(--on-primary);
  border-color: #991b1b;
}

/* ─── Buttons: success ───────────────────────────────────────── */
.btn-success {
  background: var(--success);
  color: var(--on-primary);
}
.btn-success:hover {
  background: #047857;
}

/* ─── Buttons: icon ──────────────────────────────────────────── */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.btn-icon:hover {
  background: var(--bg-muted);
  color: var(--primary);
}
.btn-icon--danger {
  color: var(--danger);
}
.btn-icon--danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ─── Buttons: sizes ─────────────────────────────────────────── */
.btn-small {
  padding: calc(0.35rem - 1px) calc(0.6rem - 1px);
  font-size: 0.75rem;
}
.btn-small .icon {
  width: 0.9375rem;
  height: 0.9375rem;
}

.btn-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  border: none;
  font-weight: 500;
  line-height: 1.4;
}
.btn-xs .icon {
  width: 0.75rem;
  height: 0.75rem;
}

.tab-bar-actions .btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  min-height: 0;
  white-space: nowrap;
}

/* ─── Buttons: save-top (secondary when clean → primary when dirty) ── */
.btn-save-top {
  background: var(--bg) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border) !important;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.btn-save-top:hover {
  background: var(--bg-subtle) !important;
  border-color: var(--primary) !important;
}
.btn-save-top.is-dirty {
  background: var(--primary) !important;
  color: var(--on-primary) !important;
  border-color: var(--primary) !important;
}
.btn-save-top.is-dirty:hover {
  background: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
}
