:root {
  --ink: #0c1617;
  --muted: #637577;
  --line: #d7e4e2;
  --paper: #f4f8f8;
  --panel: #ffffff;
  --panel-soft: #eef6f5;
  --teal: #00a99d;
  --teal-dark: #075d59;
  --cyan: #00d7ff;
  --blue: #275efe;
  --amber: #e5a942;
  --rose: #a9495b;
  --shadow: 0 22px 60px rgba(7, 31, 34, 0.16);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(rgba(13, 26, 29, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 26, 29, 0.035) 1px, transparent 1px),
    linear-gradient(120deg, rgba(0, 215, 255, 0.08), transparent 34%, rgba(229, 169, 66, 0.06) 72%, transparent),
    linear-gradient(180deg, #f7fbfb, #eef7f7),
    var(--paper);
  background-size: 40px 40px, 40px 40px, auto, auto, auto;
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 20px;
  height: 72px;
  padding: 0 clamp(18px, 4vw, 52px);
  background: rgba(247, 252, 252, 0.78);
  border-bottom: 1px solid rgba(183, 216, 213, 0.72);
  box-shadow: 0 10px 34px rgba(7, 31, 34, 0.08);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--teal-dark);
}

.brand-logo {
  display: block;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #fff;
  object-fit: cover;
  object-position: center;
  filter: invert(1) contrast(1.16) brightness(1.06);
  box-shadow: 0 0 0 1px rgba(7, 31, 34, 0.1), 0 8px 18px rgba(7, 31, 34, 0.08);
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
}

.nav-links a:hover {
  color: var(--ink);
}

.account-bar {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.credit-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
  white-space: nowrap;
}

.user-menu-wrap {
  position: relative;
}

.user-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 10px 0 8px;
  border: 1px solid rgba(185, 224, 222, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(7, 31, 34, 0.08);
  backdrop-filter: blur(12px);
}

.user-avatar-small,
.user-profile-avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #eadcff;
  color: #6d3ee8;
  font-weight: 900;
}

.user-avatar-small {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

.user-button-meta {
  display: grid;
  gap: 1px;
  text-align: left;
}

.user-button-meta > span {
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.user-menu-button strong {
  color: var(--teal-dark);
  font-size: 12px;
}

.user-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  width: min(360px, calc(100vw - 28px));
  padding: 18px;
  border: 1px solid rgba(213, 222, 220, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 50px rgba(7, 31, 34, 0.14);
  backdrop-filter: blur(16px);
}

.user-menu::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 28px;
  width: 12px;
  height: 12px;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  background: #fff;
  transform: rotate(45deg);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.user-profile-avatar {
  width: 48px;
  height: 48px;
  font-size: 18px;
}

.user-profile-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.user-profile-main strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-profile-main small {
  color: #9aa6a4;
  font-size: 12px;
}

.user-menu-list {
  display: grid;
  gap: 4px;
  padding-top: 12px;
}

.user-menu-row {
  display: grid;
  grid-template-columns: 26px minmax(90px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 42px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font: inherit;
}

button.user-menu-row {
  cursor: pointer;
}

button.user-menu-row:hover {
  background: var(--panel-soft);
}

.user-menu-row strong {
  font-size: 14px;
}

.user-menu-row span:last-child {
  justify-self: end;
  overflow: hidden;
  color: #9aa6a4;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-icon {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

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

.mini-empty {
  display: grid;
  min-height: 62px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.mini-log-item {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(223, 230, 224, 0.75);
}

.mini-log-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.mini-log-item div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.mini-log-item span,
.mini-log-item small {
  color: var(--muted);
  font-size: 12px;
}

.mini-log-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.credit-modal-card {
  width: min(560px, 100%);
}

.credit-modal-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 64px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.credit-modal-summary strong {
  font-size: 28px;
}

.credit-modal-list {
  display: grid;
  gap: 8px;
  max-height: min(460px, 62vh);
  overflow: auto;
}

.credit-modal-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.credit-modal-item div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.credit-modal-item span,
.credit-modal-item small {
  color: var(--muted);
  font-size: 12px;
}

.credit-modal-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghost-button,
.solid-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 700;
}

.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.ghost-button:hover,
.icon-button:hover {
  border-color: var(--teal);
}

.solid-button {
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  color: #fff;
  border-color: var(--teal);
}

.solid-button:hover {
  background: linear-gradient(135deg, #053f3d, var(--cyan));
  border-color: var(--teal-dark);
}

.solid-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.icon-button {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--ink);
}

.hero {
  position: relative;
  min-height: 86vh;
  display: flex;
  align-items: flex-end;
  padding: 130px clamp(18px, 5vw, 70px) 92px;
  overflow: hidden;
  background-image: url("/assets/hero-ai-video.png");
  background-size: cover;
  background-position: center;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(90deg, #000 0%, transparent 76%);
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 150px;
  background: linear-gradient(to bottom, rgba(251, 251, 247, 0), var(--paper));
  pointer-events: none;
}

.hero-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(3, 14, 17, 0.9) 0%, rgba(5, 31, 34, 0.67) 44%, rgba(5, 31, 34, 0.16) 100%),
    linear-gradient(180deg, rgba(0, 215, 255, 0.08), rgba(0, 169, 157, 0.1));
}

.hero-content {
  position: relative;
  z-index: 2;
  width: min(760px, 100%);
  color: #fff;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(44px, 7vw, 86px);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-copy {
  width: min(660px, 100%);
  margin: 22px 0 28px;
  color: rgba(255, 255, 255, 0.88);
  font-size: clamp(17px, 2vw, 22px);
}

.quick-prompt {
  display: grid;
  grid-template-columns: 1fr auto;
  width: min(760px, 100%);
  min-height: 62px;
  padding: 8px;
  border: 1px solid rgba(140, 244, 238, 0.36);
  border-radius: 8px;
  background: rgba(2, 18, 21, 0.38);
  box-shadow: 0 0 0 1px rgba(0, 215, 255, 0.08), 0 18px 50px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(14px);
}

.quick-prompt input {
  min-width: 0;
  border: 0;
  padding: 0 14px;
  color: #fff;
  background: transparent;
  outline: none;
}

.quick-prompt input::placeholder {
  color: rgba(255, 255, 255, 0.64);
}

.model-strip {
  display: none;
  position: relative;
  z-index: 4;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: -34px auto 0;
  width: min(1120px, calc(100% - 36px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.model-strip div {
  min-height: 86px;
  padding: 18px;
  background: #fff;
}

.muted {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.model-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.workspace-band,
.account-band,
.admin-band {
  padding: 78px clamp(18px, 5vw, 70px);
}

.workspace-band {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(239, 249, 249, 0.92)),
    linear-gradient(115deg, rgba(0, 215, 255, 0.1), transparent 42%, rgba(229, 169, 66, 0.08));
}

.workspace-band::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(12, 60, 65, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(12, 60, 65, 0.05) 1px, transparent 1px);
  background-size: 34px 34px;
  pointer-events: none;
}

.workspace-band > * {
  position: relative;
  z-index: 1;
}

.section-head {
  width: min(1120px, 100%);
  margin: 0 auto 26px;
}

.section-head h1,
.section-head h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: 0;
  color: #071416;
}

.section-head p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
}

.section-head.compact {
  margin-bottom: 18px;
}

.workspace-grid {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  gap: 18px;
  align-items: start;
}

.composer-workspace {
  grid-template-columns: 1fr;
  width: min(1200px, 100%);
}

.panel {
  border: 1px solid rgba(185, 224, 222, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 16px 44px rgba(7, 31, 34, 0.08);
  backdrop-filter: blur(14px);
}

.composer-panel {
  display: grid;
  gap: 12px;
  min-height: 176px;
  padding: 18px;
  border: 1px solid rgba(151, 231, 228, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(239, 250, 250, 0.88)),
    rgba(255, 255, 255, 0.94);
  box-shadow: 0 20px 60px rgba(7, 31, 34, 0.12), 0 0 0 1px rgba(0, 215, 255, 0.08);
  backdrop-filter: blur(16px);
}

.composer-canvas {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 18px;
  min-height: 88px;
  align-items: start;
}

.reference-tile {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  width: 48px;
  min-height: 70px;
  margin-left: 2px;
  border: 1px solid rgba(0, 169, 157, 0.42);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(223, 247, 246, 0.82));
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  transform: rotate(-7deg);
  transition: border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.reference-tile:hover,
.reference-tile.has-files {
  color: var(--teal);
  border-color: rgba(0, 215, 255, 0.72);
  box-shadow: 0 12px 28px rgba(0, 169, 157, 0.18);
  transform: rotate(-3deg) translateY(-1px);
}

.reference-plus {
  display: block;
  font-size: 20px;
  line-height: 1;
}

.composer-canvas textarea {
  min-height: 86px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  resize: none;
  box-shadow: none;
}

.composer-canvas textarea:focus {
  border-color: transparent;
  box-shadow: none;
}

.composer-canvas textarea::placeholder {
  color: #7f8d88;
}

.reference-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 82px;
}

.reference-chip {
  display: inline-flex;
  max-width: 240px;
  min-height: 30px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.reference-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-chip button {
  display: inline-grid;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #e7ece8;
  color: var(--muted);
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  padding: 0;
}

.reference-chip button:hover {
  background: var(--rose);
  color: #fff;
}

.composer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.composer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.composer-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  max-width: 100%;
  padding: 0 11px;
  border: 1px solid rgba(185, 224, 222, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.composer-pill:hover {
  border-color: rgba(0, 169, 157, 0.48);
  box-shadow: 0 0 0 3px rgba(0, 215, 255, 0.08);
}

.composer-pill.fixed {
  color: #303a36;
}

.composer-pill.compact {
  padding-right: 8px;
}

.pill-icon {
  color: var(--teal);
  font-weight: 900;
  line-height: 1;
}

.composer-pill select {
  width: auto;
  min-height: 34px;
  max-width: 190px;
  padding: 0 18px 0 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: inherit;
  outline: none;
}

.composer-submit {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.send-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--cyan));
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}

.send-button:hover {
  background: linear-gradient(135deg, var(--teal-dark), var(--cyan));
  box-shadow: 0 10px 26px rgba(0, 169, 157, 0.28);
}

.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.generator-panel,
.status-panel,
.panel {
  padding: 20px;
}

.field-group {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field-group label,
.auth-form label {
  font-size: 14px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input[type="file"] {
  padding: 9px 12px;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 142px;
  padding: 12px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0 0 16px;
  padding: 6px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.segmented button,
.auth-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.active,
.auth-tabs button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 12px rgba(23, 32, 29, 0.08);
}

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

.form-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding-top: 4px;
}

.cost-preview {
  color: var(--muted);
  font-weight: 700;
}

.cost-preview strong {
  color: var(--ink);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title-row h3 {
  margin: 0;
  font-size: 22px;
}

.job-list,
.admin-job-list,
.credit-log {
  display: grid;
  gap: 10px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 140px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.job-item,
.credit-item,
.admin-job {
  border: 1px solid rgba(185, 224, 222, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 14px;
}

.job-top,
.credit-item,
.admin-job {
  display: grid;
  gap: 6px;
}

.job-meta,
.admin-job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--teal-dark);
  font-weight: 800;
  font-size: 12px;
}

.status-badge.failed {
  color: var(--rose);
}

.estimate-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid rgba(41, 210, 222, 0.28);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(41, 210, 222, 0.12), rgba(10, 132, 122, 0.1));
  color: var(--teal-dark);
  font-weight: 800;
  font-size: 12px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #e8ece8;
  margin-top: 10px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--cyan), var(--amber));
}

.job-video {
  width: 100%;
  margin-top: 12px;
  border-radius: 8px;
  background: #101715;
  aspect-ratio: 16 / 9;
}

.account-band {
  background: #eef2ec;
}

.admin-band {
  background: #fff;
}

.admin-page {
  background: #f7f8f4;
}

.admin-shell {
  min-height: 100vh;
  padding-top: 72px;
}

.admin-band.standalone {
  min-height: calc(100vh - 72px);
  padding: 84px clamp(28px, 4vw, 72px);
}

.admin-login {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
  padding: 36px 18px;
}

.admin-login-card {
  width: min(430px, 100%);
}

.admin-login-card h1 {
  margin: 0 0 18px;
  font-size: 34px;
}

.admin-login-note {
  margin: 16px 0 0;
}

.admin-page .section-head,
.admin-page .stats-grid,
.admin-page .admin-grid,
.admin-page .admin-hero,
.admin-page .admin-tabs,
.admin-page .admin-dashboard-grid {
  width: min(1360px, calc(100vw - 80px));
}

.admin-hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin: 0 auto 24px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(211, 144, 47, 0.08)),
    #fff;
  box-shadow: 0 12px 32px rgba(23, 32, 29, 0.07);
}

.admin-hero h1 {
  margin: 0;
  font-size: clamp(42px, 4vw, 58px);
  letter-spacing: 0;
}

.admin-hero p:last-child {
  margin: 10px 0 0;
}

.admin-page .section-head {
  margin-bottom: 28px;
}

.admin-page .section-head h1 {
  font-size: clamp(42px, 4vw, 58px);
}

.admin-page .stats-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.admin-page .stat {
  min-height: 104px;
  padding: 18px;
  background: #fff;
}

.admin-page .stat strong {
  font-size: 30px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin: 0 auto 16px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.admin-tabs button {
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.admin-tabs button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 12px rgba(23, 32, 29, 0.08);
}

.admin-dashboard-grid {
  margin: 0 auto;
}

.admin-module {
  min-height: 420px;
}

.admin-page .admin-grid {
  grid-template-columns: minmax(760px, 1.6fr) minmax(380px, 0.9fr);
  gap: 20px;
}

.admin-page .panel {
  padding: 24px;
}

.admin-page .table-wrap {
  overflow-x: visible;
}

.admin-page .admin-table {
  min-width: 0;
  table-layout: fixed;
}

.admin-page .admin-table th,
.admin-page .admin-table td {
  padding: 14px 10px;
}

.admin-page .admin-table th:nth-child(1),
.admin-page .admin-table td:nth-child(1) {
  width: 26%;
}

.admin-page .admin-table th:nth-child(2),
.admin-page .admin-table td:nth-child(2),
.admin-page .admin-table th:nth-child(3),
.admin-page .admin-table td:nth-child(3) {
  width: 16%;
}

.admin-page .admin-table th:nth-child(4),
.admin-page .admin-table td:nth-child(4) {
  width: 10%;
}

.admin-page .admin-table th:nth-child(5),
.admin-page .admin-table td:nth-child(5) {
  width: 32%;
}

.admin-page .admin-table input,
.admin-page .admin-table select {
  min-height: 40px;
}

.admin-page .admin-actions {
  grid-template-columns: minmax(120px, 1fr) auto;
}

.admin-page .admin-actions [data-user-save] {
  grid-column: 1 / -1;
}

.admin-page .credit-detail-table {
  min-width: 980px;
}

.admin-page .credit-detail-table th:nth-child(1),
.admin-page .credit-detail-table td:nth-child(1) {
  width: 12%;
}

.admin-page .credit-detail-table th:nth-child(2),
.admin-page .credit-detail-table td:nth-child(2) {
  width: 22%;
}

.admin-page .credit-detail-table th:nth-child(3),
.admin-page .credit-detail-table td:nth-child(3) {
  width: 14%;
}

.admin-page .credit-detail-table th:nth-child(4),
.admin-page .credit-detail-table td:nth-child(4),
.admin-page .credit-detail-table th:nth-child(5),
.admin-page .credit-detail-table td:nth-child(5) {
  width: 10%;
}

.admin-page .credit-detail-table th:nth-child(6),
.admin-page .credit-detail-table td:nth-child(6) {
  width: 32%;
}

.credit-plus {
  color: var(--teal-dark);
}

.credit-minus {
  color: var(--rose);
}

.stats-grid {
  width: min(1120px, 100%);
  margin: 0 auto 18px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 16px;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.admin-grid {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--muted);
  font-size: 13px;
}

.admin-table input,
.admin-table select {
  min-height: 36px;
}

.admin-actions {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto;
  gap: 8px;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(8, 15, 14, 0.56);
  backdrop-filter: blur(8px);
}

.auth-modal[aria-hidden="false"] {
  display: grid;
}

.auth-card {
  position: relative;
  width: min(420px, 100%);
  border-radius: 8px;
  padding: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0 0 18px;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 24px;
  line-height: 1;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  margin-bottom: 18px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: none;
  max-width: min(420px, calc(100vw - 36px));
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
}

[hidden] {
  display: none !important;
}

@media (max-width: 920px) {
  .site-header {
    grid-template-columns: 1fr auto;
    height: auto;
    min-height: 68px;
    padding: 12px 18px;
  }

  .nav-links {
    display: none;
  }

  .account-bar {
    gap: 8px;
  }

  .credit-pill {
    display: none;
  }

  .user-menu {
    right: -8px;
  }

  .hero {
    min-height: 82vh;
    padding: 118px 18px 58px;
  }

  .quick-prompt {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .quick-prompt input {
    min-height: 46px;
  }

  .model-strip,
  .workspace-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .composer-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .composer-submit {
    justify-content: space-between;
  }

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

  .admin-page .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-hero {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .account-bar .ghost-button {
    padding: 0 10px;
  }

  .user-menu-grid,
  .user-menu-actions {
    grid-template-columns: 1fr;
  }

  .user-menu-row {
    grid-template-columns: 24px minmax(82px, auto) minmax(0, 1fr);
  }

  .hero h1 {
    font-size: 44px;
  }

  .model-strip {
    grid-template-columns: 1fr;
  }

  .workspace-band,
  .account-band,
  .admin-band {
    padding: 58px 14px;
  }

  .field-grid,
  .segmented {
    grid-template-columns: 1fr;
  }

  .composer-panel {
    padding: 14px;
  }

  .composer-canvas {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .reference-tile {
    width: 100%;
    min-height: 54px;
    grid-template-columns: auto auto;
    justify-content: center;
    transform: none;
  }

  .reference-tile:hover,
  .reference-tile.has-files {
    transform: none;
  }

  .reference-preview {
    padding-left: 0;
  }

  .composer-controls,
  .composer-pill {
    width: 100%;
  }

  .composer-pill select {
    flex: 1;
    max-width: none;
  }

  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .admin-page .stats-grid {
    grid-template-columns: 1fr;
  }

  .admin-page .admin-hero,
  .admin-page .admin-tabs,
  .admin-page .admin-dashboard-grid {
    width: min(100%, calc(100vw - 28px));
  }

  .admin-tabs {
    flex-direction: column;
  }
}
