:root {
  color-scheme: light;
  --bg: #f5f0e7;
  --panel: rgba(255, 252, 247, 0.94);
  --panel-strong: #fffdf9;
  --line: rgba(93, 72, 45, 0.12);
  --line-strong: rgba(93, 72, 45, 0.2);
  --text: #241d16;
  --muted: #70675b;
  --accent: #b86033;
  --accent-deep: #944621;
  --accent-soft: rgba(184, 96, 51, 0.12);
  --success: #426b4f;
  --success-soft: rgba(66, 107, 79, 0.14);
  --warning: #c58a26;
  --warning-soft: rgba(197, 138, 38, 0.14);
  --danger: #a43f34;
  --danger-soft: rgba(164, 63, 52, 0.14);
  --shadow: 0 18px 48px rgba(72, 46, 15, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(214, 180, 110, 0.14), transparent 24%),
    radial-gradient(circle at right top, rgba(184, 96, 51, 0.1), transparent 20%),
    linear-gradient(180deg, #f8f4ed 0%, #f1ebe1 100%);
}

body.login-page {
  min-height: 100vh;
}

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

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

.sidebar {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 250, 243, 0.97), rgba(247, 240, 230, 0.98));
  backdrop-filter: blur(16px);
}

.brand-block,
.nav-item,
.modal-head,
.block-head,
.record-entry-head {
  display: flex;
}

.brand-block {
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 14px);
  gap: 4px;
  width: 38px;
}

.brand-mark span {
  display: block;
  aspect-ratio: 1;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), #d89d4d);
}

.brand-mark span:last-child {
  grid-column: span 2;
  height: 14px;
  aspect-ratio: auto;
  background: linear-gradient(135deg, #56765d, #88a37a);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow:empty {
  display: none;
}

.brand-block h1,
.topbar h2,
.section-head h3,
.modal-head h3,
.block-head h4 {
  margin: 0;
}

.brand-block h1 {
  font-size: 24px;
  line-height: 1.15;
}

.sidebar-add-btn {
  display: inline-flex;
  align-items: center;
  width: 100%;
  min-height: 68px;
  justify-content: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0;
  color: #fffaf6;
  text-shadow: 0 1px 0 rgba(91, 44, 17, 0.18);
  box-shadow: 0 14px 28px rgba(184, 96, 51, 0.16);
}

.sidebar-add-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 250, 246, 0.2);
  font-size: 22px;
  line-height: 1;
}

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

.nav-item {
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: 180ms ease;
}

.nav-item-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.nav-label {
  font-size: 15px;
  font-weight: 800;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(164, 63, 52, 0.12);
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.nav-item small {
  color: var(--muted);
}

.nav-item:hover,
.nav-item.is-active {
  border-color: rgba(184, 96, 51, 0.16);
  background: rgba(255, 252, 247, 0.92);
}

.workspace {
  padding: 22px;
}

.topbar,
.stage-band,
.table-zone {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.topbar {
  display: grid;
  gap: 20px;
  margin-bottom: 18px;
  padding: 22px;
}

.topbar-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.topbar-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.topbar-copy {
  display: grid;
  gap: 6px;
}

.topbar h2 {
  font-size: 30px;
  line-height: 1.08;
}

.login-card {
  display: grid;
  gap: 4px;
  min-width: 164px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 244, 0.96);
  text-align: right;
}

.login-card span,
.login-card small {
  color: var(--muted);
}

.login-card strong {
  font-size: 22px;
  font-weight: 800;
}

.logout-btn {
  min-height: 52px;
  min-width: 108px;
  font-weight: 800;
}

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

.login-panel {
  width: min(540px, 100%);
  display: grid;
  gap: 22px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 252, 247, 0.96);
  box-shadow: var(--shadow);
}

.login-brand {
  align-items: center;
}

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

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

.login-submit {
  min-height: 56px;
  font-size: 18px;
}

.login-error {
  padding: 12px 14px;
  border: 1px solid rgba(164, 63, 52, 0.18);
  border-radius: 8px;
  background: rgba(164, 63, 52, 0.08);
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
}

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

.account-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 249, 241, 0.88);
}

.account-card strong {
  font-size: 16px;
}

.account-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.global-search {
  display: grid;
  gap: 14px;
}

.search-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 12px;
}

.search-filters {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.search-box,
.filter-select {
  display: grid;
  gap: 8px;
}

.search-box span,
.filter-select span,
.form-grid label span {
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
}

.search-box input,
.inline-date,
select,
textarea,
.form-grid label input {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: inherit;
  font-size: 18px;
}

.search-box input::placeholder,
textarea::placeholder,
.form-grid input::placeholder {
  color: #8f8577;
}

.page-section {
  display: grid;
  gap: 18px;
}

.stage-band,
.table-zone {
  padding: 22px;
}

.section-head {
  display: grid;
  gap: 18px;
}

.stage-strip,
.pagination,
.page-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.primary-btn,
.ghost-btn,
.stage-pill,
.page-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: 180ms ease;
}

.primary-btn,
.ghost-btn,
.page-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 16px;
}

.primary-btn {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #d88b48);
  color: #fffaf6;
  font-weight: 800;
}

.ghost-btn,
.stage-pill,
.page-pill {
  background: rgba(255, 252, 247, 0.86);
  color: inherit;
}

.ghost-btn:hover,
.stage-pill:hover,
.page-pill:hover {
  border-color: rgba(184, 96, 51, 0.22);
  background: rgba(255, 247, 238, 0.98);
}

.ghost-btn.small,
.page-pill {
  padding: 10px 14px;
  font-size: 15px;
}

.filter-card {
  min-height: 56px;
  font-size: 17px;
  font-weight: 800;
}

.stage-strip {
  gap: 14px;
  justify-content: flex-start;
}

.stage-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  min-width: 176px;
  min-height: 94px;
  padding: 22px;
}

.stage-pill strong {
  font-size: 28px;
  line-height: 1;
}

.stage-pill span {
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.stage-pill.is-active {
  border-color: rgba(184, 96, 51, 0.34);
  background: linear-gradient(135deg, rgba(184, 96, 51, 0.13), rgba(216, 157, 77, 0.1));
}

.section-head.compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-pill.is-active {
  border-color: rgba(184, 96, 51, 0.32);
  background: rgba(184, 96, 51, 0.1);
  color: var(--accent-deep);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

tbody tr {
  transition: 160ms ease;
}

tbody tr:hover {
  background: rgba(184, 96, 51, 0.05);
}

.name-cell strong,
.stage-cell strong,
.next-step strong {
  display: block;
  margin-bottom: 6px;
}

.name-cell strong {
  font-size: 20px;
  font-weight: 800;
}

.subtext {
  display: block;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.48;
}

.subtext.emphasis {
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
}

.badge,
.warning-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.badge {
  background: rgba(87, 118, 92, 0.12);
  color: var(--success);
}

.warning-badge.notice {
  background: var(--success-soft);
  color: var(--success);
}

.warning-badge.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.warning-badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.action-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  white-space: nowrap;
}

.row-action {
  min-width: 74px;
  min-height: 42px;
  margin-right: 0;
  font-size: 15px;
  font-weight: 800;
}

.time-cell strong,
.time-cell .subtext {
  white-space: nowrap;
}

.empty-state {
  padding: 44px 24px;
  text-align: center;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
}

.page-summary {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.pagination {
  align-items: center;
  justify-content: flex-end;
}

.page-pills {
  align-items: center;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(34, 27, 19, 0.38);
  backdrop-filter: blur(4px);
  z-index: 20;
}

.modal {
  position: fixed;
  inset: 24px;
  display: grid;
  place-items: center;
  z-index: 30;
}

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.modal-card.wide {
  width: min(900px, 100%);
}

.modal-card.extra-wide {
  width: min(980px, 100%);
}

.modal-head {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-head h3 {
  font-size: 28px;
}

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

.form-grid.roomy {
  gap: 22px;
}

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

.form-grid label textarea {
  min-height: 168px;
  resize: vertical;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 0 4px;
}

.checkbox-label input {
  width: 24px !important;
  height: 24px;
}

.checkbox-label span {
  color: var(--text);
  font-size: 18px !important;
}

.span-2 {
  grid-column: span 2;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.detail-block {
  display: grid;
  gap: 12px;
}

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

.meta-card,
.timeline-item,
.record-entry {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 247, 0.78);
}

.meta-card {
  display: grid;
  gap: 8px;
}

.meta-card strong {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta-card span {
  font-size: 16px;
  font-weight: 800;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item.is-current {
  border-color: rgba(184, 96, 51, 0.28);
  background: rgba(255, 247, 240, 0.96);
}

.timeline-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.timeline-item-head strong {
  font-size: 22px;
}

.timeline-item-head p,
.record-entry p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.timeline-item-head small,
.record-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stage-records {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.record-entry.is-active {
  border-color: rgba(184, 96, 51, 0.24);
  background: rgba(184, 96, 51, 0.08);
}

.record-stage {
  font-size: 16px;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 14px 18px;
  border-radius: 8px;
  background: rgba(34, 27, 19, 0.92);
  color: #fffaf6;
  box-shadow: var(--shadow);
  z-index: 40;
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .search-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media (max-width: 860px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .brand-block h1 {
    font-size: 20px;
  }

  .sidebar-add-btn {
    min-height: 58px;
    font-size: 18px;
  }

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

  .nav-item {
    min-height: 68px;
  }

  .topbar {
    padding: 16px;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .topbar-row,
  .topbar-head,
  .section-head.compact,
  .table-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .search-main,
  .search-filters,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .search-filters {
    gap: 10px;
  }

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

  .stage-pill {
    min-width: 148px;
    min-height: 84px;
  }

  .stage-pill strong {
    font-size: 24px;
  }

  .stage-pill span {
    font-size: 18px;
  }

  .span-2 {
    grid-column: auto;
  }

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

@media (max-width: 720px) {
  .workspace,
  .sidebar {
    padding: 12px;
  }

  .app-shell {
    gap: 0;
  }

  .sidebar {
    gap: 14px;
  }

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

  .sidebar-add-btn {
    min-height: 56px;
    padding: 0 18px;
    font-size: 19px;
  }

  .sidebar-add-icon {
    width: 24px;
    height: 24px;
    font-size: 20px;
  }

  .stage-band,
  .table-zone,
  .topbar {
    padding: 14px;
  }

  .topbar,
  .table-zone {
    border-radius: 10px;
  }

  .search-main {
    grid-template-columns: 1fr;
  }

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

  .topbar-head {
    gap: 10px;
  }

  .login-card,
  .logout-btn {
    width: 100%;
  }

  .login-card {
    text-align: left;
  }

  .search-box input,
  .inline-date,
  select,
  textarea,
  .form-grid label input {
    padding: 14px 14px;
    font-size: 16px;
  }

  .primary-btn,
  .ghost-btn,
  .page-pill {
    min-height: 46px;
  }

  .filter-card {
    min-height: 46px;
  }

  .stage-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .stage-pill {
    flex: 0 0 auto;
    min-width: 126px;
    min-height: 76px;
    padding: 16px;
  }

  .stage-pill strong {
    font-size: 20px;
  }

  .stage-pill span {
    font-size: 15px;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody tr {
    margin-bottom: 12px;
    padding: 4px 0 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 252, 247, 0.92);
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(72, 46, 15, 0.05);
  }

  tbody tr:hover {
    background: rgba(255, 252, 247, 0.92);
  }

  td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(93, 72, 45, 0.08);
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.35;
  }

  td.name-cell,
  td.action-cell {
    grid-template-columns: 1fr;
  }

  td.name-cell::before,
  td.action-cell::before {
    margin-bottom: 2px;
  }

  .name-cell strong {
    font-size: 18px;
  }

  .subtext.emphasis {
    font-size: 15px;
  }

  .action-cell {
    justify-content: flex-start;
    align-items: flex-start;
    gap: 8px;
    white-space: normal;
  }

  .row-action {
    min-width: 0;
    width: 100%;
  }

  .table-footer {
    gap: 12px;
  }

  .pagination {
    gap: 8px;
  }

  .modal {
    inset: 8px;
    align-items: stretch;
  }

  .modal-card {
    width: 100%;
    max-height: calc(100vh - 16px);
    padding: 16px;
  }

  .modal-card.wide,
  .modal-card.extra-wide {
    width: 100%;
  }

  .modal-head h3 {
    font-size: 22px;
  }

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

  .timeline-item-head {
    flex-direction: column;
  }

  .timeline-item-head strong {
    font-size: 18px;
  }
}

@media (max-width: 560px) {
  .search-filters {
    grid-template-columns: 1fr;
  }

  td {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .page-summary {
    font-size: 14px;
  }
}
