:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #151a22;
  --muted: #697386;
  --line: #d8dee7;
  --line-strong: #c5ceda;
  --accent: #1f6feb;
  --accent-soft: #eaf2ff;
  --important: #b42318;
  --done: #087443;
  --done-soft: #e8f6ef;
  --work: #175cd3;
  --work-soft: #eaf1ff;
  --new-soft: #f1f5f9;
  --shadow: 0 8px 24px rgba(20, 33, 61, 0.07);
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --extra: #7c3aed;
  --extra-soft: #f3ecff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.app {
  width: min(980px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 30px;
}

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

.top-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f7fb 100%);
  color: var(--muted);
  font-size: 19px;
  font-weight: 850;
  box-shadow: 0 6px 16px rgba(20, 33, 61, 0.07);
}

.icon-button.is-active,
.icon-button:focus-within {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-button:active {
  transform: translateY(1px);
}

.admin-button {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  min-height: 38px;
  padding: 0;
  color: var(--muted);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 24;
  background: rgba(17, 23, 35, 0.2);
}

.drawer-backdrop[hidden] {
  display: none;
}

.app-drawer {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 25;
  width: min(320px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 12px;
  box-shadow: 0 20px 48px rgba(20, 33, 61, 0.18);
}

.app-drawer[hidden] {
  display: none;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.drawer-head strong {
  display: block;
  font-size: 17px;
  font-weight: 780;
}

.drawer-close {
  width: 34px;
  height: 34px;
  min-height: 34px;
  font-size: 20px;
}

.drawer-nav {
  display: grid;
  gap: 8px;
}

.drawer-link {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.78);
  padding: 11px 12px;
  text-align: left;
}

.drawer-link strong {
  font-size: 14px;
  font-weight: 760;
}

.drawer-link.is-active {
  border-color: var(--accent);
  background: rgba(234, 242, 255, 0.88);
}

.drawer-link[hidden] {
  display: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.metric {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow);
  text-align: left;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.metric-value {
  display: block;
  font-size: 28px;
  font-weight: 850;
  line-height: 1;
}

.metric-label {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.metric.is-active .metric-value,
.metric.is-active .metric-label {
  color: var(--accent);
}

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

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 26px;
  margin: 6px 2px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.today-reset {
  min-height: 28px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.today-reset[hidden] {
  display: none;
}

.dashboard-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}

.dashboard-strip[hidden] {
  display: none;
}

.dashboard-chip {
  display: grid;
  flex: 1 1 120px;
  gap: 2px;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfe;
  padding: 7px 10px;
  text-align: left;
}

.dashboard-chip.is-action {
  cursor: pointer;
}

.dashboard-chip.is-action:hover {
  border-color: rgba(31, 111, 235, 0.28);
  background: #f8fbff;
}

.dashboard-chip.is-action:active {
  transform: translateY(1px);
}

.chip-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.chip-value {
  line-height: 1.15;
  font-size: 14px;
  font-weight: 850;
}

.dashboard-chip.warn {
  border-color: rgba(180, 35, 24, 0.3);
  background: #fff7f5;
}

.dashboard-chip.important {
  border-color: rgba(31, 111, 235, 0.16);
  background: #fbfcfe;
}

.dashboard-chip.is-active {
  border-color: rgba(31, 111, 235, 0.6);
  background: #eaf3ff;
  box-shadow: inset 0 0 0 1px rgba(31, 111, 235, 0.16);
}

.dashboard-chip.warn.is-active {
  border-color: rgba(180, 35, 24, 0.46);
  background: #fff0ec;
  box-shadow: inset 0 0 0 1px rgba(180, 35, 24, 0.12);
}

.dashboard-chip.neutral {
  border-color: rgba(31, 111, 235, 0.14);
  background: #f8fbff;
}

.tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.archive-picker {
  position: relative;
  overflow: hidden;
}

.archive-picker[hidden],
.search[hidden],
.icon-button[hidden] {
  display: none;
}

.archive-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.search {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  padding: 0 12px;
  box-shadow: var(--shadow);
}

.search.is-collapsed {
  display: none;
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}

.scope-filters {
  display: flex;
  margin-left: auto;
  gap: 6px;
  align-items: center;
}

.scope-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.scope-button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.scope-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.scope-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.scope-toggle i {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: rgba(105, 115, 134, 0.24);
  transition: background-color 0.15s ease;
}

.scope-toggle i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(20, 33, 61, 0.2);
  transition: transform 0.15s ease;
}

.scope-toggle input:checked + i {
  background: rgba(31, 111, 235, 0.42);
}

.scope-toggle input:checked + i::after {
  transform: translateX(14px);
}

.scope-toggle.is-disabled {
  opacity: 0.45;
}

.day-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 4px;
  margin: 0 0 12px;
}

.day-chip {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.day-chip.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.journal-date {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 15px;
  font-weight: 850;
}

.journal-date input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.journal-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.journal-metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  box-shadow: var(--shadow);
}

.journal-metric strong,
.journal-metric span {
  display: block;
}

.journal-metric strong {
  font-size: 22px;
  line-height: 1;
}

.journal-metric span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.journal-filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 0 12px;
  padding: 0 0 4px;
}

.journal-filter {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.journal-filter.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.journal-list {
  display: grid;
  gap: 9px;
}

.journal-event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow);
}

.journal-event.is-clickable {
  cursor: pointer;
}

.journal-event.is-clickable:active {
  transform: translateY(1px);
}

.journal-event-main {
  min-width: 0;
}

.journal-event-type {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  background: var(--new-soft);
  color: var(--muted);
  padding: 0 9px;
  font-size: 11px;
  font-weight: 850;
}

.journal-event-type.marked_important {
  background: var(--danger-soft);
  color: var(--danger);
}

.journal-event-type.published {
  background: var(--done-soft);
  color: var(--done);
}

.journal-event-type.taken {
  background: var(--work-soft);
  color: var(--work);
}

.journal-event-main strong {
  display: block;
  margin-top: 7px;
  font-size: 14px;
}

.journal-event-main p {
  display: -webkit-box;
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.journal-event-side {
  display: grid;
  align-content: start;
  justify-items: end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.event-link {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--accent);
  font-weight: 850;
}

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

.load-more {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 12px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  font-weight: 850;
  box-shadow: var(--shadow);
}

.load-more[hidden] {
  display: none;
}

.task {
  display: flex;
  flex-direction: column;
  min-height: 214px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 13px;
}

.task.is-important {
  border-color: rgba(180, 35, 24, 0.3);
}

.task.is-stale {
  border-color: rgba(180, 35, 24, 0.28);
  box-shadow: 0 10px 24px rgba(180, 35, 24, 0.08);
}

.task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.task-head-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
}

.expand-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 30px;
  border: 1px solid #cdd8e7;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, #f3f7fb 100%);
  box-shadow: 0 5px 12px rgba(28, 42, 58, 0.08);
  color: #63758a;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.expand-icon span {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 0.15s ease;
}

.expand-icon.is-open {
  border-color: rgba(42, 133, 224, 0.55);
  background: var(--new-soft);
  color: var(--accent);
  box-shadow: 0 7px 16px rgba(42, 133, 224, 0.15);
}

.expand-icon.is-open span {
  transform: rotate(225deg) translate(-1px, -1px);
}

.expand-icon:active {
  transform: translateY(1px);
}

.badges {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.status,
.important,
.stale-badge,
.ai-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.status {
  background: var(--new-soft);
  color: var(--muted);
}

.status.in_progress {
  background: var(--work-soft);
  color: var(--work);
}

.status.published {
  background: var(--done-soft);
  color: var(--done);
}

.important {
  background: #fff0ed;
  color: var(--important);
}

.stale-badge {
  background: #fff7f5;
  color: var(--danger);
}

.ai-badge {
  background: #eef7ff;
  color: var(--accent);
}

.ai-match {
  display: grid;
  gap: 4px;
  margin: 0 0 12px;
  border: 1px solid rgba(42, 133, 224, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, #f7fbff 0%, #eef6ff 100%);
  padding: 10px 12px;
}

.ai-match span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.ai-match strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}

.task-text {
  display: -webkit-box;
  flex: 1;
  width: 100%;
  min-height: 66px;
  margin: 0 0 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow-wrap: anywhere;
  line-height: 1.38;
  font-size: 16px;
  padding: 0;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.task-text.is-expanded {
  display: block;
  min-height: 0;
  overflow: visible;
  -webkit-line-clamp: unset;
}

.task-text.is-link:hover {
  color: var(--accent);
}

.meta {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.meta-value {
  min-width: 0;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-link {
  color: var(--accent);
  text-decoration: none;
}

.user-link:active {
  opacity: 0.75;
}

.empty {
  grid-column: 1 / -1;
  min-height: 160px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 36px 16px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.55);
}

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

.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f7fa 100%);
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  padding: 0 10px;
  box-shadow: 0 5px 12px rgba(20, 33, 61, 0.06);
}

.action > span {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(105, 115, 134, 0.12);
  font-size: 12px;
  font-weight: 900;
}

.action.primary {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.action.primary > span {
  background: var(--accent);
  color: #ffffff;
}

.action.success {
  border-color: rgba(8, 116, 67, 0.25);
  background: var(--done-soft);
  color: var(--done);
}

.publish-toggle {
  justify-content: flex-start;
}

.publish-toggle > span {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: rgba(8, 116, 67, 0.2);
}

.publish-toggle > span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--done);
}

.action.link {
  border-color: rgba(23, 92, 211, 0.18);
  background: var(--work-soft);
  color: var(--work);
}

.action.danger {
  border-color: rgba(180, 35, 24, 0.22);
  background: var(--danger-soft);
  color: var(--danger);
}

.action.secondary {
  color: var(--muted);
}

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

.action:disabled,
.action.is-busy {
  cursor: wait;
  opacity: 0.62;
}

.team-view,
.shifts-view,
.ai-view {
  display: grid;
  gap: 12px;
}

.team-view[hidden],
.shifts-view[hidden],
.ai-view[hidden] {
  display: none;
}

.user-form,
.shift-form,
.ai-settings-form {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(170px, 1fr) minmax(130px, 0.8fr) minmax(96px, 0.55fr) minmax(96px, 0.55fr) auto;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow);
}

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

.ai-settings-form .form-title,
.ai-prompt-field,
.ai-settings-actions {
  grid-column: 1 / -1;
}

.toggle-line {
  display: flex;
  min-height: 48px;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 0 12px;
}

.ai-settings-form textarea {
  min-height: 160px;
  resize: vertical;
}

.ai-settings-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.form-title {
  align-self: center;
  min-width: 0;
}

.shift-form .form-title {
  grid-column: 1 / -1;
}

.form-title strong,
.form-title span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-title strong {
  font-size: 14px;
  font-weight: 850;
}

.form-title span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.user-form {
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 0.8fr) minmax(120px, 0.8fr) minmax(120px, 0.7fr) auto;
}

.user-form label,
.shift-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.user-form input,
.user-form select,
.shift-form input,
.shift-form select,
.user-controls select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  padding: 0 10px;
}

.submit-user {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 850;
  padding: 0 12px;
}

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

.danger-zone {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(180, 35, 24, 0.22);
  border-radius: 8px;
  background: var(--danger-soft);
  padding: 12px;
}

.danger-zone[hidden] {
  display: none;
}

.danger-zone strong,
.danger-zone span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.danger-zone strong {
  color: var(--danger);
  font-size: 14px;
  font-weight: 850;
}

.danger-zone span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.current-shifts {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow);
}

.current-shifts:empty {
  display: none;
}

.shift-state-head {
  display: grid;
  gap: 8px;
}

.shift-state-head strong {
  font-size: 15px;
}

.shift-signals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.shift-signals span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: var(--new-soft);
  color: var(--muted);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 850;
}

.shift-signals span.ok {
  background: var(--done-soft);
  color: var(--done);
}

.shift-signals span.warn {
  background: var(--danger-soft);
  color: var(--danger);
}

.shift-signals span.extra {
  background: var(--extra-soft);
  color: var(--extra);
}

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

.shift-state-group {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 9px;
}

.shift-state-group p {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.shift-state-group div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.shift-state-group span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid rgba(8, 116, 67, 0.25);
  border-radius: 999px;
  background: var(--done-soft);
  color: var(--done);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.shift-state-group span.is-inactive {
  border-color: rgba(105, 115, 134, 0.2);
  background: var(--new-soft);
  color: var(--muted);
}

.shift-state-group span.is-unscheduled {
  border-color: rgba(124, 58, 237, 0.28);
  background: var(--extra-soft);
  color: var(--extra);
}

.shift-state-group span.is-approved {
  border-color: rgba(124, 58, 237, 0.18);
  background: rgba(243, 236, 255, 0.58);
}

.shift-state-group span.is-empty {
  border-style: dashed;
  background: transparent;
  color: var(--muted);
}

.shift-state-group span button {
  min-height: 22px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 850;
}

.shift-state-group span button:disabled {
  opacity: 0.5;
}

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

.user-card,
.shift-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow);
}

.shift-main {
  min-width: 0;
}

.shift-card.is-now {
  border-color: rgba(8, 116, 67, 0.28);
  background: var(--done-soft);
}

.shift-card.is-unscheduled {
  border-color: rgba(124, 58, 237, 0.32);
  background: var(--extra-soft);
}

.shift-card-actions {
  display: grid;
  grid-template-columns: 112px 92px;
  gap: 8px;
}

.shift-edit {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) 96px 96px auto;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.shift-edit[hidden] {
  display: none;
}

.shift-edit input,
.shift-edit select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  padding: 0 10px;
}

.user-card.is-muted {
  opacity: 0.62;
}

.user-card strong,
.user-card span,
.shift-card strong,
.shift-card span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card strong,
.shift-card strong {
  font-size: 15px;
}

.user-card span,
.shift-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.user-controls {
  display: grid;
  grid-template-columns: 140px 120px;
  gap: 8px;
  align-items: center;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 850;
}

.task-detail {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  background: rgba(10, 14, 22, 0.38);
  padding: 12px;
}

.task-detail[hidden] {
  display: none;
}

.task-detail-panel {
  position: relative;
  width: min(760px, 100%);
  max-height: min(82vh, 820px);
  margin: 0 auto;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  padding: 16px;
}

.detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.detail-head {
  padding-right: 42px;
}

.detail-head h2 {
  margin: 0;
  font-size: 24px;
}

.detail-text {
  margin: 14px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.42;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.detail-meta div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.detail-meta span,
.detail-meta strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-meta strong {
  margin-top: 5px;
  font-size: 14px;
}

.detail-actions {
  margin: 0 0 16px;
}

.task-detail h3 {
  margin: 16px 0 8px;
  font-size: 16px;
}

.event-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.event-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.event-list strong,
.event-list span {
  display: block;
}

.event-list span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.skeleton {
  min-height: 214px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent),
    var(--panel);
  background-size: 180px 100%, 100% 100%;
  animation: shimmer 1.15s infinite linear;
}

@keyframes shimmer {
  from {
    background-position: -180px 0, 0 0;
  }

  to {
    background-position: calc(100% + 180px) 0, 0 0;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --panel: #1a1d24;
    --panel-soft: #222732;
    --text: #f4f7fb;
    --muted: #aab3c2;
    --line: #2e3542;
    --line-strong: #3a4352;
    --accent-soft: #142746;
    --work-soft: #142746;
    --done-soft: #113426;
    --new-soft: #262c36;
    --danger-soft: #3a1d1b;
    --extra-soft: #2b2144;
    --shadow: none;
  }
}

@media (max-width: 720px) {
  .detail-meta {
    grid-template-columns: 1fr;
  }

  .user-form,
  .shift-form,
  .ai-settings-form {
    grid-template-columns: 1fr 1fr;
  }

  .form-title {
    grid-column: 1 / -1;
  }

  .submit-user {
    grid-column: 1 / -1;
  }

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

  .user-card,
  .shift-card {
    grid-template-columns: 1fr;
  }

  .shift-card-actions,
  .shift-edit {
    grid-template-columns: 1fr 1fr;
  }

  .shift-edit .action {
    grid-column: 1 / -1;
  }

  .danger-zone {
    grid-template-columns: 1fr;
  }

  .shift-state-grid {
    grid-template-columns: 1fr;
  }

  .user-controls {
    grid-template-columns: 1fr 1fr;
  }

  .tools {
    flex-wrap: wrap;
  }

  .scope-filters {
    display: flex;
    flex: 1 1 auto;
    justify-content: flex-end;
  }

  .search {
    order: 5;
    flex-basis: 100%;
  }

  .dashboard-strip {
    grid-template-columns: 1fr;
  }

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

  .task-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .app {
    padding: 15px 10px 24px;
  }

  .topbar {
    align-items: flex-start;
    gap: 10px;
  }

  h1 {
    font-size: 25px;
  }

  .top-actions {
    gap: 5px;
  }

  .icon-button,
  .admin-button {
    width: 35px;
    height: 35px;
    min-height: 35px;
    font-size: 17px;
  }

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

  .metric {
    min-height: 66px;
    padding: 10px;
  }

  .metric-value {
    font-size: 24px;
  }

  .metric-label {
    font-size: 12px;
  }

  .summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

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

  .journal-event {
    grid-template-columns: 1fr;
  }

  .journal-event-side {
    align-items: center;
    grid-auto-flow: column;
    justify-content: space-between;
    justify-items: start;
  }

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

  .app-drawer {
    top: 10px;
    right: 10px;
    width: calc(100vw - 20px);
    padding: 10px;
  }

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

  .action {
    font-size: 12px;
  }
}
