* { box-sizing: border-box; }

:root {
  --brand: #7d91d6;
  --brand-deep: #5f73b8;
  --brand-soft: rgba(125, 145, 214, 0.16);
  --brand-wash: rgba(125, 145, 214, 0.28);
  --bg: #f3f5fb;
  --surface: #ffffff;
  --ink: #0a0a0a;
  --muted: #5a6270;
  --line: #d8deea;
  --accent: var(--brand);
  --accent-soft: var(--brand-soft);
  --danger: #9b1c1c;
  --ok: #0f6b4c;
  --font-ui: "Figtree", "Segoe UI", sans-serif;
  --font-brand: "Source Serif 4", Georgia, serif;
}

body {
  margin: 0;
  font: 15px/1.45 var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 8% -8%, var(--brand-wash) 0%, transparent 58%),
    radial-gradient(700px 380px at 100% 0%, rgba(10, 10, 10, 0.05) 0%, transparent 50%),
    linear-gradient(180deg, #eef1f8 0%, var(--bg) 42%, #e9edf6 100%);
  min-height: 100vh;
}

header.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #fff;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--brand);
}

.brand-slogan {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 0 rgba(125, 145, 214, 0.08);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brand-deep);
}

.panel h3 {
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.panel h3:first-child { margin-top: 0; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
}

.field {
  flex: 1 1 14rem;
  min-width: 0;
}

.field label,
label {
  display: block;
  margin: 0 0 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}

input:focus,
textarea:focus {
  outline: 2px solid var(--brand-wash);
  border-color: var(--brand);
}

textarea { min-height: 5.5rem; resize: vertical; }

textarea#ai-prompt,
textarea#gemini-debug {
  min-height: 10rem;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.4;
}

textarea#gemini-debug {
  background: #0f1720;
  color: #d7e2ef;
  border-color: #2a3848;
}

textarea#fb-desc { min-height: 12rem; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f6fb;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.btn:hover { background: #e8ecf7; }

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

button.primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }

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

.muted { color: var(--muted); font-size: 0.88rem; margin: 0.4rem 0 0; }
.error {
  color: var(--danger);
  background: #fdecec;
  border: 1px solid #f0c2c2;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  margin: 0.65rem 0 0;
}
.warn {
  color: #7a5b00;
  background: #fff6d6;
  border: 1px solid #f0d56d;
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  margin: 0 0 0.65rem;
  font-weight: 600;
}
.warn-cost {
  color: #7a2e00;
  background: #ffefe3;
  border-color: #f0a56d;
}
.warn-promo {
  color: #0b4f3a;
  background: #e6f7ef;
  border-color: #7dceb0;
}
.history-box {
  margin: 0.5rem 0 0.85rem;
  padding: 0.65rem 0.75rem;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.history-box h3 {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.history-box ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  color: var(--ink);
}
.history-box li { margin: 0.2rem 0; }
.hidden { display: none !important; }

.layout-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 1rem;
  align-items: start;
}

.stack { display: grid; gap: 1rem; }

.dl {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.35rem 0.75rem;
  margin: 0;
}
.dl dt { color: var(--muted); font-size: 0.85rem; }
.dl dd { margin: 0; font-weight: 550; }
.dl dd.price-highlight {
  color: var(--ok);
  font-size: 1.05rem;
  font-weight: 700;
}

.controls {
  display: grid;
  gap: 0.65rem;
  margin: 0.75rem 0;
}

.inline-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.1rem;
  align-items: center;
}

.inline-opts label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-weight: 500;
  color: var(--ink);
  font-size: 0.9rem;
}

details.prompt-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 1rem 1rem;
  margin-bottom: 1rem;
}

details.prompt-box > summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--brand-deep);
  list-style: none;
  padding: 0.35rem 0;
}

details.prompt-box > summary::-webkit-details-marker { display: none; }
details.prompt-box > summary::before {
  content: "▸ ";
  color: var(--muted);
}
details.prompt-box[open] > summary::before { content: "▾ "; }

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

.offers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.offers-table th,
.offers-table td {
  text-align: left;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.offers-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.offers-table tr.is-selected {
  background: var(--accent-soft);
}

.offers-table .offer-pick {
  font-size: 0.82rem;
  padding: 0.3rem 0.55rem;
}

.offers-table .muted-cell {
  color: var(--muted);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
}
.gallery figure { margin: 0; }
.gallery img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.gallery .btn {
  width: 100%;
  margin-top: 0.4rem;
  font-size: 0.85rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(800px 420px at 20% 10%, var(--brand-wash) 0%, transparent 55%),
    radial-gradient(600px 360px at 90% 90%, rgba(10, 10, 10, 0.08) 0%, transparent 50%),
    linear-gradient(160deg, #f7f8fc 0%, #e8ecf7 100%);
}

.login-box {
  width: min(100%, 400px);
  margin: 0;
  padding: 1.5rem 1.4rem 1.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(20, 28, 48, 0.08);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.15rem;
}

.login-logo {
  display: block;
  width: min(100%, 280px);
  height: auto;
  margin: 0 auto 0.85rem;
}

.login-tagline {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.02em;
}

.login-sub {
  margin: 0.35rem 0 0;
}

.login-box button { width: 100%; margin-top: 0.75rem; }

@media (max-width: 900px) {
  .layout-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  main { padding: 0.85rem; }
  .dl { grid-template-columns: 1fr; }
  .dl dt { margin-top: 0.25rem; }
  .brand-slogan { display: none; }
  .brand-name { font-size: 1.15rem; }
}
