:root {
  --bg: #f4efe5;
  --paper: rgba(255, 251, 244, 0.84);
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --panel-elevated: rgba(255, 255, 255, 0.96);
  --line: rgba(53, 72, 64, 0.14);
  --line-strong: rgba(31, 77, 59, 0.24);
  --ink: #18241f;
  --muted: #506158;
  --accent: #214f40;
  --accent-2: #6d8f7d;
  --accent-soft: rgba(205, 223, 212, 0.72);
  --warn: #8b2e2e;
  --success: #1f5d41;
  --sidebar-bg: rgba(12, 24, 22, 0.88);
  --sidebar-ink: #f6f0e4;
  --sidebar-muted: rgba(246, 240, 228, 0.74);
  --sidebar-line: rgba(255, 255, 255, 0.12);
  --sidebar-surface: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.72);
  --button-bg: rgba(255, 255, 255, 0.66);
  --button-hover: rgba(31, 77, 59, 0.12);
  --table-row: rgba(255, 255, 255, 0.34);
  --table-row-alt: rgba(250, 246, 240, 0.62);
  --hero-glow: rgba(94, 137, 117, 0.18);
  --shadow: 0 20px 60px rgba(33, 45, 40, 0.12);
  --shadow-strong: 0 24px 70px rgba(19, 30, 27, 0.18);
  --font-sans: 'IBM Plex Sans', 'Segoe UI', sans-serif;
  --font-serif: 'IBM Plex Serif', Georgia, serif;
}

body[data-theme='dark'],
html[data-theme='dark'] body {
  --bg: #0d1715;
  --paper: rgba(15, 27, 24, 0.8);
  --panel: rgba(18, 31, 28, 0.78);
  --panel-strong: rgba(21, 36, 32, 0.92);
  --panel-elevated: rgba(24, 41, 37, 0.95);
  --line: rgba(199, 221, 211, 0.12);
  --line-strong: rgba(199, 221, 211, 0.24);
  --ink: #ecf2ee;
  --muted: #a8bab1;
  --accent: #83b39b;
  --accent-2: #b8d4c4;
  --accent-soft: rgba(74, 108, 93, 0.28);
  --warn: #ef8f8f;
  --success: #8fd4a9;
  --sidebar-bg: rgba(7, 14, 13, 0.94);
  --sidebar-ink: #f2ecdf;
  --sidebar-muted: rgba(242, 236, 223, 0.72);
  --sidebar-line: rgba(255, 255, 255, 0.08);
  --sidebar-surface: rgba(255, 255, 255, 0.05);
  --input-bg: rgba(12, 24, 22, 0.86);
  --button-bg: rgba(255, 255, 255, 0.05);
  --button-hover: rgba(131, 179, 155, 0.12);
  --table-row: rgba(255, 255, 255, 0.02);
  --table-row-alt: rgba(255, 255, 255, 0.04);
  --hero-glow: rgba(131, 179, 155, 0.12);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --shadow-strong: 0 28px 90px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  color-scheme: light;
  position: relative;
  background:
    radial-gradient(circle at top left, var(--hero-glow), transparent 26%),
    radial-gradient(
      circle at 82% 18%,
      rgba(214, 188, 126, 0.12),
      transparent 22%
    ),
    linear-gradient(135deg, #efe3d1 0%, #f7f3eb 42%, #dde9e0 100%);
}

body[data-theme='dark'],
html[data-theme='dark'] body {
  color-scheme: dark;
  background:
    radial-gradient(
      circle at top left,
      rgba(79, 127, 108, 0.18),
      transparent 26%
    ),
    radial-gradient(
      circle at 82% 18%,
      rgba(201, 168, 103, 0.08),
      transparent 18%
    ),
    linear-gradient(135deg, #09110f 0%, #10201c 45%, #162923 100%);
}

body::before,
body::after {
  content: '';
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  filter: blur(8px);
}

body::before {
  width: 360px;
  height: 360px;
  top: -90px;
  right: -110px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 219, 154, 0.18),
    transparent 64%
  );
}

body::after {
  width: 300px;
  height: 300px;
  bottom: -120px;
  left: -80px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(76, 123, 104, 0.18),
    transparent 62%
  );
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  padding: 32px 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 22%),
    var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-line);
  color: var(--sidebar-ink);
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.02);
}

.mobile-menu-toggle {
  display: none;
}

.sidebar .eyebrow,
.login-card .eyebrow {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 6px;
}

.sidebar .eyebrow {
  color: color-mix(in srgb, var(--sidebar-ink) 78%, #d7b57b 22%);
}

.login-card .eyebrow {
  color: var(--accent);
}

.sidebar .muted {
  color: var(--sidebar-muted);
}

.sidebar h1,
.content h2,
.crew-card h3,
.print-group h2 {
  font-family: var(--font-serif);
  margin: 0;
}

.nav {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.sidebar-tools {
  margin-top: 24px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--sidebar-line);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08),
    var(--sidebar-surface)
  );
  color: var(--sidebar-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.theme-toggle-label {
  color: var(--sidebar-muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav a {
  padding: 12px 14px;
  border: 1px solid var(--sidebar-line);
  border-radius: 14px;
  background: var(--sidebar-surface);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background-color 0.2s ease;
}

.nav a:hover,
.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(215, 181, 123, 0.28);
  background: rgba(255, 255, 255, 0.12);
}

.nav-logout {
  margin: 0;
}

.nav-logout .button {
  width: 100%;
  border-color: var(--sidebar-line);
  background: var(--sidebar-surface);
  color: var(--sidebar-ink);
}

.content {
  padding: 34px;
  min-width: 0;
}

.panel,
.hero-card,
.stat-card,
.crew-card,
.flash {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  position: relative;
}

.hero-card,
.stat-card,
.crew-card,
.flash {
  overflow: hidden;
}

.panel {
  overflow: visible;
}

.panel::before,
.hero-card::before,
.stat-card::before,
.crew-card::before,
.flash::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.65),
    transparent
  );
  opacity: 0.45;
  pointer-events: none;
}

body[data-theme='dark'] .panel::before,
body[data-theme='dark'] .hero-card::before,
body[data-theme='dark'] .stat-card::before,
body[data-theme='dark'] .crew-card::before,
body[data-theme='dark'] .flash::before,
html[data-theme='dark'] body .panel::before,
html[data-theme='dark'] body .hero-card::before,
html[data-theme='dark'] body .stat-card::before,
html[data-theme='dark'] body .crew-card::before,
html[data-theme='dark'] body .flash::before {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(184, 212, 196, 0.22),
    transparent
  );
  opacity: 0.3;
}

body[data-theme='dark'] .panel,
body[data-theme='dark'] .hero-card,
body[data-theme='dark'] .stat-card,
body[data-theme='dark'] .crew-card,
body[data-theme='dark'] .flash,
html[data-theme='dark'] body .panel,
html[data-theme='dark'] body .hero-card,
html[data-theme='dark'] body .stat-card,
html[data-theme='dark'] body .crew-card,
html[data-theme='dark'] body .flash {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body[data-theme='dark'] .panel,
body[data-theme='dark'] .hero-card,
body[data-theme='dark'] .stat-card,
body[data-theme='dark'] .crew-card,
html[data-theme='dark'] body .panel,
html[data-theme='dark'] body .hero-card,
html[data-theme='dark'] body .stat-card,
html[data-theme='dark'] body .crew-card {
  background: rgba(18, 31, 28, 0.92);
}

.hero-card,
.split-layout,
.stats-grid {
  margin-bottom: 22px;
}

.hero-card {
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  background:
    radial-gradient(
      circle at top right,
      rgba(255, 217, 161, 0.16),
      transparent 24%
    ),
    linear-gradient(135deg, var(--panel-elevated), var(--panel));
}

.hero-actions,
.stats-grid,
.split-layout,
.filter-grid,
.form-grid {
  display: grid;
  gap: 16px;
}

.hero-actions {
  grid-template-columns: repeat(3, max-content);
}

.stats-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stat-card {
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 36%),
    var(--panel);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

body[data-theme='dark'] .stat-card,
html[data-theme='dark'] body .stat-card {
  background:
    linear-gradient(180deg, rgba(131, 179, 155, 0.08), transparent 34%),
    var(--panel);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-strong);
}

.stat-card span,
.eyebrow,
.muted,
.subline {
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.panel {
  padding: 22px;
}

.split-layout {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  align-items: start;
}

.split-layout > * {
  min-width: 0;
}

.form-panel-wide {
  max-width: 1100px;
}

.editor-panel-full {
  width: 100%;
  max-width: none;
}

#form-editor {
  display: grid;
  gap: 16px;
}

.form-items-wrap {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    var(--panel-strong)
  );
}

.editor-submit-actions {
  margin-top: 14px;
}

.editor-hero-actions {
  justify-content: flex-end;
}

#form-items-table {
  table-layout: fixed;
}

#form-items-table col.col-customer {
  width: 30%;
}

#form-items-table .customer-search-input {
  min-width: 260px;
}

.customer-ac-wrap {
  position: relative;
}

.customer-ac-list {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 200;
  background: var(--panel-elevated);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-strong);
  max-height: 260px;
  overflow-y: auto;
  min-width: 320px;
  width: max-content;
  padding: 4px 0;
  margin-top: 2px;
  list-style: none;
}

.customer-ac-list li {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
}

.customer-ac-list li:hover,
.customer-ac-list li.ac-active {
  background: var(--accent-soft);
}

.time-ac-wrap {
  position: relative;
}

.time-ac-list {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 210;
  background: var(--panel-elevated);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-strong);
  max-height: 220px;
  overflow-y: auto;
  width: 100%;
  min-width: 120px;
  padding: 4px 0;
  margin-top: 2px;
  list-style: none;
}

.time-ac-list li {
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.time-ac-list li:hover,
.time-ac-list li.ac-active {
  background: var(--accent-soft);
}

#form-items-table col.col-time {
  width: 8%;
}

#form-items-table col.col-disposal {
  width: 12%;
}

#form-items-table col.col-phone {
  width: 11%;
}

#form-items-table col.col-comment {
  width: 10%;
}

#form-items-table col.col-service-type {
  width: 11%;
}

#form-items-table col.col-description {
  width: 15%;
}

#form-items-table col.col-price {
  width: 8%;
}

#form-items-table col.col-vehicle {
  width: 11%;
}

#form-items-table col.col-action {
  width: 10%;
}

#form-items-table th,
#form-items-table td {
  padding-top: 10px;
  padding-bottom: 10px;
}

#form-items-table input,
#form-items-table select {
  min-height: 42px;
}

#form-items-table td:nth-child(2),
#form-items-table td:nth-child(8),
#form-items-table td:nth-child(10),
#form-items-table th:nth-child(2),
#form-items-table th:nth-child(8),
#form-items-table th:nth-child(10) {
  white-space: nowrap;
}

.stack-form,
.form-grid {
  margin-top: 18px;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid.compact-form {
  margin-top: 12px;
  gap: 10px 12px;
}

.form-grid.compact-form label span {
  margin-bottom: 4px;
  font-size: 0.86rem;
}

.form-grid.compact-form input,
.form-grid.compact-form select,
.form-grid.compact-form textarea {
  padding: 8px 10px;
  border-radius: 12px;
}

.form-grid.compact-form textarea {
  min-height: 82px;
}

.form-grid.compact-form .form-row-actions {
  margin-top: 4px;
  gap: 8px;
}

#form-editor .form-grid {
  margin-top: 10px;
  gap: 10px 12px;
}

#form-editor label span {
  margin-bottom: 4px;
  font-size: 0.86rem;
}

#form-editor input,
#form-editor select,
#form-editor textarea {
  padding: 8px 10px;
  border-radius: 12px;
}

#form-editor textarea {
  min-height: 82px;
}

#form-items-table th,
#form-items-table td {
  padding-top: 8px;
  padding-bottom: 8px;
}

#form-items-table input,
#form-items-table select {
  min-height: 36px;
  padding: 7px 9px;
}

.full-span {
  grid-column: 1 / -1;
}

label span {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 7px;
}

input,
select,
textarea,
button {
  width: 100%;
  font: inherit;
}

input,
select,
textarea {
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  background: var(--input-bg);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.nav a:focus-visible,
.theme-toggle:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, white 10%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

input.is-invalid {
  border-color: rgba(139, 46, 46, 0.8);
  box-shadow: 0 0 0 3px rgba(139, 46, 46, 0.12);
}

input.is-invalid:focus {
  outline: none;
  border-color: rgba(139, 46, 46, 0.95);
  box-shadow: 0 0 0 4px rgba(139, 46, 46, 0.18);
}

body[data-theme='dark'] input.is-invalid {
  border-color: rgba(255, 173, 173, 0.92);
  box-shadow: 0 0 0 3px rgba(239, 143, 143, 0.24);
}

body[data-theme='dark'] input.is-invalid:focus {
  border-color: rgba(255, 191, 191, 0.98);
  box-shadow: 0 0 0 4px rgba(255, 160, 160, 0.3);
}

textarea {
  resize: vertical;
}

/* Strong compact density for job form and form editor */
.form-grid.compact-form {
  margin-top: 8px;
  gap: 6px 4px;
}

.form-grid.compact-form label span,
#form-editor label span {
  margin-bottom: 2px;
  font-size: 0.84rem;
}

.form-grid.compact-form input,
.form-grid.compact-form select,
.form-grid.compact-form textarea,
#form-editor input,
#form-editor select,
#form-editor textarea {
  padding: 0 4px !important;
  border-radius: 10px;
  line-height: 42px;
  font-size: 1rem;
  min-height: 42px;
}

.form-grid.compact-form input::placeholder,
.form-grid.compact-form textarea::placeholder,
#form-editor input::placeholder,
#form-editor textarea::placeholder,
#form-editor #form-items-table input::placeholder {
  font-size: 1rem;
  opacity: 0.9;
  line-height: 42px;
}

.form-grid.compact-form textarea,
#form-editor textarea {
  min-height: 96px;
  line-height: 1.35;
  padding: 8px 4px !important;
}

#form-editor .form-grid {
  margin-top: 8px;
  gap: 6px 4px;
}

#form-editor #form-items-table th,
#form-editor #form-items-table td {
  padding-top: 4px;
  padding-bottom: 4px;
  padding-left: 2px;
  padding-right: 2px;
}

#form-editor #form-items-table input,
#form-editor #form-items-table select {
  min-height: 42px;
  height: 42px;
  padding: 0 4px !important;
  line-height: 42px;
  font-size: 1rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--button-bg);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.button:hover {
  transform: translateY(-1px);
  background: var(--button-hover);
  border-color: var(--line-strong);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.button-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-color: var(--accent);
  color: #fff;
}

.button-primary:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 86%, white 14%) 0%,
    color-mix(in srgb, var(--accent-2) 84%, white 16%) 100%
  );
  border-color: color-mix(in srgb, var(--accent) 86%, white 14%);
}

.button-sm {
  padding: 6px 12px;
  font-size: 0.9rem;
}

.button-danger {
  background: linear-gradient(135deg, #8b2e2e, #a03535);
  border-color: #8b2e2e;
  color: #fff;
}

.button-danger:hover {
  background: linear-gradient(135deg, #a63c3c, #b74747);
  border-color: #a63c3c;
}

.form-row-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.forms-filter-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.forms-filter-actions {
  justify-content: flex-start;
}

.quick-filter-actions {
  margin-bottom: 10px;
}

.forms-period-alert-panel,
.forms-period-alert-panel h3,
.forms-period-alert-panel th,
.forms-period-alert-panel td,
.forms-period-alert-panel .empty-state {
  color: var(--warn);
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 6px;
  align-items: center;
}

.forms-history-table {
  table-layout: fixed;
  min-width: 1000px;
}

.forms-history-table col.col-id {
  width: 6%;
}

.forms-history-table col.col-date {
  width: 10%;
}

.forms-history-table col.col-crew {
  width: 12%;
}

.forms-history-table col.col-comment {
  width: 12%;
}

.forms-history-table col.col-rows {
  width: 7%;
}

.forms-history-table col.col-created-by {
  width: 12%;
}

.forms-history-table col.col-created-at {
  width: 15%;
}

.forms-history-table col.col-actions {
  width: 24%;
}

.forms-history-table .cell-id,
.forms-history-table .cell-date,
.forms-history-table .cell-rows,
.forms-history-table .cell-created-at {
  white-space: nowrap;
}

.forms-history-table td {
  word-break: break-word;
}

.forms-history-table .actions-cell {
  white-space: normal;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.settings-table .col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: center;
}

.settings-table td.actions-cell {
  justify-content: center;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  border-radius: 18px;
}

.forms-scroll-top {
  display: block;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 4px 0 10px;
  border-radius: 10px;
  scrollbar-gutter: stable both-edges;
  height: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.forms-scroll-top-inner {
  height: 1px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.customers-table {
  width: 100%;
  min-width: 1100px;
}

.customers-table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable both-edges;
}

.customers-scroll-top {
  display: block;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 4px 0 10px;
  border-radius: 10px;
  scrollbar-gutter: stable both-edges;
}

.customers-scroll-top-inner {
  height: 1px;
}

.customers-scroll-top,
.customers-table-wrap {
  scrollbar-width: auto;
}

.customers-scroll-top::-webkit-scrollbar,
.customers-table-wrap::-webkit-scrollbar {
  height: 12px;
}

.customers-scroll-top::-webkit-scrollbar-thumb,
.customers-table-wrap::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent) 72%, transparent);
  border-radius: 999px;
}

.customers-table .actions-cell {
  min-width: 240px;
  white-space: nowrap;
}

.customers-table .actions-cell > * {
  flex: 0 0 auto;
}

.customers-table th:last-child,
.customers-table td:last-child {
  min-width: 240px;
}

tbody tr {
  background: var(--table-row);
}

tbody tr:nth-child(even) {
  background: var(--table-row-alt);
}

tbody tr:hover {
  background: color-mix(in srgb, var(--accent-soft) 52%, transparent);
}

th,
td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.customers-table th,
.customers-table td {
  padding: 10px 8px;
}

.customers-table .actions-cell {
  gap: 4px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 26px 12px;
}

.planning-alerts-panel .table-wrap {
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.planning-alerts-panel tbody tr {
  background: color-mix(in srgb, var(--panel-strong) 88%, transparent);
}

.planning-alerts-panel tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--panel-elevated) 84%, transparent);
}

body[data-theme='dark'] .planning-alerts-panel,
html[data-theme='dark'] body .planning-alerts-panel {
  background: var(--panel);
}

body[data-theme='dark'] .planning-alerts-panel .table-wrap,
html[data-theme='dark'] body .planning-alerts-panel .table-wrap {
  background: color-mix(in srgb, var(--panel-strong) 92%, #0d1715 8%);
}

body[data-theme='dark'] .planning-alerts-panel tbody tr,
html[data-theme='dark'] body .planning-alerts-panel tbody tr {
  background: rgba(28, 43, 38, 0.9);
}

body[data-theme='dark'] .planning-alerts-panel tbody tr:nth-child(even),
html[data-theme='dark'] body .planning-alerts-panel tbody tr:nth-child(even) {
  background: rgba(23, 36, 32, 0.94);
}

.crew-grid {
  display: grid;
  gap: 14px;
}

.crew-member-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.crew-member-column {
  display: grid;
  gap: 8px;
}

.crew-member-buttons {
  display: grid;
  gap: 8px;
}

.crew-member-picker select {
  min-height: 220px;
}

.crew-card {
  padding: 18px;
}

.flash-list {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.dispatch-item {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-wrap: anywhere;
}

.dispatch-conflict {
  color: var(--warn);
  font-weight: 700;
}

.audit-data {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.flash {
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08),
    var(--panel-strong)
  );
}

.flash-close {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  margin: -8px -10px -8px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 1.5rem;
  cursor: pointer;
}

body[data-theme='dark'] .flash,
html[data-theme='dark'] body .flash {
  background: linear-gradient(
    180deg,
    rgba(131, 179, 155, 0.06),
    var(--panel-strong)
  );
}

.flash-success {
  border-color: rgba(31, 93, 65, 0.2);
  color: var(--success);
}

.flash-error {
  border-color: rgba(139, 46, 46, 0.2);
  color: var(--warn);
}

body[data-theme='dark'] .flash-error,
html[data-theme='dark'] body .flash-error {
  color: #ffd6d6;
  border-color: rgba(255, 160, 160, 0.52);
  background: linear-gradient(
    180deg,
    rgba(122, 45, 45, 0.34),
    rgba(72, 26, 26, 0.48)
  );
}

body[data-theme='dark'] #customer-duplicate-hint,
body[data-theme='dark'] .customer-invalid-hint,
body[data-theme='dark'] .phone-missing-hint,
html[data-theme='dark'] body #customer-duplicate-hint,
html[data-theme='dark'] body .customer-invalid-hint,
html[data-theme='dark'] body .phone-missing-hint {
  color: #ffd6d6 !important;
  font-weight: 600;
}

.print-body {
  background: #fff;
  padding: 24px;
}

.print-preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: -24px -24px 24px;
  padding: 16px 24px;
  background: rgba(243, 239, 230, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.print-preview-toolbar strong,
.print-preview-toolbar span {
  display: block;
}

.print-preview-toolbar span {
  margin-top: 4px;
  color: var(--muted);
}

.print-header,
.print-group {
  margin-bottom: 28px;
}

.print-group table {
  table-layout: fixed;
  width: 100%;
}

.print-form {
  border: 2px solid #000;
}

.print-form thead tr {
  height: 40px;
}

.print-form tbody tr {
  height: 54px;
}

.print-group th,
.print-group td {
  font-size: 14px;
  padding: 10px 8px;
  word-wrap: break-word;
}

.print-form th,
.print-form td {
  border: 2px solid #000;
  color: #000;
  text-transform: none;
  letter-spacing: 0;
  vertical-align: top;
}

.print-form .empty-write-row td {
  background: #fff;
}

.print-group th:nth-child(1),
.print-group td:nth-child(1) {
  width: 3%;
}

.print-group th:nth-child(2),
.print-group td:nth-child(2) {
  width: 6%;
}

.print-group th:nth-child(3),
.print-group td:nth-child(3) {
  width: 8%;
}

.print-group th:nth-child(4),
.print-group td:nth-child(4) {
  width: 25%;
}

.print-group th:nth-child(5),
.print-group td:nth-child(5) {
  width: 13%;
}

.print-group th:nth-child(6),
.print-group td:nth-child(6) {
  width: 18%;
}

.print-group th:nth-child(7),
.print-group td:nth-child(7) {
  width: 10%;
}

.print-group th:nth-child(8),
.print-group td:nth-child(8) {
  width: 8%;
}

.print-group th:nth-child(9),
.print-group td:nth-child(9) {
  width: 9%;
}

.login-page {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  padding: 28px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08),
    var(--panel-elevated)
  );
  border: 1px solid var(--line);
  border-radius: 24px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-strong);
}

.content > * {
  animation: surface-enter 0.4s ease both;
}

@keyframes surface-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .content > *,
  .button,
  .nav a,
  .theme-toggle,
  .stat-card {
    animation: none;
    transition: none;
  }
}

.login-card h1 {
  margin: 0 0 8px 0;
  font-family: var(--font-serif);
}

@media (max-width: 1080px) {
  .page-shell,
  .split-layout,
  .stats-grid,
  .form-grid,
  .hero-actions {
    grid-template-columns: 1fr;
  }

  .crew-member-picker {
    grid-template-columns: 1fr;
  }

  .crew-member-buttons {
    grid-template-columns: 1fr 1fr;
  }

  .forms-filter-grid {
    grid-template-columns: 1fr;
  }

  .editor-hero-actions {
    justify-content: flex-start;
  }

  .sidebar {
    position: static;
    height: auto;
  }
}

@media (max-width: 900px) {
  #form-items-table {
    table-layout: auto;
  }

  .print-preview-toolbar {
    position: static;
    margin: -24px -24px 20px;
    padding: 14px 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .print-preview-toolbar .button {
    width: 100%;
  }

  .panel.form-panel-wide {
    padding: 16px;
  }

  #form-editor {
    gap: 12px;
  }

  .editor-submit-actions {
    margin-top: 8px;
  }

  .editor-submit-actions .button,
  .editor-hero-actions .button {
    width: 100%;
    justify-content: center;
  }

  #form-items-table thead {
    display: none;
  }

  #form-items-table,
  #form-items-table tbody,
  #form-items-table tr,
  #form-items-table td {
    display: block;
    width: 100%;
  }

  #form-items-table tr {
    border: 1px solid var(--line);
    border-radius: 16px;
    margin-bottom: 12px;
    background: var(--panel-strong);
    padding: 10px 12px;
  }

  #form-items-table td {
    border: 0;
    border-bottom: 1px dashed rgba(31, 77, 59, 0.16);
    padding: 10px 0;
  }

  #form-items-table td:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  #form-items-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 700;
  }

  #form-items-table .row-remove-cell {
    padding-top: 10px;
  }

  .form-items-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }

  html,
  body {
    height: auto;
    min-height: auto;
  }

  .print-preview-toolbar {
    display: none;
  }

  .print-body {
    padding: 0;
    height: auto;
    min-height: auto;
  }

  .print-group {
    break-inside: avoid;
    page-break-after: always;
  }

  .print-group:last-of-type {
    page-break-after: auto;
  }
}

/* Final lock: compact horizontal spacing + settings-like vertical field size */
.form-grid.compact-form {
  gap: 6px 4px !important;
}

#form-editor .form-grid {
  gap: 6px 4px !important;
}

.form-grid.compact-form input,
.form-grid.compact-form select,
#form-editor input,
#form-editor select {
  height: 46px !important;
  min-height: 46px !important;
  padding: 0 4px !important;
  line-height: 1.2 !important;
  font-size: 1rem !important;
}

.form-grid.compact-form textarea,
#form-editor textarea {
  min-height: 96px !important;
  padding: 10px 4px !important;
  line-height: 1.3 !important;
}

.form-grid.compact-form input::placeholder,
.form-grid.compact-form textarea::placeholder,
#form-editor input::placeholder,
#form-editor textarea::placeholder,
#form-editor #form-items-table input::placeholder {
  font-size: 1rem !important;
  line-height: 1.2 !important;
}

#form-editor #form-items-table th,
#form-editor #form-items-table td {
  padding-left: 2px !important;
  padding-right: 2px !important;
}

#form-editor #form-items-table input,
#form-editor #form-items-table select {
  height: 46px !important;
  min-height: 46px !important;
  padding: 0 4px !important;
  line-height: 1.2 !important;
  font-size: 1rem !important;
}

#form-editor .crew-member-picker select[multiple] {
  height: auto !important;
  min-height: 160px !important;
}

@media (max-width: 768px) {
  .sidebar {
    padding: 12px 16px;
  }

  .mobile-menu-toggle.is-ready {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: auto;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--sidebar-line);
    border-radius: 12px;
    background: var(--sidebar-surface);
    color: var(--sidebar-ink);
    cursor: pointer;
  }

  #sidebar-menu:not([hidden]) {
    padding-top: 16px;
  }

  .content {
    padding: 16px;
  }

  .panel,
  .hero-card {
    padding: 16px;
  }

  .hero-card {
    flex-direction: column;
    align-items: stretch;
  }

  .button-sm {
    min-height: 44px;
  }

  .form-grid.compact-form input:not([type='hidden']),
  .form-grid.compact-form select,
  #form-editor input:not([type='hidden']),
  #form-editor select,
  #form-editor #form-items-table input:not([type='hidden']),
  #form-editor #form-items-table select {
    min-height: 48px !important;
    height: 48px !important;
    padding: 0 12px !important;
  }

  .form-grid.compact-form textarea,
  #form-editor textarea {
    padding: 10px 12px !important;
  }

  #form-items-table .customer-search-input {
    min-width: 0;
  }

  .customer-ac-list {
    min-width: 0;
    width: 100%;
  }

  .customer-ac-list li {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  :is(.jobs-table, .mobile-card-table) thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  :is(.jobs-table, .mobile-card-table),
  :is(.jobs-table, .mobile-card-table) tbody,
  :is(.jobs-table, .mobile-card-table) tr,
  :is(.jobs-table, .mobile-card-table) td {
    display: block;
    width: 100%;
  }

  :is(.jobs-table, .mobile-card-table) tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 10px 12px;
  }

  :is(.jobs-table, .mobile-card-table) td {
    padding: 8px 0;
    overflow-wrap: anywhere;
  }

  :is(.jobs-table, .mobile-card-table) td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  .jobs-table .actions-cell {
    display: block;
    white-space: normal;
  }

  .jobs-table .actions-cell .button {
    margin: 4px 4px 0 0;
  }
}
