:root {
  color-scheme: light;
  --ink: #142033;
  --muted: #617089;
  --line: #d9e2ef;
  --paper: #ffffff;
  --wash: #f3f7fb;
  --blue: #0f4c81;
  --blue-deep: #0b355e;
  --green: #17745b;
  --amber: #a56400;
  --red: #b3314a;
  --cyan: #16808d;
  --shadow: 0 18px 48px rgba(20, 32, 51, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(15, 76, 129, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 116, 91, 0.06) 1px, transparent 1px),
    var(--wash);
  background-size: 40px 40px;
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

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

button {
  cursor: pointer;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 20;
  background: var(--blue);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius);
}

.skip-link:focus {
  top: 16px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.login-panel {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-top: 5px solid var(--blue);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  line-height: 1.06;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 10px;
  color: var(--muted);
  background: #fff;
  font-size: 0.86rem;
  font-weight: 800;
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

.brand-block,
.header-actions,
.project-title-row,
.task-row,
.update-form,
.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--blue-deep);
  color: #fff;
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 700;
}

.brand-block strong,
.project-title h2,
.modal h2 {
  display: block;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-block small,
.project-card small,
.meta-row,
.timeline-meta {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 20px;
  padding: 20px;
}

.project-rail,
.main-panel {
  min-width: 0;
}

.rail-panel,
.project-focus,
.overview-strip,
.modal-content {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.rail-panel {
  padding: 16px;
  position: sticky;
  top: 92px;
}

.rail-heading h1,
.project-title h2,
.section-title,
.modal h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.field-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.text-input,
.select-input,
.text-area {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

.text-area {
  resize: vertical;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 12px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #edf3f8;
}

.segment,
.ghost-button,
.icon-button,
.primary-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
}

.segment {
  background: transparent;
  color: var(--muted);
}

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

.ghost-button,
.icon-button {
  background: #fff;
  border-color: var(--line);
  color: var(--blue-deep);
}

.primary-button {
  padding: 0 16px;
}

.icon-button {
  min-width: 40px;
}

[hidden] {
  display: none !important;
}

.project-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.project-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.project-card.is-active {
  border-color: var(--blue);
  box-shadow: 0 8px 24px rgba(15, 76, 129, 0.16);
}

.project-card[data-health="risk"],
.badge[data-tone="risk"] {
  border-left-color: var(--red);
}

.project-card[data-health="watch"],
.badge[data-tone="watch"] {
  border-left-color: var(--amber);
}

.project-card strong {
  display: block;
  margin-bottom: 6px;
}

.mini-progress,
.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6edf5;
}

.mini-progress span,
.progress-track span {
  display: block;
  height: 100%;
  background: var(--green);
}

.overview-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  margin-bottom: 20px;
}

.overview-strip article {
  padding: 18px;
  background: #fff;
}

.overview-strip span,
.kicker {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.overview-strip strong {
  display: block;
  margin-top: 6px;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 1;
}

.project-focus {
  padding: 22px;
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-content: center;
  text-align: center;
}

.project-title-row {
  justify-content: space-between;
  align-items: flex-start;
}

.project-title h2 {
  font-size: clamp(1.8rem, 4vw, 3.4rem);
  line-height: 1.05;
}

.project-summary {
  max-width: 860px;
  color: var(--muted);
  line-height: 1.75;
}

.badge-row,
.tag-row,
.api-grid,
.form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  padding: 4px 9px;
  background: #fff;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 800;
}

.tag {
  border-left-width: 1px;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
  margin-top: 22px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 16px;
}

.section-title {
  margin-bottom: 12px;
  font-size: 1.08rem;
}

.update-form {
  align-items: end;
  flex-wrap: wrap;
}

.update-form .field-label {
  flex: 1 1 170px;
}

.update-form .wide-field {
  flex-basis: 100%;
}

.range-input {
  accent-color: var(--blue);
}

.task-list,
.timeline {
  display: grid;
  gap: 10px;
}

.task-row {
  justify-content: space-between;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.task-body {
  min-width: 0;
  flex: 1;
}

.task-body strong {
  display: block;
}

.task-actions {
  display: grid;
  grid-template-columns: 116px 88px;
  gap: 8px;
  align-items: start;
}

.timeline-item {
  border-left: 4px solid var(--cyan);
  padding: 8px 0 8px 12px;
}

.timeline-item[data-status="blocked"] {
  border-left-color: var(--red);
}

.timeline-item[data-status="done"] {
  border-left-color: var(--green);
}

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

.api-pill {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #f9fbfd;
  font-family: "IBM Plex Sans", monospace;
  font-size: 0.88rem;
}

.api-pill span {
  color: var(--muted);
  font-family: "Noto Sans TC", sans-serif;
  font-weight: 700;
}

.modal {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(20, 32, 51, 0.45);
}

.modal-content {
  padding: 18px;
}

.modal-header,
.modal-actions {
  justify-content: space-between;
}

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

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

  .rail-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-header,
  .project-title-row,
  .task-row,
  .update-form {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    padding: 12px;
  }

  .overview-strip,
  .form-grid,
  .api-grid {
    grid-template-columns: 1fr;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions > * {
    width: 100%;
  }

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