:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #eef3f5;
  --text: #172026;
  --muted: #63717c;
  --line: #d8e0e5;
  --accent: #1f7a6f;
  --accent-2: #b94e48;
  --accent-3: #d49b2a;
  --ink: #263238;
  --shadow: 0 18px 50px rgba(26, 38, 48, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #142025;
  color: #f9fbfc;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e7f2ef;
  color: #145f56;
  font-weight: 800;
}

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

.sidebar .eyebrow {
  color: #91a7ad;
}

h1,
h2,
h3,
h4,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.1;
}

h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

h4 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}

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

.nav-item {
  color: #d5e1e4;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 8px;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: #203239;
  color: #ffffff;
}

.deploy-box {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  color: #dbe7ea;
}

.deploy-box strong {
  color: #ffffff;
}

.deploy-box span {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.section-label {
  margin: 0;
  color: #91a7ad;
  font-size: 12px;
  font-weight: 700;
}

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

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

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 10px;
  min-width: 310px;
}

.summary-strip div,
.metric-row div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.summary-strip span,
.metric-row span {
  display: block;
  font-size: 24px;
  font-weight: 800;
}

small {
  color: var(--muted);
  font-weight: 700;
}

.control-band {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.search-field {
  display: grid;
  gap: 7px;
  flex: 1;
  min-width: 220px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-field input,
.ai-select-label select,
.new-project-form input,
.new-project-form select,
.new-project-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  background: #fbfcfd;
}

textarea {
  resize: vertical;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(70px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segment {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.segment:last-child {
  border-right: 0;
}

.segment.active {
  background: var(--ink);
  color: #ffffff;
}

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

.new-project-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  margin-bottom: 18px;
}

.new-project-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
  align-items: end;
}

.new-project-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.wide-field {
  grid-column: span 3;
}

.primary-button {
  min-height: 43px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
}

.primary-button:hover {
  background: #17675e;
}

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

.project-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  min-height: 206px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: grid;
  gap: 14px;
  text-align: left;
}

.project-card.active {
  outline: 3px solid rgba(31, 122, 111, 0.24);
  border-color: var(--accent);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.status-pill,
.priority {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-active {
  background: #e4f3ef;
  color: #11675d;
}

.status-done {
  background: #eaf0f4;
  color: #50606b;
}

.status-blocked {
  background: #fae7e4;
  color: #a53d37;
}

.card-title {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.title-link {
  color: var(--text);
  text-decoration: none;
}

.title-link:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.card-desc {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 8px;
  background: #f0f3f5;
  border-radius: 999px;
  color: #576773;
  font-size: 12px;
  font-weight: 700;
}

.mini-progress {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

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

.mini-track div,
.progress-track div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #67a84f);
}

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

.detail-head,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.detail-desc {
  margin: 14px 0;
  color: var(--muted);
  line-height: 1.6;
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.progress-track {
  margin: 14px 0 18px;
}

.detail-section {
  padding-top: 16px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
}

.ai-section {
  padding-top: 0;
  border-top: 0;
  margin-top: 0;
}

.ai-select-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.card-ai-row {
  display: grid;
  grid-template-columns: auto minmax(130px, 180px);
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.card-ai-row select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
  padding: 7px 9px;
}

.detail-section ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.55;
}

.command-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
}

code {
  display: block;
  min-height: 42px;
  padding: 11px 12px;
  border-radius: 8px;
  background: #10191d;
  color: #e8f2ee;
  overflow-x: auto;
  white-space: nowrap;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  cursor: pointer;
  font-weight: 800;
}

.link-list {
  display: grid;
  gap: 8px;
}

.link-list a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.queue-section,
.command-section {
  margin-top: 28px;
}

.queue-list,
.ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.queue-item,
.ops-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 15px;
}

.queue-item strong,
.ops-item strong {
  display: block;
  margin-bottom: 8px;
}

.queue-item p,
.ops-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: #10191d;
  color: #ffffff;
  border-radius: 8px;
  padding: 10px 14px;
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .detail-panel {
    position: static;
  }
}

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

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

  .topbar,
  .control-band {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-strip,
  .project-list,
  .queue-list,
  .ops-grid,
  .new-project-form {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .wide-field {
    grid-column: auto;
  }

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

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

  .sidebar {
    padding: 18px 14px;
  }

  .metric-row {
    grid-template-columns: 1fr;
  }
}
