:root {
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f171b;
  --panel: #182329;
  --ink: #edf4f2;
  --muted: #9aabae;
  --line: #35454c;
  --brand: #70d5b8;
  --brand-2: #193d34;
  --danger: #ff8f8f;
  --shadow: 0 10px 32px rgba(0, 0, 0, .28);
  color-scheme: dark;
}

body,
input,
select,
textarea,
.panel,
.stat,
.table-wrap,
.schedule-wrap,
.filters,
.auth-card,
.version {
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ui-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.topbar {
  gap: .7rem;
}

.topbar nav,
.header-tools,
.user-menu {
  display: flex;
  align-items: center;
  gap: .3rem;
}

.topbar nav {
  gap: .25rem;
}

.header-tools {
  margin-left: auto;
}

.header-icon,
button.header-icon {
  position: relative;
  display: inline-flex;
  flex: 0 0 38px;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #dcece8;
  line-height: 1;
}

.notification-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 2px solid #102d28;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  line-height: 14px;
  text-align: center;
}

.notification-count[hidden] {
  display: none;
}

.header-icon:hover,
.header-icon:focus-visible,
button.header-icon:hover,
button.header-icon:focus-visible {
  border-color: rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .1);
  color: #fff;
  text-decoration: none;
  outline: none;
}

.brand {
  color: #fff !important;
}

.brand .ui-icon {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

.global-search {
  position: relative;
  margin-left: 0;
}

.global-search .ui-icon {
  position: absolute;
  z-index: 1;
  top: 9px;
  left: 9px;
  width: 18px;
  height: 18px;
  color: #b9cdc8;
}

.global-search input {
  width: 38px;
  padding-right: 8px;
  padding-left: 34px;
  color: transparent;
  transition: width .18s ease, color .18s ease;
}

.global-search input::placeholder {
  opacity: 0;
}

.global-search input:focus,
.global-search input:not(:placeholder-shown) {
  width: 180px;
  color: #fff;
}

.global-search input:focus::placeholder {
  opacity: 1;
}

.user-menu form {
  display: flex;
}

.theme-icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-icon-sun {
  display: block;
}

.schedule-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

:root[data-theme="dark"] .topbar {
  background: #091f1b;
}

:root[data-theme="dark"] .notification-count {
  border-color: #091f1b;
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .button.secondary,
:root[data-theme="dark"] .filters,
:root[data-theme="dark"] .table-wrap,
:root[data-theme="dark"] .schedule-wrap,
:root[data-theme="dark"] .legend span,
:root[data-theme="dark"] .version,
:root[data-theme="dark"] .auth-card {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

:root[data-theme="dark"] button:not(.header-icon):not(.dialog-close):not(.shift-edit):not(.phase-step),
:root[data-theme="dark"] .button:not(.secondary) {
  background: #277763;
  color: #fff;
}

:root[data-theme="dark"] .button.secondary {
  color: var(--brand);
}

:root[data-theme="dark"] .notification-open {
  background: transparent;
  color: var(--ink);
}

:root[data-theme="dark"] .color-preset {
  background: transparent;
  color: inherit;
}

:root[data-theme="dark"] .color-preset:hover,
:root[data-theme="dark"] .color-preset:focus-visible,
:root[data-theme="dark"] .color-preset[aria-pressed="true"] {
  background: var(--panel);
}

:root[data-theme="dark"] .danger-button,
:root[data-theme="dark"] button.danger-button {
  background: #9b4141;
}

:root[data-theme="dark"] thead th,
:root[data-theme="dark"] .schedule-table thead .sticky-name {
  background: #243239;
  color: #b8c7ca;
}

:root[data-theme="dark"] tbody tr:hover {
  background: #1d2a30;
}

:root[data-theme="dark"] .schedule-table .sticky-name {
  background: var(--panel);
}

:root[data-theme="dark"] .shift-cell {
  background: color-mix(in srgb, var(--shift-color, var(--panel)) 30%, var(--panel));
}

:root[data-theme="dark"] .badge {
  background: #2b3a41;
  color: #c0ced1;
}

:root[data-theme="dark"] .badge.published,
:root[data-theme="dark"] .badge.success {
  background: #174a3c;
  color: #9be4ca;
}

:root[data-theme="dark"] .badge.review {
  background: #4a3d19;
  color: #f0d88a;
}

:root[data-theme="dark"] .badge.conflict,
:root[data-theme="dark"] .badge.danger {
  background: #4b2528;
  color: #ffb0b0;
}

:root[data-theme="dark"] .alert {
  border-color: #74612e;
  background: #382f18;
  color: #f0dda0;
}

:root[data-theme="dark"] .version pre {
  background: #0b1114;
}

:root[data-theme="dark"] .schedule-viewbar,
:root[data-theme="dark"] .employee-picker summary,
:root[data-theme="dark"] .employee-picker-panel,
:root[data-theme="dark"] .group-picker summary,
:root[data-theme="dark"] .group-picker-panel,
:root[data-theme="dark"] .month-picker summary,
:root[data-theme="dark"] .month-picker-panel,
:root[data-theme="dark"] .phase-group,
:root[data-theme="dark"] .filter-panel,
:root[data-theme="dark"] .calculation-help,
:root[data-theme="dark"] .schedule-statistics,
:root[data-theme="dark"] .schedule-sheet,
:root[data-theme="dark"] .settings-heading,
:root[data-theme="dark"] .settings-footer,
:root[data-theme="dark"] .settings-section,
:root[data-theme="dark"] .settings-dialog,
:root[data-theme="dark"] .shift-dialog {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

:root[data-theme="dark"] .employee-options,
:root[data-theme="dark"] .employee-options > label,
:root[data-theme="dark"] .group-options,
:root[data-theme="dark"] .group-options > label,
:root[data-theme="dark"] .month-options,
:root[data-theme="dark"] .participant-fieldset,
:root[data-theme="dark"] .participant-group-list label,
:root[data-theme="dark"] .participant-employee-list label,
:root[data-theme="dark"] .phase-group {
  border-color: var(--line);
}

:root[data-theme="dark"] .employee-options > label:hover,
:root[data-theme="dark"] .group-options > label:hover {
  background: #223138;
}

:root[data-theme="dark"] .phase-slot,
:root[data-theme="dark"] .settings-content {
  border-color: var(--line);
  background: var(--bg);
}

:root[data-theme="dark"] .phase-day,
:root[data-theme="dark"] .schedule-table thead th {
  background: #243239;
  color: var(--ink);
}

:root[data-theme="dark"] .phase-step {
  background: #2b3b42;
  color: var(--ink);
}

:root[data-theme="dark"] .month-column {
  border-color: #60727a !important;
  background: #293940 !important;
}

:root[data-theme="dark"] .schedule-table .month-start {
  border-left-color: #60727a;
}

:root[data-theme="dark"] .schedule-table .date-column small {
  color: #a0b1b5;
}

:root[data-theme="dark"] .schedule-table .date-column.calendar-day-off {
  background: #542a35;
  color: #fecdd3;
}

:root[data-theme="dark"] .schedule-table .date-column.calendar-weekend {
  box-shadow: inset 0 3px #fb7185;
}

:root[data-theme="dark"] .schedule-table .date-column.official-holiday {
  background: #7f1d1d;
  color: #fee2e2;
  box-shadow: inset 0 4px #f87171, inset 0 -3px #f87171;
}

:root[data-theme="dark"] .schedule-table .date-column.calendar-shortened {
  box-shadow: inset 0 3px #fbbf24;
}

:root[data-theme="dark"] .shortened-day-marker {
  color: #fcd34d;
}

:root[data-theme="dark"] .shift-cell.state-day_off {
  color: #b6c4cb;
}

:root[data-theme="dark"] .schedule-table .shift-cell.calendar-day-off {
  border-right-color: #9f475d;
  box-shadow: inset 1px 0 #be647a, inset -1px 0 #be647a, inset 0 -2px var(--shift-color, transparent);
}

:root[data-theme="dark"] .schedule-table .shift-cell.official-holiday {
  border-right-color: #f87171;
  box-shadow: inset 2px 0 #f87171, inset -2px 0 #f87171, inset 0 -2px var(--shift-color, transparent);
}

:root[data-theme="dark"] .schedule-table .sticky-name {
  background: var(--panel);
}

:root[data-theme="dark"] .schedule-table thead .sticky-name {
  background: #243239;
}

:root[data-theme="dark"] .schedule-table th,
:root[data-theme="dark"] .schedule-table td,
:root[data-theme="dark"] .schedule-sheet,
:root[data-theme="dark"] .schedule-viewbar,
:root[data-theme="dark"] .schedule-statistics {
  border-color: #405159;
}

:root[data-theme="dark"] .schedule-table tbody tr:hover .sticky-name,
:root[data-theme="dark"] .schedule-table tbody tr:hover td {
  filter: brightness(1.08);
}

:root[data-theme="dark"] .dialog-close,
:root[data-theme="dark"] .shift-edit {
  background: transparent;
  color: inherit;
}

@media (max-width: 640px) {
  .header-tools {
    gap: .15rem;
  }

  .header-icon,
  button.header-icon {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
    min-height: 34px;
  }

  .global-search input {
    width: 34px;
  }

  .global-search input:focus,
  .global-search input:not(:placeholder-shown) {
    width: 130px;
  }
}
