:root {
  --ink: #182223;
  --muted: #617071;
  --line: #dbe3e1;
  --paper: #f4f7f5;
  --white: #ffffff;
  --forest: #174c43;
  --forest-deep: #103a34;
  --mint: #d8eee7;
  --lime: #b9dd72;
  --amber: #f5e7bd;
  --red: #a73c35;
  --shadow: 0 16px 45px rgba(23, 48, 43, .09);
  --radius: 14px;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(185, 221, 114, .9); outline-offset: 2px; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #e5f1ed 0, transparent 30%), var(--forest-deep); }
.login-card { width: min(430px, 100%); padding: 44px; background: var(--white); border-radius: 6px 32px 6px 6px; box-shadow: 0 28px 70px rgba(4, 28, 24, .28); }
.brand-mark { width: 58px; height: 42px; display: flex; gap: 6px; align-items: center; transform: skewX(-24deg); }
.brand-mark span { display: block; width: 8px; height: 34px; background: var(--forest); border-radius: 2px; }
.brand-mark span:nth-child(2) { height: 26px; }
.brand-mark span:nth-child(3) { height: 18px; }
.brand-mark.small { width: 37px; height: 30px; gap: 4px; }
.brand-mark.small span { width: 5px; height: 24px; }
.brand-mark.small span:nth-child(2) { height: 19px; }
.brand-mark.small span:nth-child(3) { height: 14px; }
.product-name { margin: 18px 0 4px; font-size: 13px; font-weight: 700; letter-spacing: .12em; color: var(--forest); }
.login-card h1 { margin: 0; font-size: clamp(32px, 6vw, 44px); line-height: 1.04; letter-spacing: -.04em; }
.login-copy { margin: 16px 0 30px; color: var(--muted); line-height: 1.55; max-width: 38ch; }
.login-form { display: grid; gap: 16px; }
label { display: grid; gap: 8px; font-size: 13px; font-weight: 650; color: #334240; }
label em { margin-left: 5px; font-style: normal; font-weight: 500; color: #84908f; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfb; color: var(--ink); padding: 11px 12px; transition: border-color .16s, background .16s; }
textarea { resize: vertical; line-height: 1.5; }
input:hover, textarea:hover, select:hover { border-color: #b6c5c1; }
input:focus, textarea:focus, select:focus { border-color: var(--forest); background: var(--white); outline: none; box-shadow: 0 0 0 3px rgba(23, 76, 67, .09); }
.login-hint { margin: 24px 0 0; color: #81908d; text-align: center; font-size: 12px; }
.form-error { margin: 0; color: var(--red); font-size: 13px; font-weight: 600; }
.button { border: 0; border-radius: 9px; padding: 11px 17px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 9px; transition: transform .12s, background .12s, color .12s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button-primary { color: white; background: var(--forest); box-shadow: 0 6px 18px rgba(23, 76, 67, .18); }
.button-primary:hover:not(:disabled) { background: var(--forest-deep); }
.button-secondary { color: var(--forest); background: var(--mint); }
.button-secondary:hover:not(:disabled) { background: #c9e6dc; }
.button-wide { width: 100%; padding: 13px; }
.topbar { position: sticky; top: 0; z-index: 20; height: 72px; display: grid; grid-template-columns: minmax(240px, 1fr) auto minmax(240px, 1fr); align-items: center; padding: 0 30px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; width: max-content; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .04em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.topnav { align-self: stretch; display: flex; gap: 6px; }
.nav-link { position: relative; padding: 0 14px; border: 0; background: transparent; color: var(--muted); font-weight: 650; cursor: pointer; }
.nav-link::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 3px; background: var(--forest); transform: scaleX(0); }
.nav-link.active { color: var(--ink); }
.nav-link.active::after { transform: scaleX(1); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 4px; border-radius: 10px; background: #edf2f0; font-size: 11px; }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 12px; }
.mode-badge { padding: 5px 9px; border-radius: 999px; background: var(--amber); color: #775b12; font-size: 12px; font-weight: 700; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--white); cursor: pointer; }
.icon-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
main { width: min(1540px, 100%); margin: 0 auto; padding: 34px 32px 70px; }
.view { display: none; }
.active-view { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 26px; }
.page-head h1 { margin: 0 0 7px; font-size: clamp(30px, 4vw, 45px); letter-spacing: -.04em; line-height: 1.05; }
.page-head p { margin: 0; max-width: 680px; color: var(--muted); line-height: 1.5; }
.generator-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(350px, .85fr); gap: 24px; align-items: start; }
.input-column { display: grid; gap: 16px; }
.form-section, .result-panel, .history-table-wrap, .prompt-editor, .prompt-list, .compare-panel { background: var(--white); border: 1px solid var(--line); box-shadow: 0 8px 25px rgba(23, 48, 43, .035); }
.form-section { padding: 23px; border-radius: var(--radius); }
.section-head { display: flex; align-items: center; gap: 13px; margin-bottom: 21px; }
.section-head h2 { margin: 0 0 3px; font-size: 18px; letter-spacing: -.015em; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }
.step { flex: 0 0 auto; width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--forest); font-size: 13px; font-weight: 750; }
.section-count { margin-left: auto; padding: 5px 9px; border-radius: 8px; background: var(--paper); color: var(--muted); font-size: 12px; font-weight: 650; }
.field-grid { display: grid; gap: 15px; margin-bottom: 15px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-section > label + label { margin-top: 15px; }
.tabs { display: flex; gap: 4px; }
.compact-tabs { width: max-content; margin-bottom: 14px; padding: 3px; background: var(--paper); border-radius: 9px; }
.tab { border: 0; border-radius: 7px; padding: 7px 12px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }
.tab.active { color: var(--ink); background: var(--white); box-shadow: 0 2px 7px rgba(24, 34, 35, .08); }
.program-cards { display: grid; gap: 10px; }
.program-card { position: relative; display: grid; grid-template-columns: 90px minmax(180px, 1.4fr) minmax(130px, .8fr) minmax(130px, .8fr); gap: 10px; padding: 14px; background: #f9fbfa; border: 1px solid var(--line); border-radius: 10px; }
.program-card label { font-size: 11px; color: var(--muted); }
.program-card input { padding: 9px 10px; font-size: 13px; }
.remove-program { position: absolute; right: -9px; top: -9px; width: 24px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--muted); cursor: pointer; }
.add-button { width: 100%; margin-top: 10px; padding: 10px; border: 1px dashed #afc0bc; border-radius: 9px; background: transparent; color: var(--forest); font-weight: 700; cursor: pointer; }
.add-button span { font-size: 18px; line-height: 0; }
#apply-json { margin-top: 10px; }
.settings-row { display: grid; grid-template-columns: 1fr 180px; gap: 20px; margin: 17px 0; align-items: end; }
.range-label { grid-template-columns: auto 40px; }
.range-label output { justify-self: end; color: var(--forest); }
.range-label input { grid-column: 1 / -1; padding: 0; accent-color: var(--forest); box-shadow: none; }
.fields-picker { margin: 18px 0 0; padding: 0; border: 0; }
.fields-picker legend { margin-bottom: 11px; font-size: 13px; font-weight: 700; }
.checkbox-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.check-item { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 8px 10px; background: var(--paper); border: 1px solid transparent; border-radius: 8px; font-weight: 600; cursor: pointer; }
.check-item:has(input:checked) { background: #edf7f3; border-color: #bddbd1; color: var(--forest-deep); }
.check-item input { width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--forest); box-shadow: none; }
.generate-bar { position: sticky; bottom: 12px; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 17px; border: 1px solid #b9d7cd; border-radius: 12px; background: rgba(239, 248, 245, .96); box-shadow: 0 14px 35px rgba(23, 76, 67, .15); backdrop-filter: blur(12px); }
.generate-bar > div > strong, .generate-bar > div > span { display: block; }
.generate-bar > div > span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.spinner { width: 17px; height: 17px; border: 2px solid rgba(255,255,255,.45); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-panel { position: sticky; top: 96px; min-height: 580px; max-height: calc(100vh - 120px); overflow: auto; border-radius: 5px 24px 5px 5px; }
.empty-state { min-height: 578px; display: grid; place-content: center; justify-items: center; padding: 45px; text-align: center; }
.empty-symbol { height: 72px; display: flex; align-items: end; gap: 7px; transform: skewX(-18deg); }
.empty-symbol span { display: block; width: 11px; height: 54px; border-radius: 3px; background: #b8d6ce; }
.empty-symbol span:nth-child(2) { height: 40px; }
.empty-symbol span:nth-child(3) { height: 26px; }
.empty-state h2 { margin: 18px 0 8px; font-size: 21px; }
.empty-state p { max-width: 330px; margin: 0; color: var(--muted); line-height: 1.5; }
#result-content { padding: 22px; }
.result-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.result-kicker { margin: 0 0 4px; color: var(--muted); font-size: 12px; }
.result-head h2 { margin: 0; font-size: 20px; }
.status { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.status.success { color: #1c664c; background: #ddf3e9; }
.status.failed { color: #8e322d; background: #f9dfdc; }
.status.approved { color: #4d610b; background: #ebf3c9; }
.result-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 14px 0; }
.meta-item { padding: 9px; border-radius: 8px; background: var(--paper); }
.meta-item span, .meta-item strong { display: block; }
.meta-item span { color: var(--muted); font-size: 10px; }
.meta-item strong { margin-top: 3px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warnings { margin-bottom: 13px; padding: 12px; border-left: 3px solid #c9972a; background: #fff9e9; font-size: 12px; line-height: 1.45; }
.warnings ul { margin: 6px 0 0; padding-left: 17px; }
.result-fields { display: grid; gap: 11px; }
.result-field { padding: 13px; border: 1px solid var(--line); border-radius: 10px; }
.result-field-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.result-field-head strong { font-size: 12px; }
.copy-button { border: 0; background: transparent; color: var(--forest); font-size: 11px; font-weight: 700; cursor: pointer; }
.result-field textarea { border: 0; background: transparent; padding: 0; min-height: 85px; box-shadow: none; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.export-menu { margin-left: auto; display: flex; gap: 4px; }
.text-button { border: 0; padding: 8px; background: transparent; color: var(--forest); font-size: 12px; font-weight: 700; cursor: pointer; }
.raw-details { margin-top: 14px; color: var(--muted); font-size: 12px; }
.raw-details pre { overflow: auto; max-height: 260px; padding: 12px; border-radius: 8px; background: #162522; color: #d7e7e2; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.history-table-wrap { border-radius: var(--radius); overflow: hidden; }
.history-table { width: 100%; border-collapse: collapse; }
.history-table th { padding: 12px 15px; background: #edf2f0; color: var(--muted); font-size: 11px; text-align: left; }
.history-table td { padding: 14px 15px; border-top: 1px solid var(--line); font-size: 13px; }
.history-table td strong, .history-table td small { display: block; }
.history-table td small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.history-table tbody tr { cursor: pointer; }
.history-table tbody tr:hover { background: #f8faf9; }
.history-table input { width: 16px; height: 16px; accent-color: var(--forest); box-shadow: none; }
.table-empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.compare-panel { margin-top: 20px; padding: 22px; border-radius: var(--radius); }
.compare-panel h2 { margin: 0 0 16px; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.compare-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.compare-card h3 { margin: 0 0 4px; }
.compare-card pre { margin: 12px 0 0; white-space: pre-wrap; font: 12px/1.5 inherit; }
.prompt-layout { display: grid; grid-template-columns: minmax(280px, .7fr) minmax(480px, 1.3fr); gap: 20px; align-items: start; }
.prompt-list, .prompt-editor { border-radius: var(--radius); padding: 20px; }
.prompt-item { padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.prompt-item:last-child { border-bottom: 0; }
.prompt-item strong, .prompt-item span { display: block; }
.prompt-item span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.prompt-editor { display: grid; gap: 15px; }
.prompt-editor h2 { margin: 0; }
.editor-note { margin: 0; color: var(--muted); font-size: 12px; }
.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: grid; gap: 8px; }
.toast { max-width: 390px; padding: 13px 16px; border-radius: 10px; background: #172925; color: white; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: #7e302c; }
@media (max-width: 1050px) {
  .topbar { display: block; height: 60px; padding: 0; }
  .topbar .brand, .top-actions { display: none; }
  .topnav { height: 60px; justify-content: center; }
  main { padding-bottom: 40px; }
  .generator-layout { grid-template-columns: 1fr; }
  .result-panel { position: static; max-height: none; min-height: 420px; }
  .empty-state { min-height: 420px; }
}
@media (max-width: 720px) {
  main { padding: 24px 14px 44px; }
  .page-head { align-items: start; flex-direction: column; }
  .page-head h1 { font-size: 34px; }
  .field-grid.two, .settings-row, .checkbox-grid, .prompt-layout, .compare-grid { grid-template-columns: 1fr; }
  .program-card { grid-template-columns: 80px 1fr; }
  .form-section { padding: 18px; }
  .generate-bar { align-items: stretch; flex-direction: column; }
  .generate-bar .button { width: 100%; }
  .history-table th:nth-child(3), .history-table td:nth-child(3), .history-table th:nth-child(5), .history-table td:nth-child(5), .history-table th:nth-child(6), .history-table td:nth-child(6) { display: none; }
  .login-card { padding: 30px 24px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
