:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-soft: #eef3ed;
  --ink: #22251f;
  --muted: #697164;
  --line: #dfe5da;
  --primary: #24705a;
  --primary-strong: #155444;
  --accent: #b46a33;
  --warning: #b78a00;
  --danger: #b94d46;
  --success: #27834f;
  --info: #386a8d;
  --shadow: 0 18px 44px rgba(45, 54, 38, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.app-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  background: rgba(246, 247, 242, 0.94);
  color: var(--muted);
  font-weight: 700;
}

.app-loading-overlay.is-hidden {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 20px;
  background: linear-gradient(140deg, #eef3ed 0%, #f8f5ee 52%, #e8f1f6 100%);
}

.login-screen.is-visible {
  display: grid;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  color: var(--ink);
  margin-bottom: 4px;
}

.login-hint {
  margin: 0;
  font-size: 13px;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #26342e;
  color: #f7faf4;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #d8f0df;
  color: #163a2f;
  font-weight: 800;
}

.brand-name {
  font-weight: 800;
  font-size: 18px;
}

.brand-subtitle {
  color: #becdc2;
  font-size: 12px;
  margin-top: 2px;
}

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

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 12px;
  color: #dfe9e0;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.13);
  color: #ffffff;
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: #bde3ca;
  font-weight: 700;
}

.sidebar-note {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.07);
}

.note-label {
  font-size: 12px;
  color: #bde3ca;
  font-weight: 700;
}

.sidebar-note p {
  margin: 8px 0 0;
  color: #d6e0d6;
  font-size: 13px;
  line-height: 1.55;
}

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

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

.eyebrow {
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
  margin-bottom: 5px;
}

h3 {
  font-size: 16px;
  margin-bottom: 0;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

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

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.btn,
.icon-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.btn.primary {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

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

.btn.secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.btn.danger-action {
  color: var(--danger);
  border-color: #e6c5c2;
}

.btn.ghost {
  color: var(--primary-strong);
  background: transparent;
  border-color: var(--line);
}

.btn.is-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.small-action {
  min-height: 32px;
  padding: 0 10px;
}

.icon-btn {
  width: 36px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  font-size: 24px;
  line-height: 1;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
}

select[multiple],
.multi-select {
  min-height: 112px;
  padding: 8px;
}

select[multiple] option {
  padding: 6px 8px;
}

.input-affix {
  display: flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.input-affix span {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 100%;
  color: var(--muted);
  font-weight: 700;
}

.input-affix input {
  flex: 1;
  width: auto;
  min-width: 0;
  min-height: 36px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 8px 4px;
}

.input-affix input:first-child {
  padding-left: 10px;
}

.input-affix input:last-child {
  padding-right: 10px;
}

.input-affix input:focus {
  outline: none;
}

.input-affix:focus-within {
  border-color: var(--accent);
}

.input-affix.compact {
  min-height: 34px;
}

.input-affix.compact input {
  min-height: 32px;
}

textarea {
  resize: vertical;
}

.view {
  display: none;
}

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

.section-header,
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.section-header {
  margin-bottom: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card,
.panel,
.table-wrap,
.status-strip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

.metric-card {
  padding: 16px;
}

.roas-folder-grid {
  display: block;
}

.roas-folder-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 14px 18px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.roas-folder-summary.is-empty {
  justify-content: flex-start;
  color: var(--muted);
}

.roas-folder-main {
  min-width: 0;
}

.roas-folder-title {
  margin-top: 4px;
  overflow: hidden;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roas-folder-kicker,
.roas-folder-stats span {
  color: var(--muted);
  font-size: 13px;
}

.roas-folder-kicker {
  color: var(--brand);
  font-weight: 800;
}

.roas-folder-stats {
  display: grid;
  grid-template-columns: repeat(5, max-content);
  gap: 10px 18px;
  align-items: center;
  justify-content: end;
  flex: 0 0 auto;
}

.roas-folder-stats strong {
  color: var(--text);
  font-size: 18px;
}

@media (max-width: 980px) {
  .roas-folder-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .roas-folder-stats {
    grid-template-columns: repeat(2, minmax(0, max-content));
    justify-content: start;
  }
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  margin-top: 8px;
  font-size: 27px;
  line-height: 1.15;
  font-weight: 800;
}

.metric-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-grid,
.history-grid,
.management-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 14px;
}

.dashboard-grid.single-panel {
  grid-template-columns: 1fr;
}

.panel {
  padding: 16px;
}

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

.project-list,
.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.project-row,
.history-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcf8;
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.row-title {
  font-weight: 800;
  margin-bottom: 4px;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.tag,
.source-tag,
.status-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.tag {
  background: var(--surface-soft);
  color: #3f5146;
}

.source-tag {
  background: #eef6fa;
  color: var(--info);
  border-color: #d1e4ef;
}

.source-tag-button {
  cursor: pointer;
  font: inherit;
}

.source-tag-button:hover {
  border-color: var(--info);
  background: #e2f1f8;
}

.status-tag {
  background: #f5efe4;
  color: var(--accent);
  border-color: #ead8bd;
}

.status-tag.done {
  background: #e8f5eb;
  color: var(--success);
  border-color: #cae6d0;
}

.budget-recommendation-cell {
  display: grid;
  gap: 4px;
  justify-items: end;
  min-width: 96px;
}

.recommendation-mark {
  color: #1f6fb2;
  font-weight: 700;
  margin-left: 2px;
}

.tiny-action {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
}

.recommendation-summary {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f8f5;
}

.recommended-budget-row {
  background: #e8f1ff;
}

.status-tag.pending {
  background: #eef6fa;
  color: var(--info);
  border-color: #c6dfeb;
}

.status-tag.warning {
  background: #fff4d8;
  color: #9b6a12;
  border-color: #ead28f;
}

.status-tag.muted {
  background: var(--surface-soft);
  color: var(--muted);
  border-color: var(--line);
}

.status-tag.danger {
  background: #fff0ee;
  color: var(--danger);
  border-color: #f0c8c3;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.toolbar-action {
  display: flex;
  align-items: end;
}

.toolbar-action .btn {
  width: 100%;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.project-picker-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.form-grid > .project-picker-field {
  grid-column: 1 / -1;
}

.wide-field {
  grid-column: 1 / -1;
}

.campaign-type-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.multi-filter {
  position: relative;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.multi-trigger {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 10px;
  text-align: left;
}

.multi-filter.is-open .multi-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 112, 90, 0.14);
}

.multi-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 5;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
}

.multi-filter.is-open .multi-menu {
  display: grid;
  gap: 10px;
}

.multi-search {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 9px;
  font: inherit;
}

.multi-search:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(36, 112, 90, 0.12);
}

.project-search {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
}

.project-search:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(36, 112, 90, 0.12);
}

.multi-options {
  display: grid;
  gap: 4px;
  max-height: 220px;
  overflow: auto;
}

.multi-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border-radius: 8px;
  color: var(--ink);
  padding: 4px 6px;
}

.multi-option:hover {
  background: var(--surface-soft);
}

.multi-option.is-hidden {
  display: none;
}

.multi-option input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.text-btn {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  font-size: 12px;
}

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

.import-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  font-size: 13px;
  color: var(--ink);
}

.import-result ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--danger);
}

.project-picker {
  min-height: 38px;
  max-height: 156px;
  overflow: auto;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.compact-picker {
  max-height: 150px;
}

.report-scope-picker {
  min-height: 140px;
  max-height: 320px;
  overflow-y: auto;
}

.project-check {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: var(--ink);
}

.project-check.is-hidden {
  display: none;
}

.project-check input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 2px 0 0;
  padding: 0;
}

.project-check strong,
.project-check span {
  display: block;
}

.project-check span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.wide-label {
  margin-top: 14px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

.dense-table table {
  min-width: 1900px;
}

.roas-table table {
  min-width: 1700px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f5ee;
  color: #4c5548;
  font-size: 12px;
  font-weight: 800;
}

td {
  font-size: 13px;
}

tbody tr:hover {
  background: #fbfcf8;
}

.dense-table td,
.dense-table th {
  padding: 10px;
}

.number {
  font-variant-numeric: tabular-nums;
}

.metric-previous {
  color: var(--muted);
  font-size: 0.9em;
  white-space: nowrap;
}

.metric-previous .delta {
  margin-left: 2px;
}

.delta {
  font-weight: 800;
}

.delta.up {
  color: var(--success);
}

.delta.down {
  color: var(--danger);
}

.risk-row {
  background: #fff8ec;
}

.risk-row:hover {
  background: #fff5df;
}

.summary-row {
  background: #eef3ed;
  font-weight: 800;
}

.summary-row:hover {
  background: #e5ede5;
}

.status-strip {
  display: flex;
  gap: 0;
  align-items: stretch;
  height: 64px;
  margin-bottom: 14px;
  overflow: auto hidden;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 420px;
  padding: 12px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.pipeline-step:last-child {
  border-right: 0;
}

.pipeline-step strong {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
  margin-bottom: 0;
}

.pipeline-step span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.stack-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.management-grid {
  margin-bottom: 14px;
}

.plan-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

.adjustment-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.adjustment-flow > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.adjustment-flow strong,
.adjustment-flow span {
  display: block;
}

.adjustment-flow span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.adjustment-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.adjust-input {
  min-width: 108px;
}

.note-input {
  min-width: 220px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  grid-auto-flow: column;
  gap: 6px;
  margin-top: 8px;
  color: var(--text);
}

.inline-check input {
  width: 18px;
  height: 18px;
}

.review-decision {
  min-width: 150px;
  margin-bottom: 8px;
}

.review-note {
  margin-top: 8px;
  color: var(--accent);
  line-height: 1.5;
}

.current-config {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.current-config div {
  display: grid;
  gap: 4px;
}

.current-config span {
  color: var(--muted);
  font-size: 12px;
}

.current-config strong {
  color: var(--ink);
  font-size: 16px;
}

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

.detail-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 12px;
}

.detail-grid span,
.detail-grid strong {
  display: block;
}

.detail-grid span {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.detail-grid strong {
  font-weight: 650;
  line-height: 1.45;
}

.detail-grid strong.detail-highlight {
  color: var(--danger);
}

.execution-shot-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.execution-shot-panel > span {
  color: var(--muted);
  font-size: 12px;
}

.paste-upload-zone {
  display: grid;
  gap: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  outline: none;
}

.paste-upload-zone:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(38, 123, 96, 0.14);
}

.paste-upload-zone > strong {
  font-size: 14px;
}

.paste-upload-zone > span {
  color: var(--muted);
  font-size: 12px;
}

.paste-upload-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.paste-upload-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 6px 8px 6px 12px;
}

.paste-upload-item img,
.paste-upload-thumb-empty {
  width: 56px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.paste-upload-item img {
  object-fit: cover;
  display: block;
}

.paste-upload-thumb-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
}

.paste-upload-item span {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.shot-card {
  display: grid;
  gap: 8px;
}

.shot-preview,
.shot-placeholder {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 650;
}

.shot-preview-button {
  width: 100%;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}

.shot-preview img {
  width: 100%;
  height: 220px;
  object-fit: contain;
  display: block;
  background: #fff;
}

.shot-card strong {
  font-size: 13px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

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

.viewer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
}

input[readonly] {
  background: var(--surface-soft);
  color: var(--muted);
}

dialog {
  width: min(820px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(21, 31, 25, 0.45);
}

.dialog-card {
  padding: 20px;
}

.image-dialog-card {
  max-height: calc(100vh - 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.image-preview-shell {
  min-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.image-preview-shell img {
  width: 100%;
  max-height: calc(100vh - 160px);
  object-fit: contain;
  display: block;
  background: #fff;
  border-radius: 6px;
}

.dialog-header,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.dialog-actions {
  align-items: center;
  justify-content: flex-end;
  margin-top: 18px;
}

.pipeline-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.pipeline-preview div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcf8;
}

.pipeline-preview strong,
.pipeline-preview span {
  display: block;
}

.pipeline-preview span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 1000;
  right: 22px;
  bottom: 22px;
  max-width: 340px;
  background: #26342e;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.empty-state {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

.loading-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.compact-empty {
  padding: 10px;
  text-align: left;
}

.validation-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
}

@media (max-width: 1100px) {
  .metric-grid,
  .toolbar,
  .adjustment-flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .history-grid,
  .management-grid {
    grid-template-columns: 1fr;
  }
}

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

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

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

  .main-area {
    padding: 20px 14px 32px;
  }

  .topbar,
  .section-header {
    display: grid;
  }

  .topbar-actions,
  .inline-actions {
    width: 100%;
  }

  .topbar-actions > *,
  .inline-actions > * {
    flex: 1 1 180px;
  }

  .metric-grid,
  .toolbar,
  .form-grid,
  .pipeline-preview,
  .adjustment-flow,
  .adjustment-fields,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}
