:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --bg-soft: #fbf7ef;
  --ink: #19221f;
  --muted: #64716b;
  --card: rgba(255, 252, 245, 0.88);
  --line: rgba(35, 47, 42, 0.12);
  --accent: #2e6f6a;
  --accent-dark: #174c48;
  --amber: #b66a30;
  --sage: #d9e4d3;
  --danger: #9f2d2d;
  --shadow: 0 24px 70px rgba(39, 46, 40, 0.15);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(46, 111, 106, 0.18), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(182, 106, 48, 0.15), transparent 28rem),
    linear-gradient(135deg, var(--bg), #eef3ed);
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.glass-card {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: var(--radius-lg);
}

.login-card {
  width: min(540px, 100%);
  padding: 42px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 14px 30px rgba(46, 111, 106, 0.22);
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 0.85rem;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3, p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 12px 0;
  font-size: clamp(2.3rem, 4vw, 4.5rem);
  line-height: 0.96;
  letter-spacing: -0.06em;
}

h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
  letter-spacing: -0.035em;
}

h3 {
  margin: 0 0 8px;
}

.lead {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.form-stack {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(46, 111, 106, 0.58);
  box-shadow: 0 0 0 4px rgba(46, 111, 106, 0.13);
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

.primary-button, .ghost-button, .small-button {
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 800;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.primary-button {
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  box-shadow: 0 14px 28px rgba(46, 111, 106, 0.22);
}

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

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.primary-button.wide {
  width: 100%;
  margin-top: 12px;
}

.ghost-button, .small-button {
  padding: 11px 13px;
  background: rgba(25, 34, 31, 0.07);
  color: var(--ink);
}

.credential-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.56);
}

.credential-box span, .muted, .fine-print {
  color: var(--muted);
}

.credential-box strong {
  display: block;
  margin-top: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.message {
  min-height: 1.3em;
  color: var(--danger);
  font-weight: 700;
}

.dashboard-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: rgba(20, 27, 25, 0.91);
  color: white;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.sidebar-brand span {
  display: block;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.88rem;
  margin-top: 2px;
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.sidebar a {
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.sidebar a.active, .sidebar a:hover {
  color: white;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar .ghost-button {
  margin-top: auto;
  color: white;
  background: rgba(255, 255, 255, 0.12);
}

.main-content {
  padding: 28px;
  display: grid;
  gap: 22px;
}

.hero-panel {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(26px, 4vw, 46px);
  overflow: hidden;
}

.hero-panel h1 {
  max-width: 780px;
}

.hero-panel .lead {
  max-width: 780px;
}

.hero-stats, .usage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 12px;
}

.hero-stats {
  align-self: end;
  min-width: min(360px, 100%);
}

.hero-stats div, .usage-grid div {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
}

.hero-stats span, .usage-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.hero-stats strong, .usage-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
}

.controls-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 16px;
}

.notice-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border: 1px solid rgba(182, 106, 48, 0.24);
  border-radius: var(--radius-lg);
  background: rgba(255, 246, 226, 0.82);
}

.notice-panel p {
  margin: 8px 0 0;
  color: #5f5144;
  line-height: 1.55;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 22px;
  align-items: start;
}

.template-section, .test-panel, .output-section, .usage-panel {
  padding: 24px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  margin-bottom: 18px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.template-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  background: rgba(255, 255, 255, 0.62);
  display: grid;
  gap: 10px;
}

.template-card.locked {
  opacity: 0.56;
}

.template-card.selected {
  border-color: rgba(46, 111, 106, 0.64);
  box-shadow: 0 0 0 4px rgba(46, 111, 106, 0.11);
}

.template-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  padding: 8px 11px;
  border-radius: 999px;
  background: rgba(46, 111, 106, 0.13);
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 900;
}

.muted-pill {
  background: rgba(25, 34, 31, 0.08);
  color: var(--muted);
}

.locked-pill {
  background: rgba(159, 45, 45, 0.1);
  color: var(--danger);
}

.template-details {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.55);
  line-height: 1.5;
  margin-bottom: 16px;
}

.template-details ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.textarea-label {
  margin-top: 14px;
}

.input-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}


.compact-heading {
  margin-bottom: 12px;
}

.estimate-panel {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(46, 111, 106, 0.2);
  border-radius: var(--radius-md);
  background: rgba(241, 248, 244, 0.82);
}

.estimate-panel h3 {
  margin: 0;
}

.estimate-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
}

.cost-grid {
  margin-top: 10px;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.estimate-grid div {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.68);
}

.estimate-grid span,
.model-estimate-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.estimate-grid strong,
.model-estimate-item strong {
  display: block;
  margin-top: 5px;
  font-size: 1.1rem;
}

.model-estimate-details {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.52);
  overflow: hidden;
}

.model-estimate-details summary {
  cursor: pointer;
  padding: 12px 13px;
  font-weight: 900;
  color: var(--accent-dark);
}

.model-estimate-list {
  display: grid;
  gap: 8px;
  padding: 0 13px 13px;
}

.model-estimate-item {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, minmax(80px, 0.8fr));
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.66);
}

.model-estimate-item code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 900;
  color: var(--accent-dark);
  overflow-wrap: anywhere;
}

.model-estimate-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.model-estimate-item.selected-model {
  border-color: rgba(46, 111, 106, 0.46);
  box-shadow: 0 0 0 3px rgba(46, 111, 106, 0.1);
}

.checkbox-row {
  display: flex;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  margin-top: 16px;
  color: var(--ink);
  line-height: 1.45;
}

.checkbox-row input {
  width: auto;
  margin-top: 3px;
}

.output-box {
  min-height: 260px;
  padding: 20px;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(25, 34, 31, 0.93);
  color: #f8f6ee;
  line-height: 1.55;
}

.usage-panel .usage-grid, .output-section .usage-grid {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  margin-top: 14px;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(25, 34, 31, 0.09);
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--amber));
  transition: width 0.2s ease;
}

.fine-print {
  font-size: 0.88rem;
  line-height: 1.45;
}

@media (max-width: 1120px) {
  .dashboard-view {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
  }
  .sidebar nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .workspace-grid, .hero-panel {
    grid-template-columns: 1fr;
    display: grid;
  }
  .controls-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 720px) {
  .login-card, .template-section, .test-panel, .output-section, .usage-panel, .hero-panel {
    padding: 20px;
  }
  .main-content {
    padding: 16px;
  }
  .sidebar nav, .controls-grid, .hero-stats, .usage-panel .usage-grid, .output-section .usage-grid, .estimate-grid, .cost-grid, .model-estimate-item {
    grid-template-columns: 1fr;
  }
  .notice-panel, .section-heading {
    display: grid;
  }
}

.template-module-label {
  margin: -0.35rem 0 0.45rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}
