:root {
  --bg: #f3efe7;
  --panel: rgba(249, 245, 238, 0.9);
  --panel-strong: rgba(255, 251, 245, 0.98);
  --ink: #171717;
  --muted: #6e665d;
  --line: rgba(33, 28, 23, 0.14);
  --accent: #b85c38;
  --accent-soft: rgba(184, 92, 56, 0.14);
  --shadow: 0 18px 60px rgba(29, 24, 20, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(184, 92, 56, 0.14), transparent 28%),
    radial-gradient(circle at right 12% top 20%, rgba(48, 66, 82, 0.1), transparent 26%),
    linear-gradient(180deg, #ede6dc 0%, #f5f0e7 45%, #efe8de 100%);
  position: relative;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    repeating-radial-gradient(circle at 15% 20%, transparent 0 14px, rgba(40, 34, 28, 0.04) 14px 15px),
    repeating-linear-gradient(90deg, rgba(30, 25, 20, 0.03) 0 1px, transparent 1px 120px),
    repeating-linear-gradient(0deg, rgba(30, 25, 20, 0.03) 0 1px, transparent 1px 120px);
  opacity: 0.6;
}

body::after {
  background: linear-gradient(135deg, transparent 0 78%, rgba(184, 92, 56, 0.08) 78% 100%);
}

.page-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.api-panel {
  display: grid;
  grid-template-columns: minmax(120px, 170px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.eyebrow,
.panel-kicker,
.summary-label,
.status-text,
.field span {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow,
.panel-kicker {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  margin: 0 0 12px;
}

.field-label {
  display: inline-block;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.key-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.app-grid {
  display: grid;
  gap: 22px;
}

.panel {
  padding: 24px;
}

.panel-heading {
  margin-bottom: 18px;
}

.control-grid,
.summary-panel {
  display: grid;
  gap: 16px;
}

.control-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.field span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

input,
button {
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid rgba(34, 29, 23, 0.16);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.86);
  color: var(--ink);
  padding: 14px 16px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input:focus {
  border-color: rgba(184, 92, 56, 0.7);
  box-shadow: 0 0 0 4px rgba(184, 92, 56, 0.12);
  background: rgba(255, 253, 248, 0.98);
}

button {
  border: none;
  border-radius: 999px;
  padding: 13px 20px;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease, background-color 160ms ease;
}

button:hover:not(:disabled) {
  box-shadow: 0 10px 24px rgba(29, 24, 20, 0.12);
}

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

.primary-button {
  background: linear-gradient(135deg, #1d1b1a 0%, #2e2a27 100%);
  color: #f8f3eb;
  box-shadow: 0 16px 36px rgba(22, 19, 17, 0.2);
}

.secondary-button,
.ghost-button {
  background: rgba(255, 251, 245, 0.86);
  color: var(--ink);
  border: 1px solid rgba(33, 28, 23, 0.12);
}

.secondary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled) {
  background: rgba(255, 253, 248, 0.98);
  border-color: rgba(184, 92, 56, 0.26);
}

.danger-button {
  background: rgba(184, 56, 56, 0.12);
  color: #963232;
  border: 1px solid rgba(184, 56, 56, 0.24);
}

.danger-button:hover:not(:disabled) {
  background: rgba(184, 56, 56, 0.16);
  border-color: rgba(184, 56, 56, 0.34);
}

.button-slot .secondary-button {
  align-self: start;
}

.segments-container {
  display: grid;
  gap: 14px;
}

.segment-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(33, 28, 23, 0.09);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 252, 248, 0.95), rgba(246, 239, 229, 0.9));
}

.action-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: center;
}

.button-cluster {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.status-cluster {
  display: grid;
  gap: 14px;
}

.status-line {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
}

.status-text {
  font-size: 0.75rem;
  color: var(--muted);
}

.progress-rail {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(34, 29, 23, 0.08);
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #b85c38 0%, #e2b26c 100%);
  transition: width 220ms ease;
}

.summary-panel {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.summary-card strong {
  display: block;
  margin-top: 10px;
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: clamp(2.2rem, 3vw, 3rem);
}

.summary-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.inline-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.warning-box {
  max-width: 460px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: #844831;
  background: rgba(184, 92, 56, 0.08);
  border: 1px solid rgba(184, 92, 56, 0.18);
  padding: 12px 14px;
  border-radius: 16px;
}

.history-list {
  display: grid;
  gap: 10px;
  max-height: min(42vh, 430px);
  overflow-y: auto;
  padding-right: 4px;
}

.history-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(96px, auto) minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(33, 28, 23, 0.1);
  background: rgba(255, 252, 248, 0.76);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.history-item:hover {
  background: rgba(255, 253, 248, 0.94);
  border-color: rgba(184, 92, 56, 0.24);
  box-shadow: 0 10px 24px rgba(29, 24, 20, 0.08);
}

.history-item:focus-visible {
  outline: none;
  border-color: rgba(184, 92, 56, 0.6);
  box-shadow: 0 0 0 4px rgba(184, 92, 56, 0.12);
}

.history-item.is-active {
  border-color: rgba(184, 92, 56, 0.48);
  box-shadow: 0 10px 26px rgba(184, 92, 56, 0.12);
}

.history-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.76rem;
  font-weight: 800;
  background: rgba(34, 29, 23, 0.08);
}

.history-status-running,
.history-status-queued {
  background: rgba(226, 178, 108, 0.2);
  color: #8a5b19;
}

.history-status-completed {
  background: rgba(52, 132, 86, 0.16);
  color: #2f704d;
}

.history-status-failed {
  background: rgba(184, 92, 56, 0.14);
  color: #94462a;
}

.history-status-canceled {
  background: rgba(34, 29, 23, 0.1);
  color: #5f5850;
}

.history-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.history-main strong,
.history-main small {
  overflow-wrap: anywhere;
}

.history-main small,
.history-progress,
.history-empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.history-progress {
  font-weight: 800;
}

.history-actions {
  display: flex;
  justify-content: flex-end;
}

.history-export {
  padding: 10px 14px;
  white-space: nowrap;
}

.history-empty {
  padding: 18px;
  border: 1px dashed rgba(33, 28, 23, 0.16);
  border-radius: 16px;
  text-align: center;
}

.table-wrap {
  overflow: auto;
  max-height: min(58vh, 560px);
  border: 1px solid rgba(33, 28, 23, 0.1);
  border-radius: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1280px;
  background: rgba(255, 252, 248, 0.75);
}

thead {
  background: #1d1b1a;
  color: #f8f3eb;
  position: sticky;
  top: 0;
  z-index: 1;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(33, 28, 23, 0.08);
  text-align: left;
  white-space: nowrap;
  font-size: 0.92rem;
}

tbody tr:nth-child(even) {
  background: rgba(36, 31, 27, 0.03);
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
}

@media (max-width: 1160px) {
  .action-panel,
  .control-grid,
  .segment-row,
  .summary-panel,
  .history-item {
    grid-template-columns: 1fr;
  }

  .page-shell {
    width: min(100vw - 20px, 1440px);
    padding-top: 20px;
  }
}

@media (max-width: 720px) {
  .panel {
    padding: 18px;
  }

  th,
  td {
    padding: 12px 13px;
  }

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

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

  .history-list {
    max-height: 420px;
  }

  .table-wrap {
    max-height: 520px;
  }
}

.login-shell {
  min-height: 100vh;
  width: min(100vw - 32px, 520px);
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.login-panel {
  width: 100%;
  padding: 26px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form .primary-button {
  width: 100%;
}

.login-error {
  color: #963232;
  background: rgba(184, 56, 56, 0.1);
  border: 1px solid rgba(184, 56, 56, 0.22);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.9rem;
}
