:root {
  --color-primary: #1f4cff;
  --color-secondary: #19b36b;
  --color-accent: #ff8c2b;
  --color-background: #f6f7fb;
  --color-ink: #10162f;
  --color-muted: #6b7280;
  --color-surface: #ffffff;
  --color-border: rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 20px 40px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 18px 30px rgba(15, 23, 42, 0.12);
  --bp-phone: 430px;
  --bp-sm: 640px;
  --bp-md: 980px;
  --touch-target: 44px;
}

html {
  box-sizing: border-box;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

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

body {
  margin: 0;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: var(--color-ink);
  background: radial-gradient(circle at top left, rgba(31, 76, 255, 0.08), transparent 45%),
    radial-gradient(circle at 30% 20%, rgba(25, 179, 107, 0.1), transparent 40%),
    linear-gradient(135deg, var(--color-background), #fefefe 50%);
  min-height: 100vh;
}

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

html[data-theme="dark"] {
  --color-ink: #f8fafc;
  --color-muted: #94a3b8;
  --color-surface: #0f172a;
  --color-border: rgba(148, 163, 184, 0.2);
  --shadow-soft: 0 18px 32px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 22px 36px rgba(0, 0, 0, 0.55);
}

html[data-theme="dark"] body {
  background: radial-gradient(circle at top left, rgba(31, 76, 255, 0.18), transparent 50%),
    radial-gradient(circle at 30% 20%, rgba(25, 179, 107, 0.18), transparent 45%),
    linear-gradient(135deg, var(--color-background), #0b1020 60%);
}

html,
body {
  height: 100%;
  overflow-x: hidden;
}

body {
  overflow-y: hidden;
}

body.auth-body {
  overflow: auto;
}

.page {
  display: flex;
  min-height: 100vh;
  height: 100%;
  min-width: 0;
}

.sidebar {
  width: 260px;
  padding: 32px 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(246, 247, 251, 0.92));
  border-right: 1px solid var(--color-border);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 32px;
  transition: width 0.25s ease, padding 0.25s ease;
  position: relative;
  z-index: 2;
  overflow: hidden;
}

html[data-theme="dark"] .sidebar {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(10, 15, 30, 0.95));
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  position: relative;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-collapse-toggle {
  border: none;
  background: rgba(31, 76, 255, 0.08);
  color: var(--color-primary);
  border-radius: 10px;
  width: var(--touch-target);
  height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
  z-index: 3;
}

.sidebar-collapse-toggle:hover {
  background: rgba(31, 76, 255, 0.2);
}

.sidebar-collapse-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.sidebar-collapse-icon svg {
  width: 100%;
  height: 100%;
}

.sidebar-collapse-icon .collapse-closed {
  display: none;
}

.sidebar.sidebar-collapsed .sidebar-collapse-icon .collapse-open {
  display: none;
}

.sidebar.sidebar-collapsed .sidebar-collapse-icon .collapse-closed {
  display: inline-flex;
}

.sidebar.sidebar-collapsed {
  width: 90px;
  padding: 32px 12px;
  overflow: visible;
}

.sidebar.sidebar-collapsed .sidebar-header {
  justify-content: center;
}

.sidebar.sidebar-collapsed .sidebar-header-actions {
  width: 100%;
  justify-content: center;
}

.sidebar.sidebar-collapsed .brand,
.sidebar.sidebar-collapsed .nav-toggle {
  display: none;
}

.sidebar.sidebar-collapsed .nav {
  gap: 10px;
}

.sidebar.sidebar-collapsed .brand-title,
.sidebar.sidebar-collapsed .brand-subtitle {
  display: none;
}

.sidebar.sidebar-collapsed .nav {
  gap: 6px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-link {
  text-decoration: none;
  color: inherit;
}

.brand img {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: var(--shadow-soft);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  letter-spacing: 1px;
}

.brand-title {
  font-weight: 700;
}

.brand-subtitle {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(31, 76, 255, 0.06);
}

.settings-toggle {
  margin-top: 6px;
}

html[data-theme="dark"] .theme-toggle {
  background: rgba(15, 23, 42, 0.6);
}

html[data-theme="dark"] .button:not(.button-danger):not(.button-ghost) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.05)),
    linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .button-ghost {
  background: rgba(148, 163, 184, 0.12);
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.45);
}

html[data-theme="dark"] .button-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.45);
}

html[data-theme="dark"] .input {
  background: rgba(15, 23, 42, 0.5);
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.3);
}

html[data-theme="dark"] .input:focus {
  border-color: rgba(129, 176, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(129, 176, 255, 0.15);
}

html[data-theme="dark"] .status {
  background: rgba(148, 163, 184, 0.22);
  color: #e2e8f0;
}

html[data-theme="dark"] .status.open {
  background: rgba(59, 130, 246, 0.3);
  color: #dbeafe;
}

html[data-theme="dark"] .status.in_progress {
  background: rgba(251, 146, 60, 0.32);
  color: #fed7aa;
}

html[data-theme="dark"] .status.ready {
  background: rgba(34, 197, 94, 0.3);
  color: #bbf7d0;
}

html[data-theme="dark"] .status.closed {
  background: rgba(148, 163, 184, 0.28);
  color: #e2e8f0;
}

html[data-theme="dark"] .status.cancelled {
  background: rgba(239, 68, 68, 0.32);
  color: #fecaca;
}

html[data-theme="dark"] .status.success {
  background: rgba(34, 197, 94, 0.3);
  color: #bbf7d0;
}

html[data-theme="dark"] .status.muted {
  background: rgba(148, 163, 184, 0.24);
  color: #e2e8f0;
}

html[data-theme="dark"] .chip {
  background: rgba(148, 163, 184, 0.22);
  color: #e2e8f0;
}

html[data-theme="dark"] .chip.open {
  background: rgba(59, 130, 246, 0.3);
  color: #dbeafe;
}

html[data-theme="dark"] .chip.in_progress {
  background: rgba(251, 146, 60, 0.32);
  color: #fed7aa;
}

html[data-theme="dark"] .chip.ready {
  background: rgba(34, 197, 94, 0.3);
  color: #bbf7d0;
}

html[data-theme="dark"] .chip.closed {
  background: rgba(148, 163, 184, 0.28);
  color: #e2e8f0;
}

html[data-theme="dark"] .chip.cancelled {
  background: rgba(239, 68, 68, 0.32);
  color: #fecaca;
}

html[data-theme="dark"] .chip.success {
  background: rgba(34, 197, 94, 0.3);
  color: #bbf7d0;
}

html[data-theme="dark"] .chip.accent {
  background: rgba(251, 146, 60, 0.32);
  color: #fed7aa;
}

html[data-theme="dark"] .topbar .muted {
  color: #ffffff;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.switch-slider {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.2);
  position: relative;
  transition: background 0.2s ease;
}

.switch-slider::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease;
  box-shadow: var(--shadow-soft);
}

.switch input:checked + .switch-slider {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
}

.switch input:checked + .switch-slider::after {
  transform: translateX(20px);
}

.nav-toggle {
  display: none;
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.72);
  color: var(--color-ink);
  border-radius: 10px;
  min-height: var(--touch-target);
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
  background: rgba(31, 76, 255, 0.14);
  border-color: rgba(31, 76, 255, 0.35);
  color: var(--color-primary);
}

html[data-theme="dark"] .nav-toggle {
  background: rgba(15, 23, 42, 0.78);
  border-color: rgba(148, 163, 184, 0.42);
  color: #f8fafc;
}

html[data-theme="dark"] .nav-toggle:hover,
html[data-theme="dark"] .nav-toggle:focus-visible {
  background: rgba(250, 204, 21, 0.2);
  border-color: rgba(250, 204, 21, 0.45);
  color: #f8fafc;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--color-ink);
  min-height: var(--touch-target);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  gap: 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
}

.nav-group-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.nav-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: inherit;
}

.nav-arrow svg {
  width: 100%;
  height: 100%;
}

.sidebar.sidebar-collapsed .nav-arrow {
  display: none;
}

.sidebar.sidebar-collapsed .nav-label {
  display: none;
}

.sidebar.sidebar-collapsed .nav-link,
.sidebar.sidebar-collapsed .nav-group-toggle {
  justify-content: center;
}

.sidebar.sidebar-collapsed .nav-link-logout {
  margin-top: 8px;
  padding-top: 10px;
}

.sidebar.sidebar-collapsed .nav-group-content {
  justify-content: center;
}

.sidebar.sidebar-collapsed .nav-group-menu {
  margin-left: 0;
  border-left: none;
  padding-left: 0;
}

.nav-group-toggle:hover {
  background: rgba(31, 76, 255, 0.08);
  color: var(--color-primary);
}

html[data-theme="dark"] .nav-group-toggle:hover {
  background: rgba(250, 204, 21, 0.12);
  color: var(--color-accent);
}

.nav-group-menu {
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-left: 6px;
  border-left: 2px solid var(--color-border);
  padding-left: 10px;
}

.nav-group-menu.is-open {
  display: flex;
}

.sidebar.sidebar-collapsed .nav-group-menu.is-open {
  position: absolute;
  top: 50%;
  left: 100%;
  margin-left: 0;
  border: 1px solid var(--color-border);
  padding: 12px;
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.1);
  width: 190px;
  max-height: min(70vh, 420px);
  overflow-y: auto;
  z-index: 40;
  transform: translate(12px, -50%);
}

.sidebar.sidebar-collapsed .nav-group-menu.is-open a {
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--color-ink);
}

.nav-link {
  text-decoration: none;
  color: var(--color-ink);
  min-height: var(--touch-target);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.nav-label {
  white-space: nowrap;
  display: block;
}

.nav-link:hover {
  background: rgba(31, 76, 255, 0.08);
  color: var(--color-primary);
}

.nav-link-logout {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.nav-link.active,
.nav-link[aria-current="page"] {
  background: rgba(31, 76, 255, 0.16);
  color: var(--color-primary);
  font-weight: 700;
}

html[data-theme="dark"] .nav-link:hover {
  background: rgba(250, 204, 21, 0.12);
  color: var(--color-accent);
}

html[data-theme="dark"] .nav-link.active,
html[data-theme="dark"] .nav-link[aria-current="page"] {
  background: rgba(250, 204, 21, 0.18);
  color: var(--color-accent);
}

.nav-group-toggle.active {
  background: rgba(31, 76, 255, 0.12);
  color: var(--color-primary);
}

html[data-theme="dark"] .nav-group-toggle.active {
  background: rgba(250, 204, 21, 0.16);
  color: var(--color-accent);
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: inherit;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
}

.nav-icon-dark {
  display: none;
}

html[data-theme="dark"] .nav-icon-dark {
  display: inline-flex;
}

html[data-theme="dark"] .nav-icon-light {
  display: none;
}

.sidebar-footer {
  margin-top: auto;
}

.badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(31, 76, 255, 0.12);
  color: var(--color-primary);
  font-size: 0.75rem;
  font-weight: 600;
}

.content {
  flex: 1;
  padding: 32px 40px calc(60px + env(safe-area-inset-bottom));
  position: relative;
  overflow-y: auto;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content::after {
  content: "";
  position: absolute;
  inset: -20% 10% auto auto;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(255, 140, 43, 0.18), transparent 60%);
  border-radius: 50%;
  z-index: 0;
}

html[data-theme="dark"] .content::after {
  background: radial-gradient(circle, rgba(255, 140, 43, 0.25), transparent 65%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  position: relative;
  z-index: 25;
  margin-bottom: 30px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
}

.muted {
  color: var(--color-muted);
  margin: 4px 0 0;
}

.topbar .muted {
  margin-bottom: 12px;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.topbar-actions .topbar-select {
  padding: 10px 16px;
  font-weight: 600;
  min-height: 40px;
}

.button {
  border: none;
  padding: 10px 16px;
  min-height: var(--touch-target);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--color-primary), #5d7bff);
  color: #fff;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

a.button {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button-ghost {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid rgba(31, 76, 255, 0.3);
  box-shadow: none;
}

.button-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.3);
  box-shadow: none;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin: 0;
}

.flash-stack-page {
  margin: 6px 0 18px;
  position: relative;
  width: min(760px, 100%);
  z-index: 5;
  justify-items: start;
}

.flash-stack-page .flash {
  width: 100%;
  max-width: none;
  min-height: 56px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-soft);
}

.flash {
  padding: 16px 20px;
  border-radius: 12px;
  color: var(--color-ink);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.3;
  background: rgba(241, 245, 255, 0.96);
  border: 1px solid rgba(31, 76, 255, 0.28);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.flash-hide {
  opacity: 0;
  transform: translateY(-6px);
}

.flash.error {
  background: rgba(254, 226, 226, 0.97);
  border-color: rgba(239, 68, 68, 0.45);
}

.flash.success {
  background: rgba(220, 252, 231, 0.97);
  border-color: rgba(34, 197, 94, 0.45);
}

html[data-theme="dark"] .flash {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(148, 163, 184, 0.45);
  color: #e2e8f0;
}

html[data-theme="dark"] .flash.error {
  background: rgba(127, 29, 29, 0.9);
  border-color: rgba(248, 113, 113, 0.55);
}

html[data-theme="dark"] .flash.success {
  background: rgba(20, 83, 45, 0.92);
  border-color: rgba(74, 222, 128, 0.6);
}

.stats-grid {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  position: relative;
  z-index: 1;
}

.stat-card {
  padding: 18px;
  border-radius: 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  animation: rise 0.6s ease both;
}

.stat-card:nth-child(2) {
  animation-delay: 0.1s;
}

.stat-card:nth-child(3) {
  animation-delay: 0.2s;
}

.stat-card:nth-child(4) {
  animation-delay: 0.3s;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--color-muted);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin: 6px 0;
}

.stat-meta {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.panel-grid {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.panel {
  background: var(--color-surface);
  border-radius: 20px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  padding: 24px;
  position: relative;
  z-index: 1;
  animation: fadeIn 0.6s ease both;
}

.panel + .panel.panel-collapsible {
  margin-top: 24px;
}

.panel-body {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.panel-scroll {
  overflow-x: auto;
}

.panel-table .panel-body {
  gap: 12px;
}

.detail-stack {
  display: grid;
  gap: 20px;
}

.detail-summary {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.detail-summary .status {
  font-size: 0.72rem;
}

.detail-summary .job-code {
  font-size: 0.72rem;
  background: rgba(31, 76, 255, 0.08);
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--color-primary);
}

html[data-theme="dark"] .detail-summary .job-code {
  background: rgba(129, 176, 255, 0.15);
  color: #93c5fd;
}

.detail-key-value {
  font-size: 0.95rem;
  line-height: 1.5;
}

.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: 6px;
}

.table-scroll {
  overflow-x: auto;
  max-height: min(62vh, 640px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border: 1px solid var(--color-border);
  border-radius: 14px;
}

.table-scroll .table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-surface);
}

.truncate {
  display: inline-block;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: rgba(31, 76, 255, 0.04);
}

.pagination-top {
  margin-left: auto;
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--color-muted);
  white-space: nowrap;
}

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

.pagination-page {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary);
  background: rgba(31, 76, 255, 0.12);
  border-radius: 999px;
  padding: 4px 10px;
}

html[data-theme="dark"] .pagination {
  background: rgba(148, 163, 184, 0.12);
}

html[data-theme="dark"] .pagination-page {
  background: rgba(250, 204, 21, 0.18);
  color: var(--color-accent);
}

.table-empty-results {
  margin-top: 12px;
}

.empty-state-inline {
  padding: 16px;
  border: 1px dashed var(--color-border);
}

.is-hidden {
  display: none !important;
}

.button:disabled,
.button.is-disabled,
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

.input:disabled,
select.input:disabled,
textarea.input:disabled,
.input.is-disabled,
.input[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  background: rgba(148, 163, 184, 0.12);
}

.status-select:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.table-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.table-filters .pagination {
  margin-left: auto;
}

.filter-field {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.filter-field span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

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

.table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
}

.table-mobile-cards td::before {
  content: attr(data-label);
  display: none;
}

.job-code {
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  letter-spacing: 0.12em;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.table-title {
  font-weight: 600;
}

.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-actions-cell {
  text-align: center !important;
  vertical-align: middle !important;
}

.table-actions-cell .table-actions {
  justify-content: center;
}

.table-compact th,
.table-compact td {
  padding: 8px 8px;
  font-size: 0.85rem;
}

.table-compact th {
  font-size: 0.7rem;
}

.table-compact .table-actions {
  gap: 4px;
}

.table-compact .table-actions .button {
  font-size: 0.75rem;
  padding: 4px 8px;
}

.table-compact .truncate {
  max-width: 200px;
}

html[data-theme="dark"] .table th {
  color: #94a3b8;
}

html[data-theme="dark"] .table td {
  border-bottom-color: rgba(148, 163, 184, 0.12);
}

html[data-theme="dark"] .table th {
  border-bottom-color: rgba(148, 163, 184, 0.2);
}

html[data-theme="dark"] .table-scroll {
  border-color: rgba(148, 163, 184, 0.15);
}

.hide-mobile {
  display: table-cell;
}

.show-mobile {
  display: none;
}

.inline-form {
  display: inline;
}

.status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.08);
  color: var(--color-muted);
}

.status.open {
  background: rgba(37, 99, 235, 0.15);
  color: #1d4ed8;
}

.status.in_progress {
  background: rgba(255, 140, 43, 0.18);
  color: #9a3412;
}

.status.ready {
  background: rgba(34, 197, 94, 0.16);
  color: #166534;
}

.status.closed {
  background: rgba(148, 163, 184, 0.3);
  color: #475569;
}

.status.cancelled {
  background: rgba(239, 68, 68, 0.16);
  color: #b91c1c;
}

.status.success {
  background: rgba(34, 197, 94, 0.16);
  color: #166534;
}

.status.muted {
  background: rgba(148, 163, 184, 0.25);
  color: #64748b;
}

.empty-state {
  padding: 24px;
  border-radius: 16px;
  background: rgba(31, 76, 255, 0.06);
  text-align: center;
  display: grid;
  gap: 8px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.panel-toggle {
  cursor: pointer;
}

.panel-collapsible > summary {
  list-style: none;
}

.panel-collapsible > summary::-webkit-details-marker {
  display: none;
}

.panel-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.panel-toggle-icon svg {
  width: 20px;
  height: 20px;
  display: none;
}

.panel-toggle-icon .icon-light-closed {
  display: inline-block;
}

details[open] .panel-toggle-icon .icon-light-closed {
  display: none;
}

details[open] .panel-toggle-icon .icon-light-open {
  display: inline-block;
}

html[data-theme="dark"] .panel-toggle-icon .icon-light-closed,
html[data-theme="dark"] .panel-toggle-icon .icon-light-open {
  display: none;
}

html[data-theme="dark"] .panel-toggle-icon .icon-dark-closed {
  display: inline-block;
}

html[data-theme="dark"] details[open] .panel-toggle-icon .icon-dark-closed {
  display: none;
}

html[data-theme="dark"] details[open] .panel-toggle-icon .icon-dark-open {
  display: inline-block;
}

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(25, 179, 107, 0.15);
  color: var(--color-secondary);
  font-weight: 600;
  font-size: 0.75rem;
}

html[data-theme="dark"] .pill {
  background: rgba(34, 197, 94, 0.25);
  color: #22c55e;
}

.timeline {
  display: grid;
  gap: 16px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 12px;
  align-items: center;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
}

.timeline-title {
  font-weight: 600;
}

.chip {
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.08);
  font-size: 0.75rem;
}

.chip.open {
  background: rgba(37, 99, 235, 0.15);
  color: #1d4ed8;
}

.chip.in_progress {
  background: rgba(255, 140, 43, 0.18);
  color: #9a3412;
}

.chip.ready {
  background: rgba(34, 197, 94, 0.16);
  color: #166534;
}

.chip.closed {
  background: rgba(148, 163, 184, 0.3);
  color: #475569;
}

.chip.cancelled {
  background: rgba(239, 68, 68, 0.16);
  color: #b91c1c;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip.success {
  background: rgba(34, 197, 94, 0.15);
  color: #166534;
}

.chip.accent {
  background: rgba(255, 140, 43, 0.18);
  color: #9a3412;
}

.metric {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.metric-label {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.metric-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.metric-bar {
  width: 100%;
  height: 10px;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.metric-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 999px;
}

.metric-fill.secondary {
  background: var(--color-secondary);
}

.metric-fill.accent {
  background: var(--color-accent);
}

.panel-note {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.panel-note-divider {
  border-top: 2px solid var(--color-border);
  padding-top: 16px;
  margin-top: 22px;
}

.panel-note-title {
  font-weight: 700;
  color: var(--color-ink);
  font-size: 1.1rem;
  margin-bottom: 10px;
}

.panel-note-total {
  font-weight: 700;
  color: #22c55e;
  font-size: 1.05rem;
}

.panel-note-amount {
  font-size: 1.05rem;
  font-weight: 700;
  color: #22c55e;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.summary-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--color-border);
  background: rgba(31, 76, 255, 0.04);
}

.dashboard-summary-grid {
  margin-bottom: 16px;
}

.dashboard-range-form {
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(170px, 220px) auto auto;
  align-items: end;
  column-gap: 10px;
  row-gap: 8px;
  margin-bottom: 10px;
}

.dashboard-range-form label {
  display: grid;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.dashboard-range-form .input {
  min-width: 0;
  width: 100%;
}

.dashboard-range-form .button {
  white-space: nowrap;
}

.dashboard-range-note {
  margin-top: 0;
  margin-bottom: 12px;
}

.summary-card-warning {
  background: rgba(255, 140, 43, 0.14);
}

.summary-card-success {
  background: rgba(25, 179, 107, 0.14);
}

.summary-label {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.summary-value {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 6px;
}

.status-distribution {
  display: flex;
  width: 100%;
  height: 12px;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.status-segment {
  min-width: 0;
  height: 100%;
}

.status-segment.open {
  background: rgba(37, 99, 235, 0.85);
}

.status-segment.in_progress {
  background: rgba(255, 140, 43, 0.9);
}

.status-segment.ready {
  background: rgba(34, 197, 94, 0.88);
}

.status-segment.closed {
  background: rgba(100, 116, 139, 0.85);
}

.status-segment.cancelled {
  background: rgba(239, 68, 68, 0.86);
}

.status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-alerts {
  display: grid;
  gap: 10px;
}

.dashboard-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: rgba(31, 76, 255, 0.06);
}

.dashboard-alert a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.dashboard-alert.warning {
  background: rgba(255, 140, 43, 0.14);
}

.dashboard-alert.success {
  background: rgba(25, 179, 107, 0.14);
}

.dashboard-alert.accent {
  background: rgba(31, 76, 255, 0.1);
}

html[data-theme="dark"] .summary-card-warning {
  background: rgba(249, 115, 22, 0.24);
}

html[data-theme="dark"] .summary-card-success {
  background: rgba(34, 197, 94, 0.24);
}

html[data-theme="dark"] .status-distribution {
  background: rgba(148, 163, 184, 0.2);
}

html[data-theme="dark"] .status-segment.open {
  background: rgba(59, 130, 246, 0.82);
}

html[data-theme="dark"] .status-segment.in_progress {
  background: rgba(249, 115, 22, 0.85);
}

html[data-theme="dark"] .status-segment.ready {
  background: rgba(34, 197, 94, 0.82);
}

html[data-theme="dark"] .status-segment.closed {
  background: rgba(148, 163, 184, 0.85);
}

html[data-theme="dark"] .status-segment.cancelled {
  background: rgba(248, 113, 113, 0.85);
}

html[data-theme="dark"] .dashboard-alert {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(148, 163, 184, 0.16);
}

html[data-theme="dark"] .dashboard-alert.warning {
  background: rgba(249, 115, 22, 0.26);
}

html[data-theme="dark"] .dashboard-alert.success {
  background: rgba(34, 197, 94, 0.24);
}

html[data-theme="dark"] .dashboard-alert.accent {
  background: rgba(59, 130, 246, 0.26);
}

html[data-theme="dark"] .dashboard-alert a {
  color: #93c5fd;
}

.settings-panel {
  margin-top: 28px;
}

.settings-form {
  display: grid;
  gap: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  font-size: 0.9rem;
}

.form-grid > label,
.form-grid > .field-span-2 {
  min-width: 0;
  align-self: start;
}

.form-grid label .input,
.form-grid label .search-select,
.form-grid label .search-select .input {
  width: 100%;
  box-sizing: border-box;
}

.field-span-2 {
  grid-column: 1 / -1;
}

.bicycle-form-grid {
  align-items: start;
}

.job-top-grid {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) minmax(220px, 1.1fr) minmax(180px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.job-top-grid > label {
  min-width: 0;
}

.job-top-grid label .input,
.job-top-grid label .search-select,
.job-top-grid label .search-select .input {
  width: 100%;
  box-sizing: border-box;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.field-error {
  font-size: 0.8rem;
  color: #b91c1c;
}

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

.full-width {
  width: 100%;
}

.settings-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.settings-column {
  display: grid;
  gap: 16px;
}

.settings-section {
  display: grid;
  gap: 16px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: rgba(31, 76, 255, 0.04);
}

.section-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.color-field {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: #fff;
}

.color-value {
  font-size: 0.85rem;
  color: var(--color-muted);
  justify-self: end;
}


.input {
  padding: 10px 12px;
  min-height: var(--touch-target);
  border-radius: 12px;
  border: 1px solid var(--color-border);
  font-family: inherit;
  font-size: 1rem;
}

.input[type="file"] {
  padding: 6px;
  background: rgba(31, 76, 255, 0.04);
}

.input[type="file"]::file-selector-button {
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--color-primary), #5d7bff);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  margin-right: 10px;
}

.input-compact {
  padding: 6px 10px;
  font-size: 0.85rem;
}

.button-compact {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
}

.icon {
  width: 16px;
  height: 16px;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-pdf {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-pdf .pdf-spinner {
  display: none;
}

.btn-pdf.is-loading .pdf-icon {
  display: none;
}

.btn-pdf.is-loading .pdf-spinner {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

.wa-modal-message {
  min-height: 140px;
  resize: vertical;
}

.wa-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-whatsapp {
  color: #25d366;
  border-color: rgba(37, 211, 102, 0.55);
}

.btn-whatsapp:hover {
  background: rgba(37, 211, 102, 0.12);
}

html[data-theme="dark"] .btn-whatsapp {
  color: #5cf08f;
  border-color: rgba(92, 240, 143, 0.55);
}

html[data-theme="dark"] .btn-whatsapp:hover {
  background: rgba(37, 211, 102, 0.22);
}

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

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

.status-select {
  border-color: transparent;
  font-weight: 600;
}

.status-select.status-open {
  background: rgba(37, 99, 235, 0.18);
  color: #1d4ed8;
}

.status-select.status-in_progress {
  background: rgba(255, 140, 43, 0.2);
  color: #9a3412;
}

.status-select.status-ready {
  background: rgba(34, 197, 94, 0.2);
  color: #166534;
}

.status-select.status-closed {
  background: rgba(148, 163, 184, 0.3);
  color: #475569;
}

.status-select.status-cancelled {
  background: rgba(239, 68, 68, 0.2);
  color: #b91c1c;
}

html[data-theme="dark"] .status-select.status-open {
  background: rgba(59, 130, 246, 0.28);
  color: #93c5fd;
}

html[data-theme="dark"] .status-select.status-in_progress {
  background: rgba(249, 115, 22, 0.28);
  color: #fdba74;
}

html[data-theme="dark"] .status-select.status-ready {
  background: rgba(34, 197, 94, 0.28);
  color: #86efac;
}

html[data-theme="dark"] .status-select.status-closed {
  background: rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
}

html[data-theme="dark"] .status-select.status-cancelled {
  background: rgba(239, 68, 68, 0.3);
  color: #fecaca;
}

textarea.input {
  min-height: 90px;
  resize: vertical;
}

select[multiple].input {
  min-height: 120px;
}

.form-stack {
  display: grid;
  gap: 18px;
}

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

.form-actions .button {
  min-width: 140px;
}

.search-select {
  position: relative;
  width: 100%;
}

.search-select .input {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-select.is-open .input {
  border-color: rgba(31, 76, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(31, 76, 255, 0.1);
}

html[data-theme="dark"] .search-select.is-open .input {
  border-color: rgba(250, 204, 21, 0.55);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.16);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 22;
  display: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  max-height: 240px;
  overflow-y: auto;
}

.search-results.is-open {
  display: grid;
}

.search-result {
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  color: var(--color-ink);
  font: inherit;
  cursor: pointer;
  width: 100%;
}

.search-result:hover,
.search-result:focus-visible,
.search-result.is-active {
  background: rgba(31, 76, 255, 0.08);
}

html[data-theme="dark"] .search-result:hover,
html[data-theme="dark"] .search-result:focus-visible,
html[data-theme="dark"] .search-result.is-active {
  background: rgba(250, 204, 21, 0.12);
}

.search-empty {
  padding: 10px 12px;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.parts-list {
  display: grid;
  gap: 10px;
}

.parts-add-button {
  margin-top: 12px;
}

.parts-note {
  margin-top: 6px;
}

.parts-head {
  display: grid;
  grid-template-columns: minmax(180px, 1.7fr) 90px 110px 120px 110px 38px;
  gap: 8px;
  color: var(--color-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 2px;
}

.part-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.7fr) 90px 110px 120px 110px 38px;
  gap: 8px;
  align-items: center;
}

.part-field-label {
  display: none;
}

.part-total {
  text-align: right;
  font-weight: 600;
  color: var(--color-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.parts-summary {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: rgba(31, 76, 255, 0.04);
}

.parts-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--color-muted);
}

.parts-summary-row strong {
  font-variant-numeric: tabular-nums;
  color: var(--color-ink);
}

.parts-summary-row.total {
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
  font-weight: 700;
}

.parts-summary-row.total strong {
  color: var(--color-primary);
}

html[data-theme="dark"] .parts-summary {
  background: rgba(148, 163, 184, 0.1);
}

.part-remove {
  font-weight: 700;
}

.input-feedback {
  font-size: 0.78rem;
  color: var(--color-muted);
}

.input-feedback.error {
  color: #b91c1c;
}

.input-invalid {
  border-color: rgba(239, 68, 68, 0.7) !important;
}

.wizard-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.wizard-step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: rgba(31, 76, 255, 0.04);
}

.wizard-step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), #5d7bff);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.wizard-step-title {
  font-weight: 600;
}

.template-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.code-sample {
  margin: 6px 0 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid var(--color-border);
  overflow-x: auto;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  font-size: 0.85rem;
}

.security-stack {
  display: grid;
  gap: 16px;
}

.security-note {
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.input-short {
  min-height: 72px;
}

.service-options {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.service-option {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(31, 76, 255, 0.06);
}

.job-status-field {
  min-width: 160px;
  max-width: 220px;
  justify-self: start;
}

.job-status-field .input {
  min-width: 160px;
}

.job-notes-field {
  max-width: 760px;
}

.job-notes-field .input {
  min-height: 128px;
}

.js-delivery-picker {
  font-variant-numeric: tabular-nums;
}

.air-datepicker {
  border-radius: 14px;
  border: 1px solid var(--color-border);
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
}

.air-datepicker-nav--title,
.air-datepicker-body--day-name {
  text-transform: capitalize;
}

.air-datepicker-cell.-selected- {
  background: var(--color-primary);
}

html[data-theme="dark"] .air-datepicker {
  background: #0f172a;
  border-color: rgba(148, 163, 184, 0.25);
  color: #e2e8f0;
}

.service-option input[type="checkbox"] {
  margin-top: 0;
}

.service-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.service-name {
  font-weight: 600;
}

.js-service-price {
  width: 110px;
  text-align: right;
  font-size: 0.85rem;
}

.js-service-price:disabled {
  opacity: 0.4;
}

.service-desc {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(64px, 10vh, 96px) 20px 24px;
  overflow-y: auto;
  z-index: 80;
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  width: min(520px, 100%);
  background: var(--color-surface);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: grid;
  gap: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  border: 1px solid var(--color-border);
  background: rgba(15, 23, 42, 0.06);
  color: var(--color-ink);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover,
.modal-close:focus-visible {
  background: rgba(31, 76, 255, 0.14);
  border-color: rgba(31, 76, 255, 0.35);
  color: var(--color-primary);
}

html[data-theme="dark"] .modal-close {
  background: rgba(148, 163, 184, 0.18);
  border-color: rgba(148, 163, 184, 0.42);
  color: #f8fafc;
}

html[data-theme="dark"] .modal-close:hover,
html[data-theme="dark"] .modal-close:focus-visible {
  background: rgba(250, 204, 21, 0.2);
  border-color: rgba(250, 204, 21, 0.45);
  color: #f8fafc;
}

.modal-body {
  display: grid;
  gap: 14px;
}

.confirm-modal #confirmMessage {
  margin: 0;
  font-size: 0.95rem;
  color: var(--color-ink);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-section {
  display: grid;
  gap: 6px;
}

.modal-title {
  font-weight: 600;
}

.modal-list {
  display: grid;
  gap: 10px;
}

.modal-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  padding: 6px 0;
}

.modal-row + .modal-row {
  border-top: 1px dashed var(--color-border);
}

.modal-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  margin-top: 10px;
}

.theme-presets {
  display: grid;
  gap: 16px;
}

.theme-header h3 {
  margin: 0;
}

.theme-header .muted {
  margin-top: 6px;
}


.settings-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.preview-card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(31, 76, 255, 0.06);
  border-radius: 14px;
  padding: 12px 16px;
}

.preview-card img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
}

.preview-title {
  font-weight: 600;
}

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--color-surface);
  border-radius: 20px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  padding: 28px;
  display: grid;
  gap: 24px;
  animation: rise 0.6s ease both;
}

.auth-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.auth-header h1 {
  margin: 0;
  line-height: 1.1;
}

.auth-header .muted {
  margin: 8px 0 0;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form > label {
  gap: 8px;
}

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

.auth-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.9rem;
}

.auth-footer.single-link {
  justify-content: flex-start;
}

.auth-footer a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

:focus-visible {
  outline: 2px solid rgba(31, 76, 255, 0.7);
  outline-offset: 2px;
}

html[data-theme="dark"] :focus-visible {
  outline-color: rgba(129, 176, 255, 0.85);
}

.button-ghost:focus-visible {
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(31, 76, 255, 0.18);
}

html[data-theme="dark"] .button-ghost:focus-visible {
  box-shadow: 0 0 0 3px rgba(129, 176, 255, 0.25);
}

.status:focus-visible,
.chip:focus-visible {
  outline-offset: 1px;
}

html[data-theme="dark"] .button-ghost:hover {
  background: rgba(148, 163, 184, 0.2);
  border-color: rgba(148, 163, 184, 0.6);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@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 (max-width: 980px) {
  .page {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    align-items: stretch;
    padding: 20px 16px;
    gap: 20px;
    overflow: visible;
  }

  .sidebar.sidebar-collapsed {
    width: 100%;
    padding: 20px 16px;
    overflow: visible;
  }

  .sidebar.sidebar-collapsed .brand {
    display: flex;
  }

  .sidebar.sidebar-collapsed .sidebar-header {
    justify-content: space-between;
  }

  .sidebar.sidebar-collapsed .sidebar-header-actions {
    width: auto;
    justify-content: flex-end;
  }

  .sidebar.sidebar-collapsed .brand-title,
  .sidebar.sidebar-collapsed .brand-subtitle,
  .sidebar.sidebar-collapsed .nav-label,
  .sidebar.sidebar-collapsed .nav-arrow {
    display: block;
  }

  .sidebar.sidebar-collapsed .nav-link,
  .sidebar.sidebar-collapsed .nav-group-toggle {
    justify-content: flex-start;
  }

  .sidebar.sidebar-collapsed .nav-group-content {
    justify-content: flex-start;
  }

  .sidebar.sidebar-collapsed .nav-group-menu.is-open {
    position: static;
    transform: none;
    width: 100%;
    max-height: none;
    min-height: 0;
    overflow: visible;
    margin-left: 6px;
    border: 0;
    border-left: 2px solid var(--color-border);
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    padding: 0 0 0 10px;
  }

  .nav {
    display: none;
    width: 100%;
    padding: 8px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(8px);
  }

  html[data-theme="dark"] .nav {
    background: rgba(15, 23, 42, 0.8);
  }

  .nav.is-open {
    display: flex;
  }

  .nav-link {
    width: 100%;
  }

  .nav-link-logout {
    margin-top: 8px;
    padding-top: 10px;
  }

  .sidebar.mobile-menu-open .nav {
    display: flex;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .sidebar-collapse-toggle {
    display: none;
  }

  .content {
    padding: 28px 24px calc(48px + env(safe-area-inset-bottom));
  }

  .flash-stack-page {
    width: 100%;
    margin-bottom: 16px;
  }

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

  .job-status-field {
    max-width: 280px;
  }

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

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

@media (max-width: 640px) {
  .sidebar {
    gap: 18px;
  }

  .truncate {
    max-width: 180px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }

  .topbar-actions > * {
    width: auto;
  }

  .topbar-actions #storeForm {
    flex: 1 1 190px;
    min-width: 0;
  }

  .topbar-actions #storeForm .topbar-select {
    width: 100%;
  }

  .topbar-actions .button,
  .topbar-actions a.button {
    flex: 1 1 160px;
    min-width: 150px;
  }

  .flash-stack-page {
    width: 100%;
  }

  .flash-stack-page .flash {
    width: 100%;
    max-width: none;
    min-height: 58px;
    padding: 14px 16px;
  }

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

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

  .job-top-grid {
    grid-template-columns: 1fr;
  }

  .job-status-field,
  .job-notes-field {
    max-width: none;
  }

  .table-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .table-filters .pagination {
    margin-left: 0;
    width: 100%;
  }

  .filter-field {
    width: 100%;
    min-width: 0;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .button {
    width: 100%;
    min-width: 0;
  }

  .service-option {
    grid-template-columns: 20px 1fr;
    align-items: start;
  }

  .js-service-price {
    grid-column: 1 / -1;
    width: 100%;
    text-align: left;
  }

  .table-mobile-cards {
    border: none;
    max-height: none;
    overflow: visible;
  }

  .table-mobile-cards .table,
  .table-mobile-cards .table tbody,
  .table-mobile-cards .table tr,
  .table-mobile-cards .table td {
    display: block;
    width: 100%;
  }

  .table-mobile-cards .table thead {
    display: none;
  }

  .table-mobile-cards .table tbody {
    display: grid;
    gap: 10px;
  }

  .table-mobile-cards .table tr {
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: rgba(31, 76, 255, 0.03);
  }

  .table-mobile-cards .table td {
    padding: 0;
    border: 0;
    display: grid;
    gap: 4px;
  }

  .table-mobile-cards .table td + td {
    margin-top: 10px;
  }

  .table-mobile-cards td::before {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-muted);
  }

  .table-mobile-cards .table .truncate {
    max-width: none;
    white-space: normal;
  }

  .table-mobile-cards .table td.table-actions-cell {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .table-mobile-cards .table td.table-actions-cell > .button,
  .table-mobile-cards .table td.table-actions-cell > .inline-form,
  .table-mobile-cards .table td.table-actions-cell > .inline-form .button {
    width: 100%;
  }

  .table-mobile-cards .table td.table-actions-cell > .inline-form {
    display: block;
    margin: 0;
  }

  html[data-theme="dark"] .table-mobile-cards .table tr {
    background: rgba(148, 163, 184, 0.08);
    border-color: rgba(148, 163, 184, 0.24);
  }

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

  .color-field {
    grid-template-columns: auto 1fr;
  }

  .color-value {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .button,
  .nav-link,
  .nav-group-toggle {
    font-size: 1rem;
  }

  .icon-button {
    width: var(--touch-target);
    height: var(--touch-target);
  }

  .modal-overlay {
    padding: 72px 12px 16px;
  }

  .modal {
    border-radius: 14px;
    padding: 16px;
  }

  .confirm-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-body {
    min-height: 100svh;
    align-items: flex-start;
  }

  .auth-card {
    margin-top: 8vh;
  }

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

  .dashboard-range-form {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .dashboard-range-form .input {
    min-width: 0;
    width: 100%;
  }

  .settings-preview {
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .table-actions {
    justify-content: flex-start;
  }

  .hide-mobile {
    display: none;
  }

  .show-mobile {
    display: table-cell;
  }

  .status-form {
    flex-direction: column;
    align-items: stretch;
  }

  .part-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: rgba(31, 76, 255, 0.03);
  }

  .part-field-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-muted);
  }

  .parts-head {
    display: none;
  }

  .part-total {
    text-align: left;
  }

  .wizard-steps {
    grid-template-columns: 1fr;
  }

  .pagination {
    width: 100%;
    justify-content: space-between;
  }

  .pagination-actions {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .sidebar {
    padding: 16px 12px;
  }

  .content {
    padding: 20px 12px calc(28px + env(safe-area-inset-bottom));
  }

  .flash-stack-page {
    width: 100%;
    margin-bottom: 14px;
  }

  .table th,
  .table td {
    padding: 10px 8px;
  }

  .auth-card {
    padding: 22px 18px;
  }
}
