:root {
  --bg: #f3efe6;
  --panel: rgba(255, 251, 245, 0.85);
  --line: rgba(95, 66, 42, 0.15);
  --text: #2a211b;
  --muted: #6a5749;
  --brand: #a54d2a;
  --brand-dark: #7a351b;
  --ok: #2f6b42;
  --warn: #a25d16;
  --danger: #8f2d2d;
  --shadow: 0 18px 45px rgba(74, 46, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 32%),
    linear-gradient(180deg, #f8f3ea 0%, #efe5d6 100%);
}

.page-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 20px 56px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 250, 244, 0.9), rgba(239, 225, 206, 0.88));
  box-shadow: var(--shadow);
}

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

.hero-actions form {
  margin: 0;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1;
}

.hero-copy,
.panel-head p,
.status-line,
th,
td,
label span {
  color: var(--muted);
}

.ghost-button,
button {
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: white;
  padding: 12px 18px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.ghost-button {
  background: rgba(165, 77, 42, 0.12);
  color: var(--brand-dark);
  border: 1px solid rgba(165, 77, 42, 0.18);
}

button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.grid {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

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

.two-col {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.panel,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.stat-card {
  padding: 20px;
}

.stat-card strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

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

.bulk-edit-form {
  display: grid;
  gap: 14px;
  margin: 18px 0 16px;
  padding: 16px;
  border: 1px solid rgba(95, 66, 42, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}

.bulk-edit-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

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

.form-hint {
  margin: -2px 2px 2px;
  font-size: 13px;
  color: var(--muted);
}

label {
  display: grid;
  gap: 8px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

.checkbox-field input {
  width: auto;
  margin: 0;
}

.checkbox-field span {
  color: var(--text);
}

input,
textarea,
select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(87, 56, 32, 0.14);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  font-size: 14px;
}

textarea {
  resize: vertical;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(95, 66, 42, 0.1);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th:first-child,
td:first-child {
  width: 44px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.active { background: rgba(47, 107, 66, 0.12); color: var(--ok); }
.badge.paused { background: rgba(162, 93, 22, 0.12); color: var(--warn); }
.badge.expired,
.badge.quota_exceeded,
.badge.failed { background: rgba(143, 45, 45, 0.12); color: var(--danger); }
.badge.executed { background: rgba(47, 107, 66, 0.12); color: var(--ok); }
.badge.proposed,
.badge.confirmed { background: rgba(165, 77, 42, 0.12); color: var(--brand-dark); }

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

.mini-actions button,
.proposal-card button,
.action-card button {
  padding: 8px 12px;
  font-size: 12px;
}

.danger-button {
  background: rgba(143, 45, 45, 0.14);
  color: var(--danger);
  border: 1px solid rgba(143, 45, 45, 0.18);
}

.proposal-list,
.action-list {
  display: grid;
  gap: 12px;
}

.proposal-card,
.action-card {
  padding: 14px 16px;
  border: 1px solid rgba(95, 66, 42, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.code-chip {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(42, 33, 27, 0.06);
  font-family: Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.status-line {
  margin: 16px 4px 0;
  min-height: 24px;
}

.status-line.error {
  color: var(--danger);
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 999;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 24px));
}

.toast {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 251, 245, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(0);
  opacity: 1;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.toast.success {
  border-color: rgba(47, 107, 66, 0.22);
}

.toast.error {
  border-color: rgba(143, 45, 45, 0.22);
  color: var(--danger);
}

.toast.leaving {
  transform: translateY(8px);
  opacity: 0;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 250, 244, 0.95), rgba(239, 225, 206, 0.92));
  box-shadow: var(--shadow);
}

.auth-error {
  margin: 10px 0 16px;
  color: var(--danger);
}

#trendCanvas {
  width: 100%;
  height: auto;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(247, 238, 225, 0.72));
}

@media (max-width: 760px) {
  .hero {
    flex-direction: column;
  }
}
