:root {
  color-scheme: light dark;
  --bg: #f5f7f8;
  --sidebar: rgba(255, 255, 255, 0.78);
  --surface: #ffffff;
  --surface-soft: #f0f4f5;
  --text: #111516;
  --muted: #667175;
  --line: #d9e0e2;
  --accent: #0f827a;
  --accent-strong: #095f5a;
  --green: #248a4b;
  --orange: #a66416;
  --danger: #b23a3a;
  --shadow: 0 20px 60px rgba(25, 37, 42, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1111;
    --sidebar: rgba(16, 20, 20, 0.82);
    --surface: #171b1b;
    --surface-soft: #202727;
    --text: #f1f5f3;
    --muted: #a4afac;
    --line: #303939;
    --accent: #69d7cc;
    --accent-strong: #9af2e8;
    --green: #72d987;
    --orange: #e5aa63;
    --danger: #ff8d8d;
    --shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 14%, transparent), transparent 320px),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

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

a {
  color: var(--accent-strong);
}

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

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

.brand {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: center;
}

.brand img {
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.brand strong,
.brand span,
.sync-panel strong,
.sync-panel span {
  display: block;
}

.brand span,
.eyebrow,
.status-line,
.empty-state span,
.status-card span,
.status-card small {
  color: var(--muted);
}

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

.tab,
.primary-action,
.secondary-action,
.danger-action,
.icon-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
}

.tab {
  width: 100%;
  padding: 0 12px;
  text-align: left;
}

.tab.is-active {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line));
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  font-weight: 760;
}

.sync-panel {
  display: grid;
  grid-template-columns: 1fr 40px;
  align-items: end;
  gap: 12px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 18px;
}

.workspace {
  width: min(1240px, 100%);
  padding: 36px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

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

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.18;
}

h1 {
  font-size: 34px;
}

h2 {
  font-size: 18px;
}

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

.status-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
}

.status-card {
  display: grid;
  gap: 6px;
  min-height: 118px;
  padding: 16px;
}

.status-card strong {
  font-size: 20px;
}

.tool-grid,
.settings-layout {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.settings-layout {
  grid-template-columns: minmax(320px, 480px) minmax(300px, 1fr);
}

.panel {
  padding: 18px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.counter,
.chip,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.counter {
  justify-content: center;
  min-width: 32px;
  padding: 0 10px;
}

.chip,
.tag {
  padding: 0 8px;
}

.chip:not(.muted) {
  border-color: color-mix(in srgb, var(--green) 42%, var(--line));
  color: var(--green);
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
}

label {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

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

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

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

.primary-action,
.secondary-action,
.danger-action {
  padding: 0 14px;
  font-weight: 740;
}

.primary-action {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.secondary-action {
  color: var(--accent-strong);
}

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

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

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

.item.is-draft {
  border-style: dashed;
}

.item-header,
.item-actions,
.settings-actions,
.data-stats,
.tag-row,
.review-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.item-header {
  justify-content: space-between;
}

.item-title {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 780;
}

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

.item-body {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.item-actions button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
}

.review-actions,
.settings-actions,
.data-stats {
  margin: 14px 0;
}

.data-stats span {
  min-width: 122px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.data-stats strong {
  display: block;
  font-size: 24px;
}

.policy-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.policy-list p,
.status-line {
  margin: 0;
  color: var(--muted);
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .tab {
    text-align: center;
  }

  .sync-panel {
    margin-top: 0;
  }

  .workspace {
    padding: 22px 14px 40px;
  }

  .view-header,
  .tool-grid,
  .settings-layout,
  .status-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .view-header .primary-action,
  .view-header .secondary-action {
    width: 100%;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 28px;
  }

  .inline-fields {
    grid-template-columns: 1fr;
  }

  .panel,
  .status-card {
    padding: 14px;
  }
}
