:root {
  color-scheme: light;
  --bg: #dfe8de;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-soft: rgba(255, 255, 255, 0.82);
  --rail: rgba(242, 246, 242, 0.92);
  --border: rgba(17, 44, 30, 0.1);
  --text: #10241a;
  --muted: #66756a;
  --accent: #157347;
  --accent-strong: #0d5d38;
  --accent-soft: #dff3e6;
  --warning-soft: rgba(250, 205, 93, 0.18);
  --error-soft: rgba(205, 69, 69, 0.14);
  --shadow: 0 24px 60px rgba(15, 42, 26, 0.12);
  --shadow-soft: 0 10px 28px rgba(15, 42, 26, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(21, 115, 71, 0.1), transparent 26%),
    linear-gradient(180deg, #e7efe7 0%, #dde8de 100%);
}

.app-shell {
  min-height: 100vh;
  padding: 16px;
  display: grid;
  grid-template-columns: 76px 390px minmax(0, 1fr) 320px;
  gap: 16px;
}

.utility-rail,
.sidebar,
.detail-panel,
.context-panel {
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.utility-rail {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 18px 12px;
  background: var(--rail);
}

.rail-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rail-btn,
.filter-chip,
.ghost-btn,
.log-item {
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.rail-btn {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  background: rgba(255,255,255,0.84);
  border-color: var(--border);
  box-shadow: var(--shadow-soft);
}

.rail-btn.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.rail-icon {
  font-size: 0.82rem;
  font-weight: 800;
}

.sidebar {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1dbf73, #11744a);
  box-shadow: 0 12px 28px rgba(17, 116, 74, 0.24);
}

.brand-mark span {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid rgba(255,255,255,0.92);
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
}

.brand-subtitle {
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 2px;
}

.global-alert {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(189, 141, 28, 0.22);
  background: rgba(255, 246, 213, 0.92);
  color: #715308;
  font-size: 0.88rem;
}

.global-alert.is-hidden { display: none; }

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.84);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 16px;
  box-shadow: var(--shadow-soft);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.search-icon {
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  position: relative;
}

.search-icon::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 2px;
  background: var(--muted);
  right: -6px;
  bottom: -2px;
  transform: rotate(45deg);
}

.filters-block { display: grid; gap: 8px; }
.filters-title {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

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

.filter-chip {
  padding: 8px 12px;
  background: rgba(255,255,255,0.82);
  color: var(--muted);
  border-color: var(--border);
}

.filter-chip.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(21, 115, 71, 0.18);
}

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

.stat-card {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(247,250,247,0.76));
}

.stat-card .label { font-size: 0.78rem; color: var(--muted); margin-bottom: 8px; }
.stat-card .value { font-size: 1.45rem; font-weight: 800; }

.section-head,
.card-head,
.log-item-head,
.log-item-meta,
.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-head {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ghost-btn {
  padding: 8px 12px;
  background: rgba(255,255,255,0.82);
  border-color: var(--border);
}

.log-list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.76);
  border-color: transparent;
}

.log-item:hover { transform: translateY(-1px); }
.log-item.is-active {
  background: linear-gradient(180deg, rgba(226, 246, 233, 0.96), rgba(245, 252, 247, 0.94));
  border-color: rgba(21, 115, 71, 0.18);
}

.log-item-title {
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-item-time,
.log-item-detail {
  font-size: 0.82rem;
  color: var(--muted);
}

.log-item-meta {
  justify-content: flex-start;
  gap: 8px;
  margin: 8px 0 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.86);
  border: 1px solid var(--border);
  font-size: 0.78rem;
}

.pill.system { color: var(--accent-strong); }
.pill.status-error { background: var(--error-soft); color: #9f1e1e; }
.pill.status-skipped,
.pill.status-duplicate { background: var(--warning-soft); color: #7d5a00; }

.detail-panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.detail-topbar h1 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.detail-topbar p {
  margin: 0;
  color: var(--muted);
}

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

.detail-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  overflow: auto;
}

.detail-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--panel-soft);
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.card-head h2 {
  margin: 0 0 12px;
  font-size: 0.98rem;
}

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

.info-item {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.86);
}

.item-label {
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.item-value {
  font-weight: 700;
  line-height: 1.45;
}

.code-block {
  margin: 0;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #0f1720;
  color: #d8e5f5;
  font: 0.82rem/1.55 "Consolas", "Courier New", monospace;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 180px;
}

.context-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 1480px) {
  .app-shell { grid-template-columns: 76px 360px minmax(0, 1fr); }
  .context-panel { display: none; }
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "rail"
      "side"
      "detail"
      "context";
  }
  .utility-rail {
    grid-area: rail;
    flex-direction: row;
  }
  .rail-group { flex-direction: row; }
  .sidebar { grid-area: side; }
  .detail-panel { grid-area: detail; }
  .context-panel {
    grid-area: context;
    display: flex;
  }
}
