:root {
  color-scheme: light;
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #101828;
  --text-soft: #344054;
  --muted: #667085;
  --line: #e3e8ef;
  --line-strong: #cbd5e1;

  --brand: #0f6f5c;
  --brand-dark: #0a4f42;
  --brand-soft: #e5f4f0;

  --vacation: #b45309;
  --vacation-soft: #fdf1e2;
  --sick: #be123c;
  --sick-soft: #fde7ec;
  --holiday: #6d28d9;
  --holiday-soft: #efe8fc;

  --danger: #b42318;
  --danger-soft: #fef1f0;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 14px 34px rgba(16, 24, 40, 0.08);
  --focus: rgba(15, 111, 92, 0.22);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(1100px 480px at 12% -10%, rgba(15, 111, 92, 0.08), transparent),
    radial-gradient(900px 420px at 100% 0%, rgba(180, 83, 9, 0.06), transparent),
    var(--bg);
  color: var(--text);
  font-family: Inter, Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}

.app-shell {
  width: min(1360px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

/* Header */
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 14px;
  background: linear-gradient(150deg, var(--brand), var(--brand-dark));
  color: #ffffff;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-md);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  max-width: 620px;
}

.action-group {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.logout-form {
  margin: 0;
}

.session-user {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

/* Company switch */
.company-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 24px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.company-tab {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  padding: 0 18px;
  font-weight: 800;
}

.company-tab:hover {
  background: var(--surface-soft);
}

.company-tab.is-active {
  background: linear-gradient(150deg, var(--brand), var(--brand-dark));
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

/* Buttons */
.icon-button,
.primary-button,
.secondary-button,
.danger-button,
.link-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 800;
  letter-spacing: 0;
}

.icon-button {
  min-width: 78px;
  padding: 0 14px;
  border-radius: 7px;
  background: transparent;
  color: var(--text-soft);
}

.icon-button:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.gear-button {
  min-width: 40px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.icon-button-mini {
  min-height: 30px;
  min-width: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1;
}

.icon-button-mini:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

input:disabled,
select:disabled {
  background: var(--surface-soft);
  color: var(--muted);
  cursor: not-allowed;
}

.file-input {
  position: absolute;
  width: 1px !important;
  height: 1px;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.import-status {
  max-width: 210px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.primary-button {
  padding: 0 20px;
  min-height: 44px;
  background: linear-gradient(150deg, var(--brand), var(--brand-dark));
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(10, 79, 66, 0.22);
}

.primary-button:hover {
  filter: brightness(1.05);
}

.secondary-button {
  padding: 0 16px;
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
}

.secondary-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.link-button {
  justify-self: start;
  padding: 0;
  min-height: auto;
  border: none;
  background: transparent;
  color: var(--brand-dark);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-button:hover {
  color: var(--brand);
}

.danger-button {
  min-height: 30px;
  padding: 0 12px;
  border-color: rgba(180, 35, 24, 0.18);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
}

.danger-button:hover {
  border-color: var(--danger);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Overview grid */
.overview-grid {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.vehicle-card,
.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.vehicle-card {
  padding: 20px;
}

.vehicle-card h2 {
  color: var(--text-soft);
}

.vehicle-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.stat-card {
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 20px 22px;
}

.stat-card > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.stat-card > strong {
  font-size: 34px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
}

.stat-card--primary {
  background: linear-gradient(155deg, var(--brand), var(--brand-dark));
  border-color: transparent;
}

.stat-card--primary > span,
.stat-card--primary > p {
  color: rgba(255, 255, 255, 0.78);
}

.stat-card--primary > strong {
  color: #ffffff;
}

.stat-card--vacation > strong {
  color: var(--vacation);
}

.stat-card--sick > strong {
  color: var(--sick);
}

.stat-card--holiday > strong {
  color: var(--holiday);
}

/* Form fields */
label,
.total-box {
  display: grid;
  gap: 7px;
}

label span,
.compact-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
}

input:hover,
select:hover {
  border-color: var(--line-strong);
}

/* Workspace */
.workspace {
  margin-top: 20px;
}

.register-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.entry-form {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

/* Entry type switch */
.type-switch {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.type-option {
  min-height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
  padding: 0 8px;
}

.type-option:hover {
  background: rgba(15, 24, 40, 0.04);
}

.type-option.is-active {
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.type-option[data-entry-type="work"].is-active {
  background: linear-gradient(150deg, var(--brand), var(--brand-dark));
}

.type-option[data-entry-type="vacation"].is-active {
  background: var(--vacation);
}

.type-option[data-entry-type="sick"].is-active {
  background: var(--sick);
}

.type-option[data-entry-type="holiday"].is-active {
  background: var(--holiday);
}

.field-group {
  display: grid;
  gap: 14px;
}

.field-group[hidden] {
  display: none;
}

.field-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

/* Register / table */
.register-panel {
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.table-toolbar p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.compact-field {
  min-width: 190px;
}

.table-scroll {
  position: relative;
  max-height: calc(100vh - 380px);
  min-height: 360px;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 16px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #ffffff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--line-strong);
}

td {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
}

td:nth-child(4),
th:nth-child(4) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.entry-row td {
  background: #ffffff;
  transition: background 0.12s ease;
}

.entry-row.is-alt td {
  background: var(--surface-soft);
}

.entry-row:hover td {
  background: var(--brand-soft);
}

.entry-row td:first-child {
  font-weight: 700;
  color: var(--text);
  border-left: 3px solid transparent;
}

.entry-row.is-vacation td:first-child {
  border-left-color: var(--vacation);
}

.entry-row.is-sick td:first-child {
  border-left-color: var(--sick);
}

.entry-row.is-holiday td:first-child {
  border-left-color: var(--holiday);
}

.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12.5px;
  font-weight: 800;
}

.type-badge--vacation {
  background: var(--vacation-soft);
  color: var(--vacation);
}

.type-badge--sick {
  background: var(--sick-soft);
  color: var(--sick);
}

.type-badge--holiday {
  background: var(--holiday-soft);
  color: var(--holiday);
}

/* Month header: the strongest band in the table */
.month-group-row td {
  padding: 0;
  border-bottom: none;
  background: linear-gradient(150deg, var(--brand), var(--brand-dark));
}

.month-group-row .group-heading {
  padding: 14px 20px;
}

.month-group-row .group-heading strong {
  color: #ffffff;
  font-size: 14.5px;
  letter-spacing: 0.01em;
}

.month-group-row .group-heading span {
  color: rgba(255, 255, 255, 0.82);
}

/* Week header: a light brand-tinted sub-band nested under the month */
.week-group-row td {
  padding: 0;
  border-bottom: none;
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}

.week-group-row .group-heading {
  padding: 10px 20px 10px 30px;
  position: relative;
}

.week-group-row .group-heading::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--brand);
  transform: translateY(-50%);
}

.week-group-row .group-heading strong {
  color: var(--brand-dark);
}

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

.group-heading strong {
  font-size: 13px;
  font-weight: 900;
  color: var(--text);
}

.group-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

/* Summary rows: the total that closes out a group */
.month-summary-row td,
.week-summary-row td {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.month-summary-row td:nth-child(4),
.week-summary-row td:nth-child(4) {
  color: var(--brand-dark);
  text-align: right;
  font-size: 14.5px;
}

.week-summary-row td {
  background: #ffffff;
  border-bottom: 2px solid var(--brand);
}

.week-summary-row td:first-child {
  box-shadow: inset 3px 0 0 var(--brand);
}

.month-summary-row td {
  background: var(--brand-soft);
  border-bottom: 3px solid var(--brand);
}

.actions-cell {
  width: 90px;
  text-align: center;
}

.empty-state {
  display: none;
  margin: 0;
  padding: 32px 16px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.empty-state.is-visible {
  display: block;
}

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

/* Settings modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 24, 40, 0.45);
  backdrop-filter: blur(2px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-panel {
  width: min(100%, 560px);
  max-height: min(720px, calc(100vh - 48px));
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  padding: 24px;
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.account-slots {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.account-slot {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 16px;
}

.account-slot-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-slot-heading strong {
  font-size: 14.5px;
  font-weight: 900;
}

.account-slot-status {
  border-radius: 999px;
  padding: 2px 10px;
  background: var(--line);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.account-slot-status--active {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.account-slot-meta {
  margin: 10px 0 12px;
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 600;
}

.account-slot-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

/* Auth screens */
.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 480px at 15% -10%, rgba(15, 111, 92, 0.12), transparent),
    var(--bg);
}

.auth-panel {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  padding: 28px;
}

.auth-panel h1 {
  font-size: 28px;
}

.auth-meta {
  margin: 10px 0 20px;
  color: var(--muted);
  font-weight: 600;
}

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

.auth-form .primary-button {
  width: 100%;
  margin-top: 4px;
}

.alert {
  border-radius: var(--radius-sm);
  margin: 0 0 16px;
  padding: 12px 14px;
  font-weight: 700;
}

.alert-danger {
  border: 1px solid rgba(180, 35, 24, 0.2);
  background: var(--danger-soft);
  color: var(--danger);
}

@media (max-width: 1180px) {
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 980px) {
  .header-actions {
    justify-content: flex-start;
    max-width: none;
  }

  .vehicle-fields {
    grid-template-columns: 1fr;
  }

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

  .table-controls {
    width: 100%;
    justify-content: stretch;
  }

  .compact-field {
    width: 100%;
  }

  .table-scroll {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1360px);
    padding-top: 18px;
  }

  .stat-row {
    grid-template-columns: 1fr;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    font-size: 14px;
  }

  .company-switch {
    align-items: stretch;
    flex-direction: column;
  }

  .company-tab {
    flex: 1;
  }

  .group-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .group-heading span {
    text-align: left;
  }

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

  .modal-overlay {
    padding: 12px;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .header-actions,
  .company-switch,
  .logout-form,
  .session-user,
  .modal-overlay,
  .compact-field,
  .actions-column,
  .actions-cell {
    display: none;
  }

  .overview-grid,
  .register-panel {
    box-shadow: none;
  }

  .stat-card--primary {
    background: none;
    border: 1px solid var(--line);
  }

  .stat-card--primary > span,
  .stat-card--primary > p {
    color: var(--muted);
  }

  .stat-card--primary > strong {
    color: var(--text);
  }

  .workspace {
    display: block;
  }

  .table-scroll {
    max-height: none;
    overflow: visible;
  }

  table {
    min-width: 0;
  }
}
