:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --ink: #172033;
  --muted: #64748b;
  --line: #d8e0ea;
  --line-strong: #b9c6d6;
  --blue: #1d5fd1;
  --blue-soft: #e8f0ff;
  --green: #16856a;
  --green-soft: #e8f7f2;
  --orange: #c66a10;
  --orange-soft: #fff2df;
  --red: #c24132;
  --red-soft: #fff0ee;
  --purple: #7054b8;
  --purple-soft: #f0edfb;
  --shadow: 0 18px 45px rgba(23, 32, 51, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.brand {
  display: grid;
  gap: 12px;
  padding: 10px 8px 18px;
  border-bottom: 1px solid var(--line);
}

.brand img {
  width: 156px;
  height: auto;
  object-fit: contain;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #334155;
  cursor: pointer;
  font-weight: 750;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: #c6d5ea;
  background: var(--blue-soft);
  color: #174a9f;
}

.nav-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #edf2f7;
  color: #526174;
  font-weight: 850;
}

.nav-item.active .nav-icon {
  background: var(--blue);
  color: #fff;
}

.sidebar-block {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sidebar-block label,
label span {
  color: #475569;
  font-size: 13px;
  font-weight: 780;
}

.sidebar-actions {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.main {
  min-width: 0;
  padding: 24px 28px 40px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 20px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
  letter-spacing: 0;
}

.topbar-tools {
  display: flex;
  align-items: end;
  gap: 10px;
}

.search-box {
  width: min(360px, 34vw);
  display: grid;
  gap: 6px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

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

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 95, 209, 0.13);
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border-radius: 7px;
  cursor: pointer;
  font-weight: 820;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 0 14px;
}

.primary-button {
  background: var(--blue);
  color: #fff;
}

.primary-button:hover {
  background: #184fae;
}

.secondary-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #253247;
  text-decoration: none;
}

.secondary-button:hover {
  border-color: #91a6c0;
  background: #f8fafc;
}

.text-button {
  min-height: 36px;
  background: transparent;
  color: var(--blue);
}

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

.icon-button {
  width: 36px;
  height: 36px;
  background: #edf2f7;
  color: #334155;
  font-size: 24px;
  line-height: 1;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #b9c6d6;
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: #fff;
  color: #273449;
  font-weight: 750;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.section {
  margin-bottom: 18px;
}

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

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

.panel-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.stat-card {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.stat-card strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1;
}

.stat-card.blue {
  border-left: 4px solid var(--blue);
}

.stat-card.green {
  border-left: 4px solid var(--green);
}

.stat-card.orange {
  border-left: 4px solid var(--orange);
}

.stat-card.red {
  border-left: 4px solid var(--red);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar label {
  width: min(220px, 100%);
  display: grid;
  gap: 6px;
}

.project-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

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

.project-table th {
  color: #475569;
  font-size: 12px;
  font-weight: 850;
  background: #f8fafc;
}

.project-row {
  cursor: pointer;
}

.project-row:hover {
  background: #f8fbff;
}

.project-code {
  color: var(--blue);
  font-weight: 850;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.pill.blue {
  border-color: #bed3f5;
  background: var(--blue-soft);
  color: #174a9f;
}

.pill.green {
  border-color: #b9e1d5;
  background: var(--green-soft);
  color: #0f6f58;
}

.pill.orange {
  border-color: #f1c992;
  background: var(--orange-soft);
  color: #9a4f05;
}

.pill.red {
  border-color: #f3b7b0;
  background: var(--red-soft);
  color: #a03429;
}

.pill.gray {
  border-color: #cbd5e1;
  background: #f1f5f9;
  color: #475569;
}

.pill.purple {
  border-color: #d4c9f0;
  background: var(--purple-soft);
  color: #5f469f;
}

.task-list,
.record-list,
.timeline,
.compact-list {
  display: grid;
  gap: 12px;
}

.task-card,
.record-card,
.compact-item {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.task-card.overdue {
  border-left: 4px solid var(--red);
}

.task-card.today {
  border-left: 4px solid var(--orange);
}

.task-top,
.record-top,
.compact-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.task-top > div,
.record-top > div,
.compact-top > div {
  min-width: 0;
}

.task-card h3,
.record-card h3,
.compact-item strong {
  overflow-wrap: anywhere;
}

.task-card p,
.record-card p,
.compact-item p {
  margin: 10px 0 0;
  line-height: 1.55;
}

.task-meta,
.record-meta,
.compact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.task-actions {
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(120px, 150px) minmax(220px, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
  align-items: start;
}

.task-actions label {
  display: grid;
  gap: 6px;
}

.task-actions textarea {
  min-height: 66px;
}

.kanban .task-actions,
.layout-grid > aside .task-actions {
  grid-template-columns: 1fr;
}

.empty {
  min-height: 96px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fafcff;
  color: var(--muted);
  font-weight: 760;
}

.stage-board {
  display: grid;
  gap: 10px;
}

.stage-row {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 12px;
}

.phase-label {
  padding-top: 8px;
  color: #475569;
  font-size: 13px;
  font-weight: 850;
}

.stage-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stage-step {
  max-width: 210px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font-size: 13px;
  font-weight: 760;
}

.stage-step.done {
  border-color: #b9e1d5;
  background: var(--green-soft);
  color: #0f6f58;
}

.stage-step.current {
  border-color: #99b9ef;
  background: var(--blue-soft);
  color: #174a9f;
  box-shadow: 0 0 0 2px rgba(29, 95, 209, 0.09);
}

.stage-index {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #edf2f7;
  font-size: 11px;
  font-weight: 850;
}

.stage-step.current .stage-index {
  background: var(--blue);
  color: #fff;
}

.stage-step.done .stage-index {
  background: var(--green);
  color: #fff;
}

.stage-action-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.stage-action-box {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stage-action-box h3 {
  margin-bottom: 0;
}

.stage-action-box label {
  display: grid;
  gap: 7px;
}

.next-stage-box {
  min-height: 66px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

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

.next-stage-box strong {
  font-size: 15px;
}

.detail-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.detail-title h2 {
  margin-bottom: 4px;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

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

.fact span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.fact strong {
  font-size: 14px;
}

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

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

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

.form-actions,
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: 0;
}

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

.timeline-body strong {
  display: block;
  margin-bottom: 4px;
}

.timeline-body p {
  margin-bottom: 0;
  color: #475569;
  line-height: 1.5;
}

.modal {
  width: min(760px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.38);
}

.modal-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
}

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

.modal-head h2 {
  margin-bottom: 0;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}

.kanban-column {
  min-width: 0;
  min-height: 240px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.kanban-column h3 {
  margin-bottom: 12px;
  color: #475569;
  font-size: 14px;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

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

  .layout-grid,
  .stage-action-grid,
  .kanban {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .main {
    padding: 18px 14px 28px;
  }

  .topbar,
  .topbar-tools,
  .panel-head,
  .task-top,
  .record-top,
  .compact-top,
  .detail-title {
    display: grid;
  }

  .search-box,
  .toolbar label {
    width: 100%;
  }

  .nav,
  .sidebar-actions,
  .stats-grid,
  .detail-facts,
  .form-grid,
  .task-actions {
    grid-template-columns: 1fr;
  }

  .stage-row,
  .timeline-item {
    grid-template-columns: 1fr;
  }
}
