:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e1ec;
  --input-bg: #ffffff;
  --secondary-bg: #edf2f7;
  --secondary-text: #243044;
  --download-bg: #ecfdf5;
  --download-border: #a7f3d0;
  --download-text: #0f766e;
  --info-bg: #e0f2fe;
  --info-text: #075985;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --warning-bg: #fef3c7;
  --selected-bg: #eff6ff;
  --worker-text: #243044;
  --detail-text: #334155;
  --table-heading: #475467;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #0f766e;
  --warning: #b45309;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --kakao: #fee500;
  --shadow: 0 12px 36px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
  --bg: #101214;
  --panel: #181b20;
  --text: #f1f5f9;
  --muted: #a8b3c4;
  --line: #2b313b;
  --input-bg: #111419;
  --secondary-bg: #242a33;
  --secondary-text: #eef2f7;
  --download-bg: #10241f;
  --download-border: #1f6b5b;
  --download-text: #7dd3c7;
  --info-bg: #102339;
  --info-text: #9bd4ff;
  --success-bg: #10291c;
  --success-text: #9be7b0;
  --warning-bg: #33240d;
  --selected-bg: #17243a;
  --worker-text: #e4e9f0;
  --detail-text: #cbd5e1;
  --table-heading: #b8c2d0;
  --primary: #6ea8ff;
  --primary-dark: #9ac2ff;
  --accent: #80d8cf;
  --warning: #f5c56b;
  --danger: #ff9b9b;
  --danger-bg: #3b171b;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Segoe UI",
    "Malgun Gothic",
    system-ui,
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.app-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.app-header,
.header-actions,
.panel-heading,
.button-row,
.dialog-heading,
.row-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header,
.panel-heading,
.dialog-heading {
  justify-content: space-between;
}

.app-header {
  margin-bottom: 16px;
}

.header-actions,
.button-row,
.row-actions {
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(620px, 1.6fr);
  grid-template-areas:
    "today today"
    "import list"
    "history calendar";
  gap: 16px;
  align-items: start;
}

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

.today-panel,
.import-panel,
.history-panel,
.list-panel,
.period-calendar-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.today-panel {
  grid-area: today;
}

.import-panel {
  grid-area: import;
  gap: 10px;
  padding: 14px;
}

.list-panel {
  grid-area: list;
}

.history-panel {
  grid-area: history;
}

.period-calendar-panel {
  grid-area: calendar;
}

.controls-grid,
.input-grid {
  display: grid;
  gap: 12px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  padding: 9px 11px;
}

.date-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 6px;
}

.date-input-wrap input {
  min-width: 0;
}

.date-picker-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--secondary-bg);
  color: var(--secondary-text);
  display: grid;
  place-items: center;
}

.date-picker-button:hover {
  border-color: var(--primary);
}

.calendar-icon {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 4px;
  display: block;
  position: relative;
}

.calendar-icon::before {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: 4px;
  border-top: 2px solid currentColor;
}

.calendar-icon::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 3px;
  left: 4px;
  top: 9px;
  background: currentColor;
  box-shadow: 5px 0 0 currentColor, 0 5px 0 currentColor, 5px 5px 0 currentColor;
}

input:focus,
button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.kakao-button,
.danger-button,
.danger-ghost-button,
.icon-button {
  min-height: 40px;
  border-radius: 6px;
  font-weight: 800;
}

.primary-button {
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  background: var(--secondary-bg);
  color: var(--secondary-text);
  padding: 0 14px;
}

.download-button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--download-bg);
  color: var(--download-text);
  font-weight: 800;
  padding: 0 14px;
}

.compact-import {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.compact-import summary {
  color: var(--primary);
  cursor: pointer;
  font-weight: 900;
}

.compact-form {
  margin-top: 12px;
}

.range-filter-form {
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
}

.range-filter-form h3 {
  font-size: 16px;
  margin: 0;
}

.range-calendar-popover {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 12px;
}

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

.range-calendar-heading strong {
  font-size: 15px;
}

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

.range-calendar-weekday {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  padding-bottom: 2px;
}

.range-calendar-weekday:first-child {
  color: var(--danger);
}

.range-calendar-weekday:nth-child(7) {
  color: var(--primary);
}

.range-calendar-blank {
  min-height: 34px;
}

.range-calendar-day {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-weight: 800;
}

.range-calendar-day:hover,
.range-calendar-day.is-selected {
  border-color: var(--primary);
  background: var(--selected-bg);
  color: var(--primary);
}

.kakao-button {
  background: var(--kakao);
  color: #1f2933;
  padding: 0 14px;
}

.danger-button {
  background: var(--danger);
  color: #fff;
  padding: 0 16px;
}

.danger-ghost-button {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0 14px;
}

.small {
  min-height: 34px;
  padding-inline: 10px;
  font-size: 13px;
}

.icon-button {
  width: 38px;
  background: var(--secondary-bg);
  color: var(--secondary-text);
  font-size: 24px;
  line-height: 1;
}

.button-row.end {
  justify-content: flex-end;
}

.status-area {
  min-height: 42px;
  margin-bottom: 12px;
}

.status-message {
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 800;
}

.status-message.info {
  background: var(--info-bg);
  color: var(--info-text);
}

.status-message.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-message.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-message.warning,
.row-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

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

.today-grid .worker-stack {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.today-grid .worker-stack span {
  display: inline-flex;
  font-size: calc(1rem + 3pt);
  font-weight: 800;
  line-height: 1.25;
  min-height: auto;
}

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

.worker-group h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.today-meta {
  margin-top: 12px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.shift-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
  table-layout: fixed;
}

.shift-table th:nth-child(1),
.shift-table td:nth-child(1) {
  width: 32%;
}

.shift-table th:nth-child(2),
.shift-table td:nth-child(2),
.shift-table th:nth-child(3),
.shift-table td:nth-child(3) {
  width: 24%;
}

.shift-table th:nth-child(4),
.shift-table td:nth-child(4) {
  width: 20%;
}

.shift-table th,
.shift-table td {
  border-bottom: 1px solid var(--line);
  padding: 13px 12px;
  text-align: left;
  vertical-align: top;
}

.shift-table th {
  color: var(--table-heading);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.shift-table tr.is-selected td {
  background: var(--selected-bg);
}

.date-button {
  background: transparent;
  color: var(--primary);
  font-weight: 900;
  padding: 0;
  text-align: left;
}

.worker-stack {
  display: grid;
  gap: 6px;
}

.worker-stack span {
  display: block;
  min-height: 24px;
  color: var(--worker-text);
}

.row-warning {
  width: fit-content;
  border-radius: 6px;
  margin-top: 8px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 800;
}

.empty-state {
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  padding: 18px;
  text-align: center;
}

.empty-state.compact {
  min-height: 86px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-heading-side {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.history-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.history-main strong {
  color: var(--primary);
}

.history-time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.history-detail {
  color: var(--detail-text);
  line-height: 1.55;
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.edit-dialog {
  width: min(560px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.edit-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.dialog-copy {
  color: var(--detail-text);
  line-height: 1.6;
}

#periodCalendar {
  overflow-x: auto;
  padding-bottom: 2px;
}

.period-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  min-width: 560px;
}

.period-weekday {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  padding: 4px 0 6px;
}

.period-weekday:first-child {
  color: var(--danger);
}

.period-weekday:nth-child(7) {
  color: var(--primary);
}

.period-blank {
  min-height: 98px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 70%, var(--bg));
}

.period-day {
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 9px;
  text-align: left;
}

.period-day:hover,
.period-day.is-selected {
  border-color: var(--primary);
  background: var(--selected-bg);
}

.period-date {
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.period-workers {
  color: var(--detail-text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "today"
      "import"
      "list"
      "history"
      "calendar";
  }

  .two-columns,
  .today-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 680px) {
  .app-shell {
    padding: 12px;
  }

  .panel {
    padding: 14px;
  }

  .app-header,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions,
  .button-row {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .header-actions button,
  .button-row button {
    width: 100%;
  }

  .table-wrap {
    overflow-x: visible;
  }

  .shift-table,
  .shift-table thead,
  .shift-table tbody,
  .shift-table tr,
  .shift-table th,
  .shift-table td {
    display: block;
    width: 100%;
  }

  .shift-table {
    min-width: 0;
    table-layout: auto;
  }

  .shift-table thead {
    display: none;
  }

  .shift-table tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 12px;
  }

  .shift-table tr.is-selected {
    border-color: var(--primary);
    background: var(--selected-bg);
  }

  .shift-table tr.is-selected td {
    background: transparent;
  }

  .shift-table td {
    border: none;
    padding: 6px 0;
  }

  .shift-table td:not(:first-child):not(:last-child)::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 4px;
  }

  .row-actions {
    justify-content: flex-end;
  }

  #periodCalendar {
    overflow-x: visible;
  }

  .period-calendar-grid {
    min-width: 0;
    gap: 4px;
  }

  .period-day,
  .period-blank {
    min-height: 76px;
  }

  .period-day {
    padding: 6px;
    gap: 4px;
  }

  .period-date {
    font-size: 12px;
  }

  .period-workers {
    font-size: 11px;
  }

  .period-weekday {
    font-size: 11px;
    padding: 2px 0 4px;
  }
}
