:root {
  --bg: #f4efe5;
  --surface: rgba(255, 253, 248, 0.94);
  --surface-strong: #fffdf8;
  --line: #dbcdb6;
  --text: #24301e;
  --muted: #6d775f;
  --primary: #1f6a3d;
  --primary-strong: #124b2a;
  --accent: #d8a62b;
  --danger: #b54236;
  --danger-soft: #f7dfdb;
  --ok-soft: #dfefe2;
  --shadow: 0 18px 40px rgba(43, 51, 34, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(216, 166, 43, 0.15), transparent 22rem),
    linear-gradient(180deg, #f6f0e6 0%, #efe6d8 100%);
  color: var(--text);
}

button, input, select { font: inherit; }
h1, h2, h3, h4, p { margin: 0; }

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

.sidebar {
  background: linear-gradient(180deg, #1e4e32 0%, #123522 100%);
  color: #f8f3ea;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

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

.brand-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, #f1c04f 0%, #c88a1d 100%);
  color: #193422;
}

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

.nav-link {
  width: 100%;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: rgba(255, 251, 243, 0.78);
  text-align: left;
  padding: 12px 14px;
  cursor: pointer;
}

.nav-link.active, .nav-link:hover {
  background: rgba(255, 244, 225, 0.12);
  color: #fffaf0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.12);
}

.content {
  padding: 28px;
  display: grid;
  gap: 22px;
}

.topbar, .toolbar, .toolbar-inline, .panel-head, .stack-item-head, .modal-header, .modal-actions {
  display: flex;
  align-items: center;
}

.topbar, .toolbar, .panel-head, .stack-item-head, .modal-header {
  justify-content: space-between;
}

.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.view { display: none; gap: 22px; }
.view.active { display: grid; }

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

.metric-card, .panel {
  background: var(--surface);
  border: 1px solid rgba(162, 136, 95, 0.18);
  box-shadow: var(--shadow);
}

.metric-card {
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  gap: 12px;
}

.metric-card strong { font-size: 2rem; }

.metric-tag, .count-chip, .status-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.metric-tag { background: #f0e5cf; color: #725413; }
.count-chip { background: #eef3ea; color: var(--primary-strong); }
.status-pill.finished { background: var(--ok-soft); color: var(--primary-strong); }
.status-pill.in_progress { background: #f6edcf; color: #8a650f; }
.status-pill.scheduled { background: #e7ebf7; color: #42538f; }

.panel {
  border-radius: 22px;
  padding: 18px;
}

.panel-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.search-input, .select-input, .text-input {
  width: 100%;
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  padding: 0 14px;
  color: var(--text);
}

.toolbar { gap: 14px; }
.toolbar-split { justify-content: space-between; flex-wrap: wrap; }
.toolbar-inline { gap: 12px; flex-wrap: wrap; }

.primary-button, .ghost-button, .danger-button {
  min-height: 44px;
  border-radius: 14px;
  border: 0;
  padding: 0 16px;
  cursor: pointer;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #fdfaf2;
}

.ghost-button {
  background: rgba(31, 106, 61, 0.08);
  color: var(--primary-strong);
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 13px 10px;
  border-bottom: 1px solid rgba(165, 147, 113, 0.18);
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-size: 0.85rem; font-weight: 600; }

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-button {
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  background: #edf2ed;
  color: var(--primary-strong);
}

.mini-button.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.stack-list { display: grid; gap: 12px; }

.stack-item {
  border: 1px solid rgba(165, 147, 113, 0.2);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.stack-meta {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 8px;
}

.empty { color: var(--muted); padding: 10px 4px; }

.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(18, 31, 21, 0.48);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 1000;
}

.modal-root.hidden { display: none; }

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--surface-strong);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 28px 60px rgba(18, 31, 21, 0.24);
}

.modal-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-size: 0.9rem;
  color: var(--muted);
}

.member-list {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.member-item {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 180px;
}

.note-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: #f2ecdd;
  color: #6b5a36;
}

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

@media (max-width: 640px) {
  .content { padding: 18px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .member-item { grid-template-columns: 1fr; }
}
