:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --border: #dce2ea;
  --text: #16191d;
  --text-muted: #667085;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --accent-ink: #ffffff;
  --ok: #16803a;
  --ok-bg: #e5f6eb;
  --warn: #a15c07;
  --warn-bg: #fff2d9;
  --danger: #c92f37;
  --danger-bg: #fde8ea;
  --prefer: #16803a;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgb(22 25 29 / 5%);
  --shadow-raised: 0 8px 24px rgb(22 25 29 / 10%);
  --tap: 44px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  min-height: var(--tap);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

input,
select {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgb(37 99 235 / 18%);
  border-color: var(--accent);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 0 rgb(22 25 29 / 2%);
}

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

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 30px;
  overflow: hidden;
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  display: flex;
  align-items: baseline;
  min-width: 0;
  gap: 8px;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.1;
}

.brand-week {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-week:empty {
  display: none;
}

.app-menu {
  position: relative;
  flex: 0 0 auto;
}

.app-menu summary {
  list-style: none;
}

.app-menu summary::-webkit-details-marker {
  display: none;
}

.app-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  display: grid;
  width: min(260px, calc(100vw - 32px));
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.app-menu-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 44px;
  width: 100%;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: left;
}

.app-menu-item.active,
.app-menu-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.app-menu-logout {
  margin-top: 6px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 7px 7px;
  color: var(--danger);
}

.app-menu-icon {
  color: var(--text-muted);
  text-align: center;
  font-size: 17px;
}

.top-tabs {
  display: flex;
  gap: 4px;
  margin-left: 4px;
}

.tab-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

.tab-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.top-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
}

.icon-btn:hover {
  border-color: var(--border);
  background: var(--accent-soft);
  color: var(--accent);
}

.app-main {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 16px 16px 32px;
}

body.login-mode .topbar,
body.login-mode .tabbar {
  display: none;
}

body.login-mode .app-main {
  width: 100%;
  padding: 0;
}

.screen {
  display: grid;
  gap: 14px;
}

.screen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.sticky-actions {
  position: sticky;
  top: 56px;
  z-index: 15;
  margin-top: -6px;
  padding: 8px 0;
  border-bottom: 1px solid rgb(218 224 232 / 72%);
  background: rgb(246 248 251 / 94%);
  backdrop-filter: blur(10px);
}

.screen-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
}

.screen-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

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

.week-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.week-nav [data-action="prev-week"],
.week-nav [data-action="next-week"] {
  min-width: 52px;
  border-color: #c8d2df;
  background: var(--surface-2);
  color: var(--text);
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}

.week-nav [data-action="prev-week"]:hover,
.week-nav [data-action="next-week"]:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.plan-actions {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, auto));
  gap: 8px;
  align-items: center;
}

.today-btn {
  flex-direction: column;
  gap: 1px;
  min-width: 104px;
  padding: 4px 12px;
  line-height: 1.05;
}

.today-btn small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.today-btn.is-current {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 14%);
}

.today-btn.is-current small {
  color: var(--accent-ink);
  opacity: 0.9;
}

.toolbar-menu {
  position: relative;
  flex: 0 0 auto;
}

.toolbar-menu summary {
  list-style: none;
  cursor: pointer;
}

.toolbar-menu summary.btn::after {
  content: "⌄";
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 900;
}

.toolbar-menu[open] summary.btn {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.toolbar-menu summary::-webkit-details-marker {
  display: none;
}

.toolbar-menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  display: grid;
  gap: 6px;
  width: min(240px, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.toolbar-menu-panel .btn {
  justify-content: flex-start;
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 80ms ease;
}

.btn:hover {
  border-color: #c8d2df;
  background: var(--surface-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.icon-btn:focus-visible,
.app-menu-item:focus-visible,
.tab-link:focus-visible {
  outline: 3px solid rgb(37 99 235 / 20%);
  outline-offset: 2px;
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 5px 14px rgb(37 99 235 / 20%);
}

.btn-primary:hover {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: var(--accent-ink);
}

.today-btn.is-current,
.today-btn.is-current:hover,
.today-btn.is-current:active,
.today-btn.is-current:focus-visible {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 14%);
}

.today-btn.is-current small {
  color: var(--accent-ink);
  opacity: 0.9;
}

.danger-btn {
  border-color: rgb(201 47 55 / 28%);
  background: var(--danger-bg);
  color: var(--danger);
}

.danger-btn:hover {
  border-color: var(--danger);
  background: #fbd4d8;
  color: var(--danger);
}

.chip,
.status-chip,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-chip.danger {
  border-color: rgb(201 47 55 / 22%);
  background: var(--danger-bg);
  color: var(--danger);
}

.status-chip.warn {
  border-color: rgb(161 92 7 / 22%);
  background: var(--warn-bg);
  color: var(--warn);
}

.status-chip.ok {
  border-color: rgb(22 128 58 / 22%);
  background: var(--ok-bg);
  color: var(--ok);
}

.status-chip:hover {
  box-shadow: 0 0 0 3px rgb(22 25 29 / 5%);
}

.area-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 30px;
  margin: 1px 4px 1px 0;
  padding: 0 10px;
  border: 1px solid var(--area-color, var(--accent));
  border-radius: 999px;
  background: var(--area-bg, var(--surface-2));
  color: var(--area-color, var(--accent));
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.placeholder {
  padding: 20px;
  color: var(--text-muted);
}

.week-shell {
  display: grid;
  gap: 14px;
}

.day-pager {
  display: none;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.day-card {
  min-width: 0;
  padding: 10px;
}

.day-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}

.day-name span:nth-child(2) {
  color: var(--text-muted);
  font-size: 12px;
}

.problem-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
}

.period-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.shift-card {
  display: grid;
  width: 100%;
  text-align: left;
  gap: 5px;
  min-height: 74px;
  margin-top: 8px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--ok);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.shift-card:hover {
  border-color: #c8d2df;
  border-left-color: var(--ok);
  box-shadow: 0 3px 10px rgb(22 25 29 / 7%);
}

.shift-card.open {
  border-style: dashed;
  border-left-style: solid;
  border-left-color: var(--danger);
  background: linear-gradient(0deg, rgb(201 47 55 / 3%), rgb(201 47 55 / 3%)), var(--surface);
  color: var(--danger);
}

.shift-card.conflict {
  border-left-color: var(--warn);
  background: linear-gradient(0deg, rgb(161 92 7 / 4%), rgb(161 92 7 / 4%)), var(--surface);
}

.shift-card.flash {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.rest-day,
.onboarding {
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.people-list {
  display: grid;
  gap: 8px;
}

.person-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px;
  text-align: left;
  color: var(--text);
}

.person-row:hover {
  border-color: #c8d2df;
  box-shadow: 0 3px 10px rgb(22 25 29 / 6%);
}

.person-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.person-title-line {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) minmax(0, auto) auto auto auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.person-title-line strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-area-line {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.person-area-line {
  min-width: 0;
  justify-content: flex-start;
  overflow: hidden;
}

.person-area-line .area-tag {
  min-height: 22px;
  padding: 0 8px;
  font-size: 12px;
}

.person-count-inline {
  color: var(--text-muted);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 13px;
}

.person-status-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.person-status-inline.ok {
  border-color: rgb(22 128 58 / 22%);
  background: var(--ok-bg);
  color: var(--ok);
}

.person-status-inline.away {
  border-color: rgb(201 47 55 / 22%);
  background: var(--danger-bg);
  color: var(--danger);
}

.person-edit-btn {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.person-editor {
  display: grid;
  gap: 14px;
}

dialog.person-editor-dialog {
  width: min(680px, calc(100vw - 32px));
  max-width: 680px;
}

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

.field-label {
  display: grid;
  gap: 7px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
}

textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.preset-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.area-choice-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.check-pill input {
  width: auto;
  min-height: auto;
}

.check-pill:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.check-pill.area-check-pill {
  margin: 0;
  background: var(--surface);
  color: var(--text);
}

.check-pill.area-check-pill input {
  accent-color: var(--area-color, var(--accent));
}

.check-pill.area-check-pill:has(input:checked) {
  border-color: var(--area-color, var(--accent));
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--area-color, var(--accent));
}

.check-pill.compact {
  min-height: 36px;
  padding: 0 8px;
  font-size: 12px;
}

.hours-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 8px;
}

.availability-head {
  display: grid;
  gap: 10px;
}

.availability-grid {
  display: grid;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  padding-bottom: 2px;
}

.availability-col-head,
.availability-day {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.availability-day {
  text-align: left;
}

.absence-toggle,
.availability-time {
  box-sizing: border-box;
  min-width: 0;
  min-height: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
}

.absence-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 9px;
  background: var(--surface);
}

.absence-toggle input {
  width: auto;
  min-height: auto;
}

.availability-time {
  width: 100%;
  height: var(--tap);
  padding: 0 8px;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  text-align: center;
}

.availability-time::-webkit-datetime-edit {
  padding: 0;
}

.availability-time:disabled {
  background: #f3f5f8;
  color: transparent;
  opacity: 0.75;
}

.absence-toggle.checked {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  box-shadow: inset 0 0 0 1px rgb(201 47 55 / 10%);
}

.danger-btn {
  color: var(--danger);
}

.settings-section {
  display: grid;
  gap: 12px;
  padding: 14px;
}

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

.section-head h2 {
  margin: 0;
  font-size: 17px;
}

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

.settings-list {
  display: grid;
  gap: 8px;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 40px 40px auto;
  gap: 8px;
  align-items: center;
}

.settings-row.area-row {
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  padding: 6px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--area-color, var(--accent));
  border-radius: 8px;
  background: linear-gradient(90deg, var(--area-bg, transparent), transparent 42%), var(--surface);
}

.add-area-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.area-color-button {
  width: 44px;
  min-width: 44px;
  min-height: var(--tap);
  padding: 0;
  border: 3px solid var(--surface);
  border-radius: 999px;
  background: var(--area-color, var(--accent));
  cursor: pointer;
  box-shadow: 0 0 0 1px rgb(22 25 29 / 10%), inset 0 0 0 1px rgb(255 255 255 / 45%);
}

.danger-icon {
  color: var(--danger);
}

.requirements-list {
  display: grid;
  gap: 12px;
}

.requirement-day {
  display: grid;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
}

.requirement-day-head {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 7px;
}

.requirement-day-head h2 {
  margin: 0;
  font-size: 17px;
}

.requirement-day-head span {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.requirement-grid {
  display: grid;
  gap: 8px;
  overflow-x: auto;
  align-items: center;
  padding-bottom: 3px;
}

.requirement-grid.compact {
  padding-top: 2px;
}

.requirement-head,
.requirement-area-name {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.requirement-head {
  text-align: left;
}

.requirement-area-name {
  align-self: center;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.requirement-area-name.is-zero {
  opacity: 0.58;
}

.requirement-area-name.is-zero .area-tag {
  border-color: var(--border);
  background: #f3f5f8;
  color: var(--text-muted);
}

.requirement-stepper {
  display: grid;
  grid-template-columns: 34px minmax(26px, 1fr) 34px;
  align-items: center;
  gap: 4px;
  min-width: 92px;
}

.requirement-stepper .btn {
  min-height: 36px;
  padding: 0;
  font-size: 18px;
  font-weight: 900;
}

.requirement-stepper .requirement-minus {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 10px rgb(201 47 55 / 16%);
}

.requirement-stepper .requirement-plus {
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
  box-shadow: 0 4px 10px rgb(22 128 58 / 16%);
}

.requirement-stepper .requirement-minus:hover {
  border-color: #a9242c;
  background: #a9242c;
}

.requirement-stepper .requirement-plus:hover {
  border-color: #11682f;
  background: #11682f;
}

.requirement-stepper.is-zero .requirement-minus {
  border-color: var(--border);
  background: #eef1f5;
  color: #9aa4b2;
  box-shadow: none;
}

.requirement-stepper.is-zero .requirement-minus:hover {
  border-color: var(--border);
  background: #eef1f5;
}

.requirement-stepper output {
  display: grid;
  place-items: center;
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #f8fafc;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.requirement-stepper.is-zero output {
  border-style: dashed;
  background: #f3f5f8;
  color: var(--text-muted);
}

dialog.absence-dialog {
  width: min(460px, calc(100vw - 24px));
  max-width: 460px;
}

.absence-slots {
  display: grid;
  gap: 8px;
}

.absence-day {
  display: grid;
  grid-template-columns: 44px repeat(auto-fit, minmax(96px, 1fr));
  align-items: center;
  gap: 8px;
}

.matrix-cell,
.stepper {
  min-height: var(--tap);
}

.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(360px, 100%);
  padding: 24px;
}

.login-card form {
  display: grid;
  gap: 12px;
}

.login-logo {
  display: block;
  width: min(170px, 70vw);
  height: auto;
  margin: 0 auto 10px;
}

.tabbar {
  display: none;
}

.print-title {
  display: none;
}

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop {
  background: rgb(22 25 29 / 32%);
}

.dialog-body {
  display: grid;
  gap: 14px;
  min-width: min(420px, 86vw);
}

.dialog-body h2 {
  margin: 0;
  font-size: 17px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.summary-metric {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.summary-metric strong {
  font-size: 32px;
}

.summary-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.summary-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

dialog.sheet {
  width: min(420px, calc(100vw - 24px));
  max-width: 420px;
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  box-shadow: 0 18px 60px rgb(22 25 29 / 20%);
}

.sheet-body {
  display: grid;
  gap: 14px;
  max-height: inherit;
  overflow: auto;
  padding: 16px;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.candidate-search {
  margin-top: 2px;
}

.candidate-list {
  display: grid;
  gap: 14px;
}

.candidate-section {
  display: grid;
  gap: 8px;
}

.candidate-section h3 {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.candidate-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.candidate-row.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px rgb(37 99 235 / 12%);
}

.candidate-row input {
  width: auto;
  min-height: auto;
}

.candidate-main {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.candidate-main strong,
.candidate-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-main span {
  color: var(--text-muted);
  font-size: 13px;
}

.candidate-reason {
  justify-self: end;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.candidate-reason.ok {
  color: var(--ok);
}

.candidate-reason.warn {
  color: var(--warn);
}

.sheet-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}

.color-dialog {
  width: min(420px, calc(100vw - 24px));
}

.color-picker-body {
  display: grid;
  place-items: center;
  min-height: 120px;
}

.color-spectrum {
  width: 86px;
  min-width: 86px;
  height: 86px;
  min-height: 86px;
  padding: 5px;
  border-radius: 999px;
  cursor: pointer;
  background: var(--surface);
}

.color-spectrum::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-spectrum::-webkit-color-swatch {
  border: 0;
  border-radius: 999px;
}

.color-spectrum::-moz-color-swatch {
  border: 0;
  border-radius: 999px;
}

.link-btn {
  min-height: var(--tap);
  padding: 0;
  background: transparent;
  color: var(--accent);
  text-align: left;
  font-weight: 700;
}

dialog.problem-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(390px, 100vw);
  max-width: 390px;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  border-width: 0 0 0 1px;
  border-radius: 0;
}

.problem-list {
  display: grid;
  gap: 16px;
}

.problem-section {
  display: grid;
  gap: 8px;
}

.problem-section h3 {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.problem-row {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  background: var(--surface);
}

.problem-section:first-child .problem-row {
  border-left-color: var(--danger);
}

.problem-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.problem-main strong,
.problem-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.problem-main span {
  color: var(--text-muted);
  font-size: 13px;
}

.problem-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.problem-actions .btn {
  min-height: 38px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  max-width: min(420px, calc(100vw - 24px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: var(--surface);
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  box-shadow: var(--shadow-raised);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 699px) {
  .topbar {
    min-height: 54px;
  }

  .sticky-actions {
    top: 54px;
  }

  .top-tabs,
  .top-actions {
    display: none;
  }

  .app-main {
    padding: 14px 12px calc(78px + env(safe-area-inset-bottom));
  }

  .toolbar {
    width: 100%;
  }

  .toolbar .btn {
    flex: 1 1 100%;
  }

  .plan-actions {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .plan-actions .btn {
    min-width: 0;
    width: 100%;
    padding-inline: 8px;
    white-space: normal;
  }

  .toolbar-menu {
    flex: 1 1 calc(50% - 4px);
  }

  .toolbar > [data-action="save-requirements"] {
    flex: 1 1 calc(50% - 4px);
  }

  .toolbar-menu > .btn,
  .toolbar-menu summary.btn {
    width: 100%;
  }

  .toolbar-menu-panel {
    right: auto;
    left: 0;
  }

  .toolbar-menu-panel .btn {
    flex: 0 0 auto;
  }

  .week-nav {
    width: 100%;
  }

  .week-nav .btn {
    flex: 0 0 auto;
  }

  .week-nav [data-action="today"] {
    flex: 1 1 auto;
  }

  .person-editor {
    min-height: calc(100vh - 96px);
  }

  .person-row {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    min-height: 0;
    padding: 9px;
  }

  .person-title-line {
    grid-template-columns: minmax(58px, 1fr) minmax(34px, auto) auto auto auto;
    gap: 6px;
  }

  .person-status-inline {
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
  }

  .person-edit-btn {
    min-height: 30px;
    padding: 0 8px;
    font-size: 12px;
  }

  .person-area-line {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .person-area-line::-webkit-scrollbar {
    display: none;
  }

  .person-area-line .area-tag {
    min-height: 22px;
    padding: 0 7px;
    font-size: 11px;
  }

  .preset-bar .btn {
    flex: 1 1 auto;
  }

  .add-area-form {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .settings-row.area-row {
    grid-template-columns: 40px minmax(0, 1fr) 44px;
  }

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

  .area-choice-list .check-pill {
    justify-content: center;
  }

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

  .day-pager {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 3px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .day-pager-btn {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: var(--tap);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-weight: 800;
  }

  .day-pager-btn.active {
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 5px 14px rgb(37 99 235 / 20%);
  }

  .day-pager-btn i {
    position: absolute;
    bottom: 5px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--danger);
  }

  .day-card[data-hidden-mobile="true"] {
    display: none;
  }

  dialog.sheet {
    inset: auto 0 0 0;
    width: 100vw;
    max-width: 100vw;
    max-height: calc(92vh - env(safe-area-inset-bottom));
    margin: 0;
    border-width: 1px 0 0;
    border-radius: 14px 14px 0 0;
  }

  dialog.problem-panel {
    height: auto;
    max-height: calc(88vh - env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 14px 14px 0 0;
  }

  .sheet-body {
    padding: 14px 12px calc(16px + env(safe-area-inset-bottom));
  }

  .candidate-row {
    grid-template-columns: auto auto minmax(0, 1fr);
  }

  .candidate-reason {
    grid-column: 3;
    justify-self: start;
  }

  .sheet-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .problem-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toast {
    bottom: calc(70px + env(safe-area-inset-bottom));
  }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--border);
    background: rgb(255 255 255 / 96%);
    box-shadow: 0 -8px 24px rgb(22 25 29 / 8%);
    backdrop-filter: blur(12px);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .tabbar-link {
    display: grid;
    place-items: center;
    gap: 2px;
    min-height: 56px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
  }

  .tabbar-link.active {
    color: var(--accent);
    background: linear-gradient(180deg, var(--accent-soft), transparent);
  }

  .tabbar-icon {
    font-size: 18px;
    line-height: 1;
  }
}

@media screen and (min-width: 700px) {
  .mobile-print-section {
    display: none;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 12mm;
  }

  * {
    box-shadow: none !important;
  }

  html,
  body {
    width: auto;
    min-height: 0;
    overflow: visible;
    background: #fff;
    color: #111;
    font-size: 10px;
  }

  .topbar,
  .tabbar,
  .screen-head,
  .toolbar,
  .day-pager,
  dialog,
  .toast,
  .onboarding {
    display: none !important;
  }

  .app-main {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .screen {
    display: block;
  }

  .print-title {
    display: block;
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 800;
  }

  .week-shell {
    display: block;
  }

  .week-grid {
    display: grid !important;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
  }

  .day-card {
    display: block !important;
    min-height: 0;
    padding: 5px;
    border: 1px solid #999;
    border-radius: 0;
    background: #fff;
  }

  .day-name {
    margin-bottom: 5px;
    border-bottom: 1px solid #bbb;
    padding-bottom: 3px;
    color: #111;
    font-size: 11px;
  }

  .problem-dot,
  .avatar {
    display: none !important;
  }

  .period-label {
    margin: 5px 0 2px;
    color: #333;
    font-size: 9px;
  }

  .shift-card {
    min-height: 0;
    margin-top: 3px;
    padding: 3px 4px;
    border: 0;
    border-left: 2px solid #555;
    border-radius: 0;
    background: #fff;
    color: #111;
    font-size: 9px;
    break-inside: avoid;
  }

  .shift-card.open {
    border-left-color: #b00000;
    color: #b00000;
    font-weight: 900;
  }

  .shift-card strong {
    white-space: normal !important;
  }

  .badge,
  .area-tag {
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #333;
    font-size: 8px;
    font-weight: 600;
  }

  .area-tag::before {
    display: none;
  }

  .rest-day {
    padding: 6px 0;
    color: #777;
    font-size: 9px;
  }
}

@media screen and (min-width: 700px) and (max-width: 1099px) {
  .week-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
