:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-strong: #f8faf7;
  --text: #17211d;
  --muted: #66736d;
  --line: #dce3dd;
  --accent: #256f63;
  --accent-strong: #174f47;
  --amber: #b7791f;
  --red: #b42318;
  --blue: #2563eb;
  --violet: #6d5bd0;
  --green: #2f855a;
  --shadow: 0 18px 40px rgba(23, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #eef3ed;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent-strong);
  color: white;
  font-weight: 800;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
}

.brand-block p,
.quiet-panel p,
.focus-strip p,
.empty-state p {
  color: var(--muted);
}

.summary-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 22px;
}

.metric {
  min-width: 0;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

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

.metric.urgent span {
  color: var(--red);
}

.metric.waiting span {
  color: var(--amber);
}

.metric.mine span {
  color: var(--blue);
}

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

.filter-button,
.ghost-button,
.template-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.filter-button {
  width: 100%;
  padding: 11px 12px;
  text-align: left;
}

.filter-button.active {
  border-color: rgba(37, 111, 99, 0.35);
  background: #ddebe6;
  color: var(--accent-strong);
  font-weight: 700;
}

.quiet-panel {
  margin-top: 26px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.quiet-panel h2 {
  margin-bottom: 8px;
  font-size: 14px;
}

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

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

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-status {
  display: grid;
  gap: 2px;
  min-width: 150px;
  color: var(--muted);
  font-size: 12px;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-weight: 800;
}

.sync-pill.api {
  background: #dcfce7;
  color: #166534;
}

.sync-pill.local {
  background: #fef3c7;
  color: #92400e;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 800;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 310px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
}

.ghost-button,
.template-button {
  min-height: 40px;
  padding: 0 12px;
}

.focus-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #f0d0c9;
  border-radius: 8px;
  background: #fff7f5;
}

.focus-strip div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.danger {
  background: var(--red);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(330px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
  align-items: start;
}

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

.unit-card {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(23, 33, 29, 0.04);
  text-align: left;
}

.unit-card.active {
  border-color: rgba(37, 111, 99, 0.5);
  border-left-color: var(--accent);
  box-shadow: var(--shadow);
}

.unit-card.urgent {
  border-left-color: var(--red);
}

.unit-card.waiting_client {
  border-left-color: var(--amber);
}

.unit-card.blocked {
  border-left-color: #4b5563;
}

.unit-card.ready {
  opacity: 0.68;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card-top h3 {
  font-size: 17px;
}

.card-top p,
.card-meta,
.timeline small {
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #edf2f7;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.urgent {
  background: #fee4e2;
  color: var(--red);
}

.pill.waiting_client {
  background: #fef3c7;
  color: #92400e;
}

.pill.me {
  background: #dbeafe;
  color: #1d4ed8;
}

.pill.ready {
  background: #dcfce7;
  color: #166534;
}

.card-action {
  margin-bottom: 10px;
  color: #26322d;
  line-height: 1.35;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-pane {
  position: sticky;
  top: 18px;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.empty-state h3 {
  margin-bottom: 8px;
}

.detail-content {
  padding: 18px;
}

.hidden {
  display: none;
}

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

.detail-header h3 {
  font-size: 24px;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 14px;
}

.detail-stats div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.detail-stats dt {
  color: var(--muted);
  font-size: 12px;
}

.detail-stats dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.next-action,
.source-context,
.follow-form,
.timeline-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.next-action h4,
.follow-form h4,
.timeline-section h4 {
  margin-bottom: 10px;
  font-size: 15px;
}

.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

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

.source-grid div {
  min-width: 0;
}

.source-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.source-grid dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 750;
}

.follow-form {
  display: grid;
  gap: 10px;
}

.follow-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.follow-form input,
.follow-form select,
.follow-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.follow-form input,
.follow-form select {
  min-height: 40px;
  padding: 0 10px;
}

.follow-form textarea {
  resize: vertical;
  padding: 10px;
}

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

.template-row {
  grid-template-columns: repeat(3, 1fr);
}

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

.primary-button:hover {
  background: var(--accent-strong);
}

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

.timeline-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.timeline-item p {
  margin-top: 4px;
  line-height: 1.4;
}

.timeline-item a {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent-strong);
  font-weight: 700;
}

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

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

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

  .detail-pane {
    position: static;
  }
}

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

  .topbar,
  .topbar-actions,
  .focus-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    min-width: 0;
  }

  .sync-status {
    min-width: 0;
  }

  .detail-stats,
  .source-grid,
  .form-row,
  .template-row {
    grid-template-columns: 1fr;
  }
}
