:root {
  color-scheme: light;
  --bg: #f7f8f4;
  --surface: #ffffff;
  --text: #1d211c;
  --muted: #626a60;
  --line: #d9ddd2;
  --strong-line: #b8c0ad;
  --accent: #146c5c;
  --accent-2: #2f6fed;
  --danger: #a33b2b;
  --warn: #89620d;
  --ok: #167342;
  --shadow: 0 10px 28px rgba(34, 42, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 40px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

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

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

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding: 28px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.back-link,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.header-actions select {
  width: auto;
  min-width: 190px;
}

.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 24px auto 56px;
  display: grid;
  gap: 18px;
}

.surface,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.surface {
  padding: 18px;
}

.section-title {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}

.risk-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.risk-strip span {
  min-height: 44px;
  display: flex;
  align-items: center;
  border: 1px solid #e3cf9d;
  border-radius: 8px;
  background: #fff8e6;
  color: var(--warn);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.25;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.status-line span,
.badge {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f9faf7;
  color: var(--muted);
  padding: 4px 10px;
  font-size: 13px;
  line-height: 1;
}

.badge.ok {
  border-color: #b7dac8;
  background: #eef9f2;
  color: var(--ok);
}

.badge.warn {
  border-color: #e3cf9d;
  background: #fff8e6;
  color: var(--warn);
}

.badge.danger {
  border-color: #e6bbb5;
  background: #fff0ee;
  color: var(--danger);
}

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

.form-grid.compact {
  grid-template-columns: minmax(0, 1fr) auto;
}

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

.align-end {
  align-self: end;
}

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

.metric-card {
  min-height: 110px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.metric-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.metric-card strong {
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.2;
}

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

.product-row {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.product-row:hover {
  border-color: var(--accent);
}

.product-row span:first-child {
  display: grid;
  gap: 4px;
}

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

.row-action {
  color: var(--accent);
  font-weight: 700;
}

.vault-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.vault-list button {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

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

.details {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.details-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  font-size: 13px;
}

.details-row span:last-child {
  overflow-wrap: anywhere;
}

.activity-log {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.log-line {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.log-line.ok {
  border-color: #b7dac8;
  color: var(--ok);
}

.log-line.error {
  border-color: #e6bbb5;
  color: var(--danger);
}

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

  .risk-strip,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid,
  .admin-grid,
  .split {
    grid-template-columns: 1fr;
  }

  .form-grid.compact {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1240px);
    margin-top: 14px;
  }

  .app-header {
    padding: 20px 12px;
  }

  .header-actions,
  .button-row {
    width: 100%;
  }

  .header-actions button,
  .header-actions select,
  .button-row button {
    flex: 1 1 160px;
  }

  .risk-strip,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .details-row {
    grid-template-columns: 1fr;
  }
}

