:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-soft: #eef4ef;
  --surface-warm: #fbf7ef;
  --ink: #1d2520;
  --muted: #68746d;
  --line: #dce4dd;
  --line-strong: #c8d2ca;
  --accent: #1f7a5b;
  --accent-strong: #166448;
  --accent-soft: #dff1e9;
  --danger: #bd3d31;
  --danger-soft: #fae5e1;
  --warning: #9f6b0d;
  --shadow: 0 18px 40px rgba(31, 44, 36, 0.08);
  font-family:
    Pretendard,
    "Noto Sans KR",
    "Apple SD Gothic Neo",
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 4px 2px 22px;
}

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

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

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

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

h3 {
  font-size: 18px;
}

.header-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 10px;
  width: min(440px, 100%);
}

.header-summary div {
  min-height: 74px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.header-summary span {
  display: block;
  font-size: 24px;
  font-weight: 800;
}

.header-summary small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: 188px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.tabs {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tab-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  text-align: left;
}

.tab-button:hover,
.tab-button:focus-visible {
  border-color: var(--line);
  color: var(--ink);
  outline: none;
}

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

.tab-icon {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  font-size: 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

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

.field.compact {
  min-width: 160px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background-color 0.16s ease;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: 42px;
  padding: 10px 11px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 91, 0.16);
}

.task-form {
  display: grid;
  grid-template-columns:
    minmax(150px, 1fr)
    minmax(110px, 0.75fr)
    minmax(220px, 1.6fr)
    minmax(170px, 1fr)
    minmax(140px, 0.95fr)
    minmax(136px, 0.9fr)
    auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.primary-button,
.icon-text-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-weight: 800;
  white-space: nowrap;
}

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

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-strong);
  outline: none;
}

.icon-text-button {
  padding: 0 12px;
}

.icon-text-button.secondary,
.icon-button {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.icon-text-button.secondary:hover,
.icon-text-button.secondary:focus-visible,
.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 91, 0.12);
  outline: none;
}

.icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
}

.table-shell {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.task-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

.done-table {
  min-width: 1040px;
}

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

.task-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.task-table tr:last-child td {
  border-bottom: 0;
}

.task-table .corporation-cell,
.task-table .category-cell,
.task-table .status-cell,
.task-table .date-cell,
.task-table .actions-cell {
  white-space: nowrap;
}

.table-input,
.table-select,
.table-date,
.progress-input {
  height: 38px;
  min-width: 130px;
  background: #fff;
}

.table-input.name-input {
  min-width: 210px;
}

.progress-cell {
  min-width: 220px;
}

.progress-input {
  min-width: 0;
}

.progress-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
  align-items: start;
  min-width: 220px;
}

.progress-list {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.progress-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
  align-items: center;
}

.progress-empty {
  display: flex;
  align-items: center;
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.progress-history {
  min-width: 0;
}

.progress-history summary {
  display: flex;
  align-items: center;
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.progress-history summary:hover,
.progress-history summary:focus-visible {
  color: var(--accent-strong);
  outline: none;
}

.progress-history[open] summary {
  margin-bottom: 6px;
}

.progress-summary {
  max-width: 340px;
  color: var(--ink);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.corporation-cell .table-select {
  min-width: 150px;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 114px;
}

.row-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.row-button:hover,
.row-button:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.row-button.danger:hover,
.row-button.danger:focus-visible {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

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

.empty-state {
  display: none;
  padding: 28px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.empty-state.visible {
  display: block;
}

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

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.note-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.note-card header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.note-card input {
  font-weight: 900;
}

.note-card textarea {
  min-height: 260px;
  line-height: 1.55;
}

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

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

.item-form {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

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

.item-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 8px 6px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-warm);
}

.item-list span,
.item-list .item-value {
  flex: 1;
  min-width: 0;
}

.item-list span {
  overflow-wrap: anywhere;
  font-weight: 800;
}

.item-list .item-value {
  height: 36px;
  background: #fff;
  font-weight: 800;
}

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

body.auth-locked {
  overflow: hidden;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(245, 247, 244, 0.94);
  backdrop-filter: blur(10px);
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  display: grid;
  gap: 14px;
  width: min(100%, 390px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-description {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.auth-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.auth-actions .primary-button {
  width: 100%;
}

body.auth-locked .app-shell {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}

.lock-button {
  align-self: center;
  flex: 0 0 auto;
}

.lock-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .tabs {
    position: static;
    display: flex;
    overflow-x: auto;
  }

  .tab-button {
    width: auto;
    min-width: 108px;
  }

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

  .task-form .primary-button {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 18px, 1540px);
    padding-top: 14px;
  }

  .app-header,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .header-summary,
  .management-grid,
  .task-form {
    grid-template-columns: 1fr;
  }

  .toolbar {
    justify-content: stretch;
  }

  .toolbar > * {
    width: 100%;
  }

  .field.compact {
    min-width: 0;
  }

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