:root {
  --bg: #d8d1c8;
  --surface: #ffffff;
  --surface-soft: #ece6df;
  --ink: #26221e;
  --muted: #71675d;
  --line: #c5baae;
  --accent: #7a6b5c;
  --accent-strong: #554a40;
  --accent-soft: #eee7df;
  --gold: #9a7641;
  --gold-soft: #f3eadc;
  --blue: #66737a;
  --blue-soft: #e4e8e8;
  --danger: #b42318;
  --danger-soft: #fee4df;
  --done: #6d6257;
  --shadow: 0 14px 34px rgba(38, 34, 30, 0.18);
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(122, 107, 92, 0.12), transparent 38%),
    linear-gradient(180deg, #ffffff, var(--bg));
}

.login-panel {
  width: min(940px, 100%);
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-intro {
  padding: 40px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(122, 107, 92, 0.14), transparent 48%),
    var(--surface-soft);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.eyebrow {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--accent);
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 18px;
  font-size: clamp(34px, 4vw, 58px);
  line-height: 1.02;
  letter-spacing: 0;
}

.login-intro > p {
  max-width: 58ch;
  color: var(--muted);
  line-height: 1.6;
}

.login-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
}

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric strong {
  display: block;
  font-size: 26px;
}

.metric span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.login-form-wrap {
  padding: 34px;
  display: grid;
  align-content: center;
}

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

.assignment-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.assignment-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.assignment-editor-head p {
  margin: 4px 0 0;
}

.assignment-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(100px, 0.65fr) minmax(180px, 1.8fr) auto;
  gap: 10px;
  align-items: end;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.assignment-workers {
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 760px) {
  .assignment-editor-head,
  .assignment-row {
    display: grid;
    grid-template-columns: 1fr;
  }
}

label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

.button,
button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.button:hover,
button:hover {
  background: var(--accent-strong);
}

.button.secondary,
button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.button.secondary:hover,
button.secondary:hover {
  background: var(--surface-soft);
}

.button.danger,
button.danger {
  background: var(--danger);
}

.button.ghost,
button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: transparent;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 14px;
  overflow-y: auto;
}

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

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--done);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
  margin-bottom: 10px;
}

.panel h2,
.panel h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.import-box summary {
  cursor: pointer;
  font-weight: 700;
}

.import-result-list {
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.45);
}

.import-result-list > summary {
  font-weight: 700;
}

.import-result-list > div {
  margin-top: 6px;
  max-height: 160px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
}

.plancraft-helper {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.helper-code-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.helper-code {
  min-height: 94px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 10px;
  line-height: 1.35;
}

.pool-list {
  display: grid;
  gap: 7px;
}

.pool-summary {
  margin: -2px 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.order-card,
.task-card,
.worker-task {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px;
}

.order-card {
  cursor: grab;
}

.order-card:active,
.task-card:active {
  cursor: grabbing;
}

.project-number {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 800;
  margin-bottom: 5px;
}

.order-title,
.task-title {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.main-area {
  min-width: 0;
  padding: 12px;
}

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

.topbar h1 {
  margin-bottom: 2px;
  font-size: 22px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.task-form {
  display: grid;
  grid-template-columns: minmax(190px, 1.25fr) minmax(180px, 0.95fr) minmax(125px, 0.65fr) minmax(130px, 0.65fr) minmax(105px, 0.45fr) auto;
  gap: 8px;
  align-items: end;
}

.checkbox-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
}

.chip input {
  width: auto;
}

.board-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #c8beb2;
}

.board-grid {
  min-width: 1240px;
  display: grid;
  grid-template-columns: 120px minmax(150px, 1fr) minmax(145px, 1fr) repeat(5, minmax(118px, 1fr)) minmax(135px, 0.95fr);
}

.board-head,
.worker-head,
.board-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.board-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px;
  background: #d7cec3;
  font-weight: 800;
}

.worker-head {
  position: sticky;
  left: 0;
  z-index: 1;
  height: 112px;
  display: flex;
  gap: 7px;
  align-items: flex-start;
  padding: 8px;
  background: #f4f1ed;
  overflow: hidden;
}

.worker-head.is-expanded {
  height: auto;
  min-height: 112px;
  align-self: stretch;
  background: #ffffff;
}

.worker-color {
  width: 8px;
  align-self: stretch;
  border-radius: 999px;
}

.worker-name {
  font-weight: 900;
  margin-bottom: 3px;
}

.worker-info {
  min-width: 0;
  flex: 1;
}

.worker-count {
  color: var(--muted);
  font-size: 11px;
}

.worker-toggle {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--accent-strong);
  border-color: #a99d91;
  font-size: 16px;
  line-height: 1;
}

.worker-toggle:hover {
  background: var(--accent-soft);
}

.board-cell {
  height: 112px;
  padding: 5px;
  background: #ede7df;
  overflow: hidden;
  position: relative;
}

.board-cell.worker-expanded {
  height: auto;
  min-height: 112px;
  overflow: visible;
}

.board-cell.is-week {
  background: #f1e5d5;
}

.board-cell.is-overdue {
  background: #f8e3df;
}

.board-cell.is-flex {
  background: #e4e8e8;
}

.board-cell.drag-over {
  outline: 3px solid rgba(122, 107, 92, 0.42);
  outline-offset: -4px;
}

.board-cell.has-expanded {
  overflow: visible;
  z-index: 10;
}

.cell-stack {
  display: grid;
  gap: 5px;
}

.task-card {
  cursor: grab;
  border-left: 4px solid var(--accent);
  box-shadow: 0 3px 8px rgba(34, 38, 30, 0.05);
}

.task-card.absence {
  cursor: default;
  background: #f3eadc;
}

.worker-task.absence,
.tv-task.absence {
  background: #f3eadc;
}

.task-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.time-badge {
  min-height: 19px;
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f3eadc;
  border: 1px solid #d8c2a3;
  color: #5b5148;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.task-card.is-expanded {
  position: absolute;
  left: 5px;
  top: 5px;
  z-index: 20;
  width: min(320px, calc(100vw - 32px));
  min-height: 106px;
  padding: 10px;
  cursor: default;
  box-shadow: 0 16px 34px rgba(34, 38, 30, 0.22);
}

.board-cell.is-flex .task-card.is-expanded {
  right: 5px;
  left: auto;
}

.task-card.is-expanded .task-title {
  font-size: 15px;
  line-height: 1.25;
}

.expanded-task-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.more-card {
  width: 100%;
  padding: 5px 7px;
  border-color: #a99d91;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  font-size: 11px;
}

.more-card:hover {
  background: #fff;
}

.task-card.done,
.worker-task.done {
  background: #eee8e1;
  border-color: #cbc0b3;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.tag.week {
  background: var(--gold-soft);
  color: #6f5634;
}

.tag.flex {
  background: var(--blue-soft);
  color: #49585e;
}

.tag.carry {
  background: #f3eadc;
  color: #76583a;
  border-color: #d8c2a3;
}

.tag.overdue {
  background: #fee4df;
  color: var(--danger);
  border-color: #f5b7ad;
}

.tag.done {
  background: #eee8e1;
  color: var(--done);
}

.empty-cell {
  min-height: 30px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(38, 34, 30, 0.50);
  z-index: 50;
}

.modal {
  width: min(720px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.modal-header,
.modal-body,
.modal-footer {
  padding: 14px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
}

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

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

.detail-task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.done-overview {
  display: grid;
  gap: 10px;
}

.done-summary {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  width: max-content;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.done-summary strong {
  font-size: 24px;
}

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

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

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

.done-row h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.done-row-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.worker-shell {
  min-height: 100vh;
}

.worker-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.worker-header h1 {
  font-size: 20px;
  margin-bottom: 2px;
}

.worker-content {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 12px;
}

.worker-tabs {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.worker-groups {
  display: grid;
  gap: 10px;
}

.worker-group {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 10px;
}

.worker-group.worker-day-drop {
  background: #f4f0ea;
}

.worker-group.worker-day-drop.drag-over {
  outline: 3px solid rgba(122, 107, 92, 0.42);
  outline-offset: -4px;
  background: #e7ded3;
}

.worker-group h2 {
  margin-bottom: 8px;
  font-size: 15px;
}

.worker-task-list {
  display: grid;
  gap: 7px;
}

.worker-task {
  display: grid;
  gap: 7px;
}

.worker-task[draggable="true"] {
  cursor: grab;
}

.worker-task .row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.task-badges {
  display: inline-flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
}

.worker-task-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 100%;
}

.time-edit-button,
.time-clear-button {
  padding: 7px 9px;
  font-size: 12px;
}

.modal-time-input {
  width: 112px;
  min-width: 0;
  max-width: 100%;
}

.time-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.task-colleagues {
  color: var(--accent-strong);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.day-select {
  width: auto;
  min-width: 132px;
  padding: 7px 9px;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 100;
}

.toast.error {
  background: var(--danger);
}

.tv-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  background: var(--bg);
}

.tv-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(38, 34, 30, 0.08);
}

.tv-header h1 {
  margin-bottom: 2px;
  font-size: 30px;
  line-height: 1.05;
}

.tv-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tv-summary > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tv-summary strong {
  font-size: 24px;
}

.tv-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tv-board {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--tv-worker-count, 5), minmax(0, 1fr));
  align-items: start;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #c8beb2;
}

.tv-worker-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(38, 34, 30, 0.08);
}

.tv-worker-header {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  background: #f4f1ed;
}

.tv-worker-header .worker-color {
  width: 7px;
  height: 34px;
}

.tv-worker-info {
  min-width: 0;
  flex: 1;
}

.tv-worker-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tv-worker-header h2 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.tv-worker-count {
  min-width: 24px;
  min-height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(122, 107, 92, 0.26);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.tv-worker-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.tv-worker-columns {
  display: grid;
  grid-template-columns: 1fr;
  min-width: 0;
}

.tv-cell {
  min-width: 0;
  min-height: 86px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 4px;
  padding: 5px;
  border-bottom: 1px solid var(--line);
  background: #f8f6f3;
}

.tv-cell:last-child {
  border-bottom: 0;
}

.tv-cell-title {
  margin: 0;
  color: var(--ink);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.tv-cell.is-date {
  background: #f8f6f3;
}

.tv-cell.is-week {
  background: #f1e5d5;
}

.tv-cell.is-flex {
  background: #e4e8e8;
}

.tv-cell.is-today {
  box-shadow: inset 0 0 0 2px rgba(122, 107, 92, 0.45);
}

.tv-task-list {
  display: grid;
  align-content: start;
  gap: 3px;
  min-width: 0;
}

.tv-task {
  min-width: 0;
  min-height: 30px;
  display: grid;
  gap: 2px;
  padding: 4px;
  border: 1px solid rgba(122, 107, 92, 0.24);
  border-left: 2px solid var(--accent);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.82);
}

.tv-task .project-number {
  margin-bottom: 0;
  width: max-content;
  max-width: 100%;
  min-height: 15px;
  padding: 0 4px;
  font-size: 9px;
}

.tv-task-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.tv-task-detail {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.tv-empty {
  min-height: 22px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

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

@media (max-width: 980px) {
  .login-panel {
    grid-template-columns: 1fr;
  }

  .login-intro {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 28px;
  }

  .login-form-wrap {
    padding: 24px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar {
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

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

  .main-area {
    padding: 12px;
  }

  .tv-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .tv-board {
    grid-template-columns: 1fr;
  }

  .tv-worker-columns {
    grid-template-columns: 1fr;
  }

  .tv-cell {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tv-cell:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 640px) {
  .login-screen {
    padding: 10px;
  }

  .login-metrics {
    grid-template-columns: 1fr;
  }

  .brand-row {
    align-items: flex-start;
  }

  .worker-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .worker-heading,
  .worker-header > .toolbar {
    width: 100%;
  }

  .worker-week-label {
    box-sizing: border-box;
    width: 100%;
    margin: 8px 0 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--ink);
    font-size: 18px;
    font-weight: 800;
  }

  .worker-header > .toolbar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .worker-header > .toolbar button {
    min-width: 0;
    padding-right: 6px;
    padding-left: 6px;
  }

  .worker-task .row {
    flex-direction: column;
  }

  .worker-task-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .worker-done-button {
    margin-left: auto;
  }

  .modal-footer .worker-done-button {
    align-self: flex-end;
    margin-left: 0;
  }

  .modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-actions {
    flex-direction: column;
  }
}

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

.case-summary > div {
  display: grid;
  gap: 3px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.case-summary strong {
  color: var(--accent);
  font-size: 30px;
}

.case-summary span,
.case-next-action span {
  color: var(--muted);
}

.case-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.case-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease;
}

.case-card:hover,
.case-card:focus-visible {
  border-color: var(--accent);
  outline: none;
  transform: translateY(-1px);
}

.case-card-top,
.case-next-action {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.case-card h2,
.case-card p {
  margin: 0;
}

.case-card h2 {
  font-size: 19px;
}

.case-card p {
  color: var(--muted);
}

.case-next-action {
  align-items: flex-start;
  flex-direction: column;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.tag.emergency { background: #fbe5e2; color: #9e2418; }
.tag.high { background: #fff0d7; color: #995100; }

.record-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 0 22px 22px;
}

.record-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.record-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

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

.record-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px;
  border-radius: 7px;
  background: var(--surface);
}

.record-list-item > span:first-child {
  display: grid;
  gap: 3px;
}

.record-list-item small,
.record-empty {
  color: var(--muted);
}

.record-list-item.done strong {
  text-decoration: line-through;
}

.record-form {
  display: grid;
  gap: 8px;
}

@media (max-width: 640px) {
  .case-summary {
    grid-template-columns: 1fr;
  }

  .record-sections {
    grid-template-columns: 1fr;
    padding: 0 14px 14px;
  }
}
