:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-strong: #eef6ff;
  --text: #111827;
  --muted: #64748b;
  --border: #d8e3f0;
  --accent: #1683ff;
  --accent-dark: #0b6fe8;
  --accent-soft: #e8f3ff;
  --accent-glow: rgba(22, 131, 255, 0.18);
  --gold: #b7791f;
  --danger: #b42318;
  --success: #087443;
  --warning: #c2410c;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
}

/* 波点 AI approved UI layer */
body {
  background:
    radial-gradient(circle at 10% 8%, rgba(37, 99, 235, 0.08), transparent 26%),
    radial-gradient(circle at 92% 84%, rgba(148, 163, 184, 0.12), transparent 24%),
    #f8fafc;
}

.login-screen {
  min-height: 100vh;
  padding: 28px 18px;
  background:
    radial-gradient(circle at 12% 12%, rgba(37, 99, 235, 0.1), transparent 26%),
    linear-gradient(135deg, #f8fbff 0%, #ffffff 55%, #f2f6fb 100%);
}

.login-shell {
  display: block;
  width: min(560px, 100%);
}

.login-hero {
  display: none;
}

.login-card {
  gap: 16px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 70px rgba(30, 64, 175, 0.12);
  padding: clamp(28px, 6vw, 48px);
}

.login-card-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.login-card-brand .brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

.login-card-brand div {
  display: grid;
  gap: 2px;
}

.login-card-brand strong {
  color: #0f172a;
  font-size: 23px;
  letter-spacing: 0.02em;
}

.login-card-brand span {
  color: #64748b;
  font-size: 13px;
  letter-spacing: 0.18em;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 36px);
  letter-spacing: -0.03em;
}

.login-card p {
  margin: 0;
}

.login-tabs {
  border: 0;
  border-bottom: 1px solid #e2e8f0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.login-tabs button {
  border-radius: 10px 10px 0 0;
  padding: 12px 8px;
}

.login-tabs button.active {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.auth-form label {
  color: #334155;
  font-size: 13px;
  font-weight: 800;
  margin-top: 2px;
}

.auth-form input {
  min-height: 48px;
  border-radius: 11px;
  border-color: #d6deea;
  background: #ffffff;
  padding: 0 14px;
}

.auth-form .primary {
  min-height: 50px;
  margin-top: 6px;
  border-radius: 11px;
  background: linear-gradient(135deg, #2563eb, #1769e8);
}

.app {
  width: min(1480px, calc(100vw - 48px));
  padding: 20px 0 28px;
}

.topbar {
  margin-bottom: 18px;
  border: 0;
  border-bottom: 1px solid rgba(203, 213, 225, 0.75);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 10px 2px 16px;
}

.brand h1 {
  margin: 0;
  color: #0f172a;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.brand p {
  margin: 3px 0 0;
  color: #94a3b8;
  font-size: 12px;
}

.app-nav {
  display: none;
}

.app-body,
body.admin-mode .app-body {
  grid-template-columns: 218px minmax(0, 1fr);
  gap: 28px;
}

.admin-sidebar {
  top: 20px;
  gap: 7px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.06);
  padding: 12px;
}

.sidebar-label {
  padding: 9px 10px 4px;
  color: #94a3b8;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.admin-sidebar button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  padding: 10px 12px;
  font-size: 14px;
}

.admin-sidebar button:hover,
.admin-sidebar button.active {
  border-color: #dbeafe;
  background: #eff6ff;
}

.admin-menu {
  margin-top: 10px;
  padding-top: 12px;
}

.admin-subnav button {
  min-height: 38px;
  border-radius: 10px;
  background: #f8fafc;
  font-size: 12px;
}

.tool-hub,
.admin-panel,
.workspace,
.health-view,
.canvas-view {
  border-radius: 20px;
}

.tool-hub {
  gap: 20px;
  border-color: rgba(226, 232, 240, 0.9);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.06);
  padding: clamp(20px, 3vw, 34px);
}

.tool-hub-head {
  align-items: center;
}

.tool-hub-head h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 38px);
  letter-spacing: -0.04em;
}

.tool-hub-head p {
  margin: 8px 0 0;
  color: #94a3b8;
}

.tool-hub-status {
  min-width: 168px;
  border-radius: 14px;
  background: #f8fbff;
  padding: 12px 14px;
}

.tool-search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(520px, 100%);
  min-height: 48px;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #ffffff;
  color: #94a3b8;
  padding: 0 14px;
}

.tool-search:focus-within {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.tool-search svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.tool-search input {
  width: 100%;
  border: 0;
  outline: 0;
  color: #0f172a;
  background: transparent;
}

.tool-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.tool-card {
  min-height: 176px;
  border-radius: 16px;
  background: #ffffff;
  padding: 18px;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.1);
}

.tool-card.tool-search-hidden {
  display: none;
}

.tool-empty {
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  color: #64748b;
  padding: 28px;
  text-align: center;
}

.account-menu {
  position: relative;
}

.account-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  border: 1px solid #dbe3ef;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #1e293b;
  cursor: pointer;
  padding: 5px 12px 5px 6px;
  font-weight: 800;
}

.account-trigger:hover,
.account-menu.open .account-trigger {
  border-color: #93c5fd;
  color: var(--accent);
}

.account-avatar {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: #eff6ff;
  overflow: hidden;
}

.account-avatar img {
  width: 100%;
  height: 100%;
}

.account-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chevron {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 160ms ease;
}

.account-menu.open .account-chevron {
  transform: rotate(180deg);
}

.account-dropdown {
  position: absolute;
  z-index: 20;
  top: calc(100% + 9px);
  right: 0;
  display: grid;
  min-width: 150px;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  padding: 6px;
}

.account-dropdown button {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #334155;
  cursor: pointer;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
}

.account-dropdown button:hover {
  background: #eff6ff;
  color: var(--accent);
}

.admin-head h2,
.tool-admin-panel-head h2 {
  letter-spacing: -0.03em;
}

@media (max-width: 980px) {
  .app {
    width: min(100vw - 24px, 760px);
  }

  .topbar {
    padding-inline: 0;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .app-body,
  body.admin-mode .app-body {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-menu {
    grid-column: 1 / -1;
  }

  .tool-hub-head {
    align-items: stretch;
    flex-direction: column;
  }

  .tool-hub-status {
    width: 100%;
  }
}

/* Administrator password recovery */
.auth-form-heading {
  display: grid;
  gap: 5px;
  margin-bottom: 4px;
}

.auth-form-heading strong {
  color: #0f172a;
  font-size: 18px;
}

.auth-form-heading span,
.admin-recovery-tools p {
  margin: 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.6;
}

.auth-form .auth-link {
  justify-self: center;
  border: 0;
  background: transparent;
  color: #2563eb;
  cursor: pointer;
  padding: 5px 8px;
  font-size: 13px;
  font-weight: 800;
}

.auth-form .auth-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

.admin-recovery-tools {
  display: grid;
  gap: 9px;
  margin-top: 4px;
  border-top: 1px solid #e2e8f0;
  padding-top: 14px;
}

.admin-recovery-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #475569;
  font-size: 13px;
}

.admin-recovery-status strong {
  color: #0f766e;
}

.password-form .secondary-action {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.recovery-code-panel {
  display: grid;
  gap: 8px;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  background: #ecfdf5;
  padding: 12px;
}

.recovery-code-panel span {
  color: #047857;
  font-size: 12px;
  font-weight: 800;
}

.recovery-code-panel code {
  overflow-wrap: anywhere;
  color: #064e3b;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.password-form .recovery-code-panel button,
.auth-form .recovery-code-panel button {
  min-height: 40px;
  border: 1px solid #6ee7b7;
  border-radius: 8px;
  background: #ffffff;
  color: #047857;
  cursor: pointer;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 850;
}

.admin-recovery-tools.hidden,
.recovery-code-panel.hidden {
  display: none;
}

@media (max-width: 520px) {
  .login-screen {
    padding: 12px;
  }

  .login-card {
    border-radius: 18px;
    padding: 24px 18px;
  }

  .login-tabs {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2px;
  }

  .login-tabs button {
    padding-inline: 4px;
    font-size: 12px;
  }

  .brand p {
    display: none;
  }

  .topbar-actions {
    gap: 6px;
  }

  .account-name {
    max-width: 90px;
  }

  .status {
    display: none;
  }

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

  .admin-menu {
    grid-column: auto;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #ffffff;
  color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", system-ui, sans-serif;
}

body.locked .app {
  display: none;
}

.login-screen {
  display: none;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
}

body.locked .login-screen {
  display: grid;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 430px);
  gap: 28px;
  width: min(1120px, 100%);
  align-items: stretch;
}

.login-hero {
  display: grid;
  align-content: center;
  gap: 22px;
  min-height: 620px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(239, 246, 255, 0.95)),
    repeating-linear-gradient(0deg, rgba(37, 99, 235, 0.04) 0 1px, transparent 1px 40px);
  box-shadow: var(--shadow);
  padding: 36px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #1e293b;
  font-size: 14px;
  font-weight: 850;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 24px rgba(22, 131, 255, 0.2);
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.login-hero h1 {
  max-width: 620px;
  font-size: clamp(34px, 4vw, 54px);
  line-height: 1.08;
  letter-spacing: 0;
}

.login-hero p {
  max-width: 580px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.75;
}

.login-preview {
  border: 1px solid #cbd7e8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.09);
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  gap: 7px;
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.preview-toolbar span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #cbd5e1;
}

.preview-grid {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 14px;
  padding: 16px;
}

.preview-settings,
.preview-result {
  display: grid;
  gap: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.preview-settings span,
.preview-result span {
  border-radius: 6px;
  background: #f1f5f9;
  color: #475467;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 750;
}

.mock-image {
  min-height: 150px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.18), transparent 48%),
    linear-gradient(160deg, #dbeafe, #ffffff 46%, #bbf7d0);
}

.login-card {
  display: grid;
  gap: 14px;
  align-content: center;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f9fc;
}

.login-tabs button {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 750;
}

.login-tabs button.active {
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

#adminEntryTab.active {
  color: #c2410c;
}

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

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

.app {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  padding: 16px 18px;
}

.app-body {
  display: grid;
  grid-template-columns: 188px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

body.admin-mode .app-body {
  grid-template-columns: 188px minmax(0, 1fr);
}

.app-content {
  min-width: 0;
}

.admin-sidebar {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 18px;
  gap: 10px;
  align-self: start;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.07);
  padding: 10px;
}

body.admin-mode .admin-sidebar {
  display: flex;
  flex-direction: column;
}

.sidebar-label {
  color: #7b8798;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  padding: 4px 4px 0;
}

.admin-sidebar button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.side-icon,
.nav-icon {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: #e8f3ff;
  color: var(--accent);
}

.side-icon.health,
#navHealth .nav-icon {
  background: #ecfdf5;
  color: #047857;
}

.side-icon.canvas,
#navCanvas .nav-icon {
  background: #eef2ff;
  color: #4f46e5;
}

.side-icon.home,
#navHome .nav-icon {
  background: #fff7ed;
  color: #c2410c;
}

.side-icon svg,
.nav-icon svg,
.tool-visual svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.admin-sidebar button:hover,
.admin-sidebar button.active {
  background: #eff6ff;
}

.admin-sidebar button.active {
  color: var(--accent);
  border-color: #bfdbfe;
}

.admin-menu {
  display: none;
  gap: 8px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

body.admin-mode .admin-menu {
  display: grid;
}

.admin-subnav {
  display: grid;
  gap: 7px;
  padding-left: 10px;
}

.admin-subnav button {
  position: relative;
  padding: 9px 10px;
  font-size: 12px;
  color: #526177;
  background: #fbfdff;
}

.admin-subnav button::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 50%;
  width: 7px;
  height: 1px;
  background: #cdd8e7;
}

.admin-subnav button.active {
  color: var(--accent);
  background: #eff6ff;
  border-color: #bfdbfe;
}

.admin-sidebar .status {
  width: 100%;
  min-width: 0;
  border-radius: 7px;
  box-shadow: none;
}

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

.app-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.app-nav button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #526177;
  cursor: pointer;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.app-nav button:hover {
  border-color: #bfdbfe;
  color: var(--accent);
}

.app-nav button.active {
  border-color: #bfdbfe;
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.tool-hub {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  border: 1px solid rgba(213, 223, 235, 0.92);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 16px;
}

.tool-hub-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.tool-hub-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.tool-hub-status {
  display: grid;
  gap: 3px;
  min-width: 150px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #f8fbff;
  padding: 10px 12px;
}

.tool-hub-status span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tool-hub-status strong {
  color: var(--accent);
  font-size: 14px;
}

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

.tool-card {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  gap: 7px 12px;
  min-height: 128px;
  align-content: start;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  color: #172033;
  cursor: pointer;
  padding: 12px;
  text-align: left;
}

.tool-visual {
  grid-row: 1 / span 3;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #e8f3ff);
  color: var(--accent);
}

.tool-visual.health {
  border-color: #a7f3d0;
  background: linear-gradient(180deg, #ffffff, #ecfdf5);
  color: #047857;
}

.tool-visual.canvas {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #ffffff, #eef2ff);
  color: #4f46e5;
}

.tool-name {
  color: #334155;
  font-size: 13px;
  font-weight: 850;
}

.tool-card strong {
  grid-column: 2 / -1;
  color: #172033;
  font-size: 15px;
  line-height: 1.35;
}

.tool-card small {
  justify-self: end;
  width: fit-content;
  border-radius: 999px;
  background: #e8f3ff;
  color: var(--accent);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 850;
}

.tool-card:hover,
.tool-card.active {
  border-color: #9fd0ff;
  background: #f4f9ff;
}

.tool-card.active {
  box-shadow: inset 0 0 0 1px rgba(22, 131, 255, 0.22);
}

.tool-card.health small {
  background: #ecfdf5;
  color: #047857;
}

.tool-card.health:hover,
.tool-card.health.active {
  border-color: #86efac;
  background: #f0fdf4;
}

.tool-card.canvas small {
  background: #eef2ff;
  color: #4f46e5;
}

.tool-card.canvas:hover,
.tool-card.canvas.active {
  border-color: #c7d2fe;
  background: #f5f7ff;
}

.tool-card.pending {
  cursor: not-allowed;
  opacity: 0.7;
}

.tool-card.pending small {
  background: #f1f5f9;
  color: #64748b;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions button {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 800;
}

.topbar-actions button:hover {
  border-color: #9fd0ff;
  color: var(--accent);
  background: #f4f9ff;
}

.quota-pill {
  border: 1px solid #b9dcff;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 850;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
  font-weight: 820;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 760;
}

.topbar p,
.result-head p,
.meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.status {
  min-width: 88px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(22, 32, 51, 0.08);
}

.status.running {
  color: #7a4d05;
  background: #fff7df;
  border-color: #edd490;
}

.status.ok {
  color: var(--success);
  background: #e8f7ef;
  border-color: #b8e4ca;
}

.status.error {
  color: var(--danger);
  background: #fff0ee;
  border-color: #efc5bf;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.health-view {
  display: grid;
  gap: 18px;
}

.canvas-view {
  display: grid;
  gap: 16px;
}

.canvas-shell {
  position: relative;
  overflow: hidden;
  height: clamp(620px, calc(100vh - 176px), 980px);
  min-height: 620px;
  border: 1px solid rgba(213, 223, 235, 0.92);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.canvas-workspace-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.canvas-frame-state {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(238, 242, 255, 0.88), rgba(255, 255, 255, 0.96) 48%, rgba(239, 246, 255, 0.9));
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.canvas-frame-state.running {
  color: #4f46e5;
}

.canvas-frame-state.error {
  background: #fff0ee;
  color: var(--danger);
}

.canvas-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(213, 223, 235, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(238, 242, 255, 0.88), rgba(255, 255, 255, 0.96) 48%, rgba(239, 246, 255, 0.9));
  box-shadow: var(--shadow);
  padding: 18px;
}

.eyebrow.canvas {
  border-color: #c7d2fe;
  background: #eef2ff;
  color: #4f46e5;
}

.canvas-hero p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.canvas-launch {
  flex: 0 0 auto;
  border: 0;
  border-radius: 7px;
  background: #4f46e5;
  color: #ffffff;
  cursor: pointer;
  padding: 11px 15px;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.canvas-launch:hover {
  filter: brightness(0.97);
}

.canvas-launch:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.health-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(213, 223, 235, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(236, 253, 245, 0.78), rgba(255, 255, 255, 0.96) 48%, rgba(239, 246, 255, 0.9));
  box-shadow: var(--shadow);
  padding: 18px;
}

.eyebrow {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 8px;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 850;
}

.health-hero p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.health-note {
  max-width: 340px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.5;
}

.health-workspace-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border: 1px solid rgba(213, 223, 235, 0.92);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 10px;
}

.health-workspace-tabs button {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fbfdff;
  color: #526177;
  cursor: pointer;
  padding: 12px;
  text-align: left;
}

.health-workspace-tabs button:hover,
.health-workspace-tabs button.active {
  border-color: #86efac;
  background: #f0fdf4;
  color: #047857;
}

.health-tab-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #ecfdf5;
  color: #047857;
}

.health-tab-icon.report {
  background: #eff6ff;
  color: var(--accent);
}

.health-tab-icon svg {
  display: block;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.health-workspace-tabs span:last-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.health-workspace-tabs strong {
  color: #172033;
  font-size: 14px;
  font-weight: 850;
}

.health-workspace-tabs small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.health-workspace-tabs button.active strong,
.health-workspace-tabs button.active small {
  color: #047857;
}

.health-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.health-upload-panel,
.health-result-panel,
.health-chat-panel {
  padding: 18px;
}

.health-upload-panel {
  position: sticky;
  top: 18px;
}

.health-upload-box {
  display: grid;
  gap: 6px;
  min-height: 126px;
  place-items: center;
  border: 1px dashed #8fc8ff;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #ffffff, #f3f9ff);
  color: #1d4ed8;
  cursor: pointer;
  padding: 18px;
  text-align: center;
}

.health-upload-box strong {
  color: #17324d;
  font-size: 16px;
}

.health-upload-box span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

#healthReportInput {
  margin-top: 10px;
}

.health-upload-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}

.health-upload-actions button:last-child,
.health-panel-head button {
  border: 0;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.health-panel-head button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.health-report-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.health-report-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  padding: 9px;
}

.health-report-item img {
  width: 72px;
  height: 72px;
  border-radius: 7px;
  object-fit: cover;
  background: #f1f5f9;
}

.health-report-item div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.health-report-item strong {
  color: #172033;
  font-size: 13px;
}

.health-report-item span,
.health-report-item small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.health-panel-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.health-analysis-output {
  min-height: 342px;
}

.small-empty {
  min-height: 342px;
}

.analysis-stack {
  display: grid;
  gap: 12px;
}

.analysis-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  padding: 13px;
}

.analysis-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.analysis-card-head strong {
  color: #172033;
  font-size: 15px;
}

.analysis-card-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-align: right;
}

.analysis-card p {
  color: #253247;
  font-size: 14px;
  line-height: 1.7;
}

.summary-card {
  border-color: #a7f3d0;
  background: #f0fdf4;
}

.health-chat-panel {
  display: grid;
  gap: 12px;
}

.health-chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 360px;
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
}

.health-message {
  display: grid;
  gap: 5px;
  width: min(760px, 88%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px 12px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.health-message.user {
  justify-self: end;
  border-color: #9fd0ff;
  background: var(--accent);
  color: #ffffff;
}

.health-message strong {
  font-size: 12px;
  font-weight: 850;
}

.health-message p {
  font-size: 14px;
  line-height: 1.65;
}

.health-message.assistant p {
  color: #253247;
}

.health-message.user p {
  color: #ffffff;
}

.health-chat-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
  align-items: end;
}

.health-chat-input textarea {
  min-height: 86px;
}

.health-error {
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f2;
  color: var(--danger);
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
}

.admin-panel {
  margin-bottom: 20px;
  border: 1px solid rgba(213, 223, 235, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 18px;
}

.admin-login {
  display: grid;
  gap: 14px;
}

.admin-login h2,
.admin-head h2,
.server-log-head h2 {
  margin-bottom: 6px;
}

.admin-login p,
.admin-head p,
.server-log-head span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.admin-login-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) auto;
  gap: 10px;
}

.admin-login-row button,
.admin-actions button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.admin-login-row button:hover,
.admin-actions button:hover {
  filter: brightness(0.97);
}

.admin-dashboard {
  display: grid;
  gap: 16px;
}

.admin-projects {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.admin-project-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 5px 11px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  color: #172033;
  cursor: pointer;
  padding: 12px;
  text-align: left;
}

.admin-project-card:hover,
.admin-project-card.active {
  border-color: #9fd0ff;
  background: #f4f9ff;
}

.admin-project-card.health:hover,
.admin-project-card.health.active {
  border-color: #86efac;
  background: #f0fdf4;
}

.admin-project-card.canvas:hover,
.admin-project-card.canvas.active {
  border-color: #c7d2fe;
  background: #f5f7ff;
}

.admin-project-card.active {
  box-shadow: inset 0 0 0 1px rgba(22, 131, 255, 0.2);
}

.admin-project-icon {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #e8f3ff;
  color: var(--accent);
}

.admin-project-icon.health {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857;
}

.admin-project-icon.canvas {
  border-color: #c7d2fe;
  background: #eef2ff;
  color: #4f46e5;
}

.admin-project-icon svg {
  display: block;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.admin-project-card span:not(.admin-project-icon) {
  color: #172033;
  font-size: 14px;
  font-weight: 850;
}

.admin-project-card strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.45;
}

.admin-project-state {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent);
  padding: 6px 10px;
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
  white-space: nowrap;
}

.admin-project-card.health .admin-project-state {
  border-color: #a7f3d0;
  color: #047857;
}

.admin-project-card.canvas .admin-project-state {
  border-color: #c7d2fe;
  color: #4f46e5;
}

.admin-empty-panel {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #64748b;
  padding: 18px;
  font-size: 14px;
  font-weight: 750;
  text-align: center;
}

.tool-admin-panel {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(213, 223, 235, 0.92);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.health-admin-panel {
  background: linear-gradient(180deg, #ffffff, #fbfffd);
}

.canvas-admin-panel {
  background: linear-gradient(180deg, #ffffff, #fbfcff);
}

.tool-admin-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.tool-admin-panel-head h2 {
  margin-bottom: 6px;
}

.tool-admin-panel-head p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.tool-admin-panel-head button {
  border: 0;
  border-radius: 7px;
  background: #fff0ee;
  color: var(--danger);
  cursor: pointer;
  padding: 10px 13px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.admin-head,
.server-log-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

#clearServerLogs {
  background: #fff0ee;
  color: var(--danger);
}

#adminLogoutBtn {
  background: var(--surface-strong);
  color: #526177;
}

.user-admin {
  scroll-margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  overflow: hidden;
}

.user-admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.user-admin-head h2 {
  margin-bottom: 6px;
}

.user-admin-head p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.user-admin-head button,
.server-log-head button,
.user-password button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  padding: 10px 13px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.user-list {
  display: grid;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 112px 104px minmax(300px, 420px) minmax(230px, 300px);
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.16s ease, box-shadow 0.16s ease;
}

.user-row:hover {
  background: #f8fbff;
}

.user-row.active {
  background: #eff6ff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.health-user-row {
  grid-template-columns: minmax(180px, 1fr) minmax(170px, 240px) 112px minmax(220px, 290px) auto;
}

.canvas-user-row {
  grid-template-columns: minmax(150px, 1fr) minmax(110px, 150px) 96px 96px minmax(230px, 320px) minmax(180px, 240px) auto;
}

.user-row:last-child {
  border-bottom: 0;
}

.user-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.user-title strong {
  color: #172033;
  font-size: 15px;
}

.user-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.user-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #35445b;
  font-size: 13px;
  font-weight: 750;
}

.user-toggle input {
  width: auto;
}

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

.user-token span,
.user-token small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.user-token strong {
  color: #0f766e;
  font-size: 18px;
  line-height: 1.1;
}

.canvas-user-token strong {
  color: #4f46e5;
}

.user-password {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.user-password input {
  min-width: 0;
}

.user-health-actions button {
  border: 1px solid #a7f3d0;
  border-radius: 7px;
  background: #ecfdf5;
  color: #047857;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.user-quota {
  display: grid;
  gap: 7px;
}

.user-quota-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.user-quota-controls {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto auto;
  gap: 8px;
}

.user-quota-controls input {
  min-width: 0;
}

.user-quota-controls button {
  border: 0;
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--accent);
  cursor: pointer;
  padding: 10px 11px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 14px;
}

.key-stack {
  display: grid;
  gap: 12px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 10px;
}

.canvas-stats {
  grid-template-columns: repeat(4, minmax(100px, 1fr));
}

.admin-stats-scope {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.server-log {
  scroll-margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  overflow: hidden;
}

.server-log-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.server-log-head > div {
  min-width: 0;
}

.server-log-filter {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.server-log-filter-title {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.server-log-customers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.server-log-customers button,
.server-log-pager button {
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}

.server-log-customers button:hover,
.server-log-pager button:hover:not(:disabled) {
  border-color: #93c5fd;
  background: #eff6ff;
  color: var(--accent);
}

.server-log-customers button.active {
  border-color: #93c5fd;
  background: var(--accent-soft);
  color: var(--accent);
}

.server-log-empty-filter {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
}

.server-log-list {
  display: grid;
}

.server-log-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 14px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
}

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

.server-log-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.server-log-title strong {
  color: #172033;
  font-size: 14px;
}

.server-log-title > span:last-child,
.server-log-detail,
.server-log-main p,
.server-log-side {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.server-log-detail {
  margin-top: 6px;
}

.server-log-main p {
  margin-top: 6px;
  max-height: 58px;
  overflow: hidden;
}

.admin-chat-detail {
  margin-top: 10px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #f0fdf4;
  overflow: hidden;
}

.admin-chat-detail summary {
  cursor: pointer;
  color: #047857;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 850;
}

.admin-chat-body {
  display: grid;
  gap: 9px;
  border-top: 1px solid #bbf7d0;
  background: #ffffff;
  padding: 12px;
}

.admin-chat-line {
  display: grid;
  gap: 5px;
  max-width: 820px;
}

.admin-chat-line span {
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
}

.admin-chat-line p {
  max-height: none;
  margin: 0;
  border-radius: 8px;
  background: #f8fafc;
  color: #1e293b;
  padding: 9px 10px;
  white-space: pre-wrap;
  overflow: visible;
}

.admin-chat-line.assistant p {
  background: #ecfdf5;
}

.admin-chat-empty {
  width: fit-content;
  margin-top: 10px;
  border-radius: 7px;
  background: #f8fafc;
  color: #64748b;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 750;
}

.server-error {
  width: fit-content;
  max-width: 100%;
  margin-top: 8px;
  border-radius: 6px;
  background: #fff0ee;
  color: var(--danger);
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.server-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.server-images a,
.server-images button {
  display: inline-grid;
  min-width: 76px;
  color: var(--accent);
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  background: var(--accent-soft);
  cursor: pointer;
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.server-images a:hover,
.server-images button:hover {
  background: #dbeafe;
}

.server-log-side {
  display: grid;
  align-content: start;
  justify-items: end;
  gap: 5px;
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.server-log-side strong {
  color: #172033;
  font-size: 13px;
  word-break: break-all;
}

.server-log-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.server-log-pager span {
  min-width: 128px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.server-log-pager button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.panel,
.results {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(213, 223, 235, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  padding: 18px;
  position: sticky;
  top: 18px;
}

.section-title {
  margin: 2px 0 12px;
  color: #1e293b;
  font-size: 15px;
  font-weight: 800;
}

.section-title:not(:first-child) {
  margin-top: 20px;
}

.key-card {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.key-card > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.key-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.key-hint {
  margin: -2px 0 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.5;
}

.api-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.api-config-grid label {
  display: grid;
  gap: 6px;
}

.key-card strong {
  color: #172033;
  font-size: 13px;
}

.key-card strong.configured {
  color: var(--success);
}

.key-card strong.missing {
  color: var(--danger);
}

.key-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

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

.key-actions button {
  border: 0;
  border-radius: 7px;
  background: var(--surface-strong);
  color: #526177;
  cursor: pointer;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 800;
}

.key-actions button:first-child {
  background: var(--accent);
  color: #ffffff;
}

.key-actions button:hover {
  filter: brightness(0.97);
}

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

label {
  font-size: 12px;
  font-weight: 800;
  color: #35445b;
  letter-spacing: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

select {
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 190px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-wide {
  grid-column: 1 / -1;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f1f5f9;
  border: 1px solid #d9e2ef;
  border-radius: 8px;
  padding: 6px;
  gap: 8px;
}

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

.segmented button,
#downloadJson,
#downloadImage,
#toggleCutoutPanel,
#clearHistory,
#clearImage,
#clearReferenceImage {
  border: 0;
  border-radius: 7px;
  color: #526177;
  background: transparent;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.segmented button.active {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(22, 131, 255, 0.2);
}

.segmented button {
  min-height: 44px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.84);
  color: #475467;
  font-size: 14px;
}

.segmented button:not(.active):hover {
  border-color: #bfdbfe;
  color: var(--accent);
}

#downloadJson,
#downloadImage,
#toggleCutoutPanel,
#clearHistory,
#clearImage,
#clearReferenceImage {
  background: #eef4ff;
  color: var(--accent);
}

#downloadJson:hover,
#downloadImage:hover,
#toggleCutoutPanel:hover,
#clearHistory:hover,
#clearImage:hover,
#clearReferenceImage:hover {
  background: #dbeafe;
}

#downloadJson:disabled,
#downloadImage:disabled,
#toggleCutoutPanel:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 14px;
  font-weight: 820;
  box-shadow: 0 16px 30px rgba(22, 131, 255, 0.2);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  display: grid;
  gap: 4px;
  min-height: 64px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 11px 12px;
}

.stat-card.wide {
  grid-column: 1 / -1;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.stat-card strong {
  color: #13213a;
  font-size: 16px;
  line-height: 1.25;
  word-break: break-word;
}

.quota-card {
  display: grid;
  gap: 4px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #f4f9ff;
  padding: 12px;
}

.quota-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.quota-card strong {
  color: var(--accent);
  font-size: 18px;
  line-height: 1.25;
}

.primary:hover {
  background: var(--accent-dark);
}

.primary:disabled {
  opacity: 0.65;
  cursor: progress;
}

.preview {
  border: 1px dashed #93c5fd;
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  display: grid;
  gap: 10px;
}

.reference-upload {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.preview-label {
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
}

.preview img {
  display: block;
  width: 100%;
  max-height: none;
  object-fit: contain;
  border-radius: 6px;
  background: var(--surface-strong);
}

.reference-preview {
  border-style: solid;
  border-color: #93c5fd;
}

.hidden {
  display: none !important;
}

.results {
  min-height: calc(100vh - 104px);
  padding: 18px;
}

.result-main-column {
  display: grid;
  gap: 14px;
}

.result-main-column .result-head {
  margin-bottom: 0;
}

@media (min-width: 1500px) {
  .workspace {
    grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  }

  .results {
    display: grid;
    grid-template-columns: minmax(420px, 1fr) minmax(360px, 430px);
    gap: 14px 16px;
    align-items: start;
  }

  .result-main-column {
    grid-column: 1;
  }

  .cutout-panel {
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;
    min-height: 100%;
  }

  .results .cutout-grid {
    grid-template-columns: 1fr;
  }

  .results .cutout-preview {
    min-height: 150px;
  }

  .results .cutout-result-preview {
    min-height: 180px;
  }

  .history,
  .raw {
    grid-column: 1 / -1;
  }
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  min-height: 260px;
}

.cutout-panel {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  border: 1px solid rgba(191, 219, 254, 0.95);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(239, 246, 255, 0.96), rgba(255, 255, 255, 0.98));
  padding: 14px;
}

.cutout-head,
.cutout-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.cutout-head span,
.cutout-card-head span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}

.cutout-head h3 {
  margin: 0;
  color: #13213a;
  font-size: 23px;
  line-height: 1.2;
}

.cutout-head #cutoutStatus {
  display: none;
}

.cutout-head p {
  margin: 0;
  color: #526177;
  font-size: 13px;
  line-height: 1.5;
}

.cutout-head strong {
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent);
  padding: 8px 12px;
  font-size: 12px;
  white-space: nowrap;
}

.cutout-head strong.ready {
  border-color: #bbf7d0;
  color: var(--success);
}

.cutout-head strong.error {
  border-color: #fecdd3;
  color: var(--danger);
}

.cutout-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 14px;
}

.cutout-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 12px;
}

.cutout-card-head button,
.cutout-actions button,
.cutout-actions a {
  border: 0;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 820;
  text-decoration: none;
  white-space: nowrap;
}

.cutout-card-head button:hover,
.cutout-actions button:hover,
.cutout-actions a:hover {
  background: #dbeafe;
}

.cutout-card-head button:disabled,
.cutout-actions button:disabled,
.cutout-actions a.disabled {
  cursor: not-allowed;
  opacity: 0.45;
  pointer-events: none;
}

.cutout-actions .primary {
  width: 100%;
  min-width: 0;
  padding: 10px 14px;
}

.cutout-upload {
  display: grid;
  gap: 4px;
  border: 1px dashed #bfdbfe;
  border-radius: 8px;
  background: #f8fbff;
  cursor: pointer;
  padding: 12px;
}

.cutout-upload strong {
  color: #13213a;
  font-size: 14px;
}

.cutout-upload small {
  color: #64748b;
  font-size: 12px;
  line-height: 1.4;
}

#cutoutImageInput {
  display: none;
}

.cutout-preview {
  display: grid;
  min-height: 148px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  background:
    linear-gradient(45deg, rgba(226, 232, 240, 0.55) 25%, transparent 25% 75%, rgba(226, 232, 240, 0.55) 75%),
    linear-gradient(45deg, rgba(226, 232, 240, 0.55) 25%, transparent 25% 75%, rgba(226, 232, 240, 0.55) 75%),
    #ffffff;
  background-position: 0 0, 10px 10px;
  background-size: 20px 20px;
}

.cutout-preview img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
}

.cutout-result-preview {
  min-height: 148px;
}

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

  .cutout-head,
  .cutout-card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .cutout-head strong,
  .cutout-card-head button,
  .cutout-actions button,
  .cutout-actions a {
    width: 100%;
    text-align: center;
  }
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.empty {
  min-height: 260px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background:
    linear-gradient(180deg, rgba(251, 253, 255, 0.9), rgba(242, 247, 252, 0.9));
}

.image-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  overflow: hidden;
}

.image-frame {
  position: relative;
  display: grid;
  min-height: 220px;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(219, 234, 254, 0.92), rgba(248, 250, 252, 0.96)),
    repeating-linear-gradient(45deg, rgba(37, 99, 235, 0.05) 0 1px, transparent 1px 18px);
}

.image-card img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
}

.image-overlay-actions {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  gap: 10px;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.image-frame:hover .image-overlay-actions,
.image-frame:focus-within .image-overlay-actions {
  opacity: 1;
  pointer-events: auto;
}

.image-overlay-actions button,
.image-overlay-actions a {
  border: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--accent);
  cursor: pointer;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
  white-space: nowrap;
}

.image-overlay-actions button:hover,
.image-overlay-actions a:hover {
  background: var(--accent);
  color: #ffffff;
}

@media (hover: none) {
  .image-overlay-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

.image-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-top: 1px solid var(--border);
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.inline-actions button,
.inline-actions a {
  border: 0;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.inline-actions button:hover,
.inline-actions a:hover {
  background: #dbeafe;
}

.image-actions span {
  color: #526177;
  font-size: 13px;
}

.image-actions strong {
  color: #162033;
  margin-left: 6px;
}

.image-actions a {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.raw {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  overflow: hidden;
}

.history {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  overflow: hidden;
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.history-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.history-list {
  display: grid;
  gap: 0;
}

.history-empty {
  color: var(--muted);
  padding: 18px 14px;
  font-size: 14px;
}

.history-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 128px;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child {
  border-bottom: 0;
}

.history-thumb {
  width: 76px;
  height: 58px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-strong);
  cursor: pointer;
  padding: 0;
}

.history-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-thumb:hover {
  border-color: var(--accent);
}

.empty-thumb {
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: default;
  font-size: 12px;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.history-title strong {
  overflow: hidden;
  color: #172033;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-main p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-status {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.history-status.ok {
  color: var(--success);
  background: #e8f7ef;
}

.history-status.error {
  color: var(--danger);
  background: #fff0ee;
}

.history-side {
  display: grid;
  justify-items: end;
  gap: 3px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  overflow-wrap: anywhere;
}

.history-download {
  width: fit-content;
  border: 0;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.history-actions button {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}

.history-actions button:hover:not(:disabled) {
  border-color: #9fd0ff;
  color: var(--accent);
  background: #f4f9ff;
}

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

.history-download:hover {
  background: #dbeafe;
}

.history-side strong {
  color: #172033;
  font-size: 14px;
}

.raw summary {
  cursor: pointer;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 800;
}

pre {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  border-top: 1px solid var(--border);
  color: #253247;
  background: #f8fbff;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.password-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
}

.preview-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
}

.preview-modal-panel {
  position: relative;
  display: grid;
  gap: 12px;
  width: min(1080px, 96vw);
  max-height: 94vh;
  border: 1px solid rgba(217, 226, 239, 0.95);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.32);
  padding: 14px;
}

.password-panel {
  position: relative;
  display: grid;
  gap: 12px;
  width: min(420px, 96vw);
  border: 1px solid rgba(217, 226, 239, 0.95);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  padding: 14px;
}

.preview-modal-head,
.preview-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.preview-modal-head button,
.preview-modal-actions a {
  border: 0;
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--accent);
  cursor: pointer;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.preview-modal-actions {
  justify-content: flex-end;
}

.password-form {
  display: grid;
  gap: 10px;
}

.password-form button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  padding: 12px;
  font-size: 13px;
  font-weight: 850;
}

.password-form button:disabled {
  cursor: progress;
  opacity: 0.65;
}

#previewImage {
  display: block;
  width: 100%;
  max-height: calc(94vh - 124px);
  object-fit: contain;
  border-radius: 6px;
  background: #f1f5f9;
}

@media (max-width: 980px) {
  .app {
    width: min(100vw - 20px, 760px);
    padding: 16px 0;
  }

  .login-screen {
    padding: 18px;
  }

  .login-shell {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .login-hero {
    min-height: auto;
    padding: 24px;
  }

  .login-hero h1 {
    font-size: 34px;
  }

  .login-preview {
    display: none;
  }

  .topbar,
  .result-head {
    align-items: stretch;
    flex-direction: column;
  }

  .app-nav {
    width: 100%;
    flex-wrap: wrap;
  }

  .app-nav button {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

  .app-body,
  body.admin-mode .app-body {
    grid-template-columns: 1fr;
  }

  body:not(.admin-mode) .admin-sidebar {
    display: none;
  }

  .admin-sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .admin-sidebar button,
  .admin-sidebar .status {
    text-align: center;
  }

  .admin-menu {
    grid-column: 1 / -1;
  }

  .admin-subnav {
    padding-left: 0;
  }

  .admin-subnav button::before {
    display: none;
  }

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

  .tool-hub-head {
    flex-direction: column;
  }

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

  .tool-admin-panel-head {
    flex-direction: column;
  }

  .tool-hub-status {
    width: 100%;
  }

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

  .health-layout {
    grid-template-columns: 1fr;
  }

  .health-upload-panel {
    position: static;
  }

  .admin-grid,
  .admin-stats,
  .api-config-grid,
  .user-row {
    grid-template-columns: 1fr;
  }

  .user-admin-head {
    flex-direction: column;
  }

  .controls {
    position: static;
  }
}

@media (max-width: 520px) {
  .login-screen {
    padding: 12px;
  }

  .login-card,
  .login-hero {
    padding: 18px;
  }

  .login-tabs {
    grid-template-columns: 1fr;
  }

  .login-tabs button {
    min-height: 44px;
  }

  .login-hero h1 {
    font-size: 30px;
  }

  .brand {
    align-items: flex-start;
  }

  h1 {
    font-size: 25px;
  }

  .option-grid,
  .stat-grid,
  .result-metrics {
    grid-template-columns: 1fr;
  }

  .admin-login-row,
  .server-log-item {
    grid-template-columns: 1fr;
  }

  .admin-sidebar,
  body.admin-mode .admin-sidebar {
    grid-template-columns: 1fr;
  }

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

  .server-log-side {
    justify-items: start;
    text-align: left;
  }

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

  .server-log-head {
    align-items: flex-start;
    flex-direction: row;
  }

  .admin-actions {
    justify-content: flex-start;
  }

  .health-hero,
  .canvas-hero,
  .health-panel-head {
    flex-direction: column;
  }

  .health-workspace-tabs {
    grid-template-columns: 1fr;
  }

  .health-workspace-tabs button {
    min-height: 58px;
  }

  .health-note {
    max-width: none;
  }

  .health-chat-input {
    grid-template-columns: 1fr;
  }

  .health-chat-messages {
    min-height: 48vh;
    max-height: none;
  }

  .stat-card.wide {
    grid-column: auto;
  }

  .history-item {
    grid-template-columns: 70px 1fr;
  }

  .history-side {
    grid-column: 2;
    justify-items: start;
    text-align: left;
  }
}

@media (min-width: 1500px) {
  .cutout-panel {
    margin-top: 0;
    padding-top: 0;
  }
}

@media (min-width: 1500px) {
  body.generate-mode {
    overflow-y: hidden;
  }

  body.generate-mode .app {
    width: min(1880px, calc(100vw - 28px));
    padding: 10px 0;
  }

  body.generate-mode .topbar {
    margin-bottom: 10px;
    padding: 11px 18px;
  }

  body.generate-mode .brand {
    gap: 10px;
  }

  body.generate-mode .topbar .brand-mark {
    width: 42px;
    height: 42px;
  }

  body.generate-mode .topbar h1 {
    font-size: 28px;
  }

  body.generate-mode .topbar p,
  body.generate-mode .result-head p,
  body.generate-mode .meta {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.35;
  }

  body.generate-mode .app-nav {
    padding: 5px;
  }

  body.generate-mode .app-nav button {
    padding: 8px 12px;
    font-size: 13px;
  }

  body.generate-mode .topbar-actions {
    gap: 8px;
  }

  body.generate-mode .status,
  body.generate-mode .topbar-actions button {
    min-width: 78px;
    padding: 8px 12px;
    font-size: 12px;
  }

  body.generate-mode .app-body {
    grid-template-columns: 216px minmax(0, 1fr);
    gap: 14px;
  }

  body.generate-mode .admin-sidebar {
    top: 10px;
    gap: 8px;
    padding: 9px;
  }

  body.generate-mode .admin-sidebar button {
    padding: 9px 10px;
    font-size: 13px;
  }

  body.generate-mode .admin-subnav button {
    padding: 7px 10px;
    font-size: 12px;
  }

  body.generate-mode .workspace {
    grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
    gap: 12px;
    align-items: stretch;
  }

  body.generate-mode .panel,
  body.generate-mode .results {
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
  }

  body.generate-mode .controls,
  body.generate-mode .results {
    height: calc(100vh - 132px);
    min-height: 0;
    overflow: hidden;
  }

  body.generate-mode .controls {
    position: static;
    display: flex;
    flex-direction: column;
    padding: 14px 16px;
  }

  body.generate-mode .controls h2,
  body.generate-mode .result-head h2 {
    margin: 0;
    font-size: 20px;
  }

  body.generate-mode .controls > .field,
  body.generate-mode .controls > .option-grid,
  body.generate-mode .controls > .quota-card,
  body.generate-mode .controls > .stat-grid {
    flex: 0 0 auto;
  }

  body.generate-mode .field {
    gap: 6px;
    margin-bottom: 10px;
  }

  body.generate-mode label {
    font-size: 11px;
  }

  body.generate-mode input,
  body.generate-mode select,
  body.generate-mode textarea {
    border-radius: 7px;
    padding: 9px 10px;
    font-size: 13px;
  }

  body.generate-mode .option-grid {
    gap: 9px;
  }

  body.generate-mode .segmented {
    gap: 7px;
    padding: 5px;
  }

  body.generate-mode .segmented button {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 14px;
  }

  body.generate-mode textarea {
    min-height: 132px;
    max-height: 132px;
    resize: none;
    line-height: 1.45;
  }

  body.generate-mode .controls > .field:has(textarea) {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }

  body.generate-mode .controls > .field textarea {
    height: 100%;
    min-height: 0;
    max-height: none;
  }

  body.generate-mode .quota-card {
    padding: 9px 10px;
  }

  body.generate-mode .quota-card strong {
    font-size: 17px;
  }

  body.generate-mode .stat-grid {
    margin-top: auto;
  }

  body.generate-mode .primary {
    padding: 11px 12px;
  }

  body.generate-mode .results {
    display: grid;
    grid-template-columns: minmax(440px, 1.15fr) minmax(250px, 0.68fr) minmax(250px, 0.68fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px;
    align-items: stretch;
    padding: 14px;
  }

  body.generate-mode .result-main-column {
    grid-column: 1;
    grid-row: 1 / 3;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 0;
  }

  body.generate-mode .result-head {
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 0;
  }

  body.generate-mode .result-actions button {
    padding: 8px 12px;
    font-size: 12px;
  }

  body.generate-mode .gallery {
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 0;
    overflow: hidden;
  }

  body.generate-mode .empty {
    min-height: 0;
    height: 100%;
  }

  body.generate-mode .image-card {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    min-height: 0;
  }

  body.generate-mode .image-frame {
    min-height: 0;
    height: 100%;
  }

  body.generate-mode .image-card img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: contain;
  }

  body.generate-mode .image-actions {
    padding: 8px 10px;
  }

  body.generate-mode .image-actions span {
    font-size: 12px;
  }

  body.generate-mode .result-metrics {
    gap: 8px;
    margin-top: 0;
  }

  body.generate-mode .stat-card {
    padding: 9px 10px;
  }

  body.generate-mode .stat-card strong {
    font-size: 15px;
  }

  body.generate-mode .cutout-panel,
  body.generate-mode .cutout-grid {
    display: contents;
  }

  body.generate-mode .cutout-head {
    grid-column: 2 / 4;
    grid-row: 1;
    align-self: stretch;
    border: 1px solid rgba(191, 219, 254, 0.95);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(239, 246, 255, 0.96), rgba(255, 255, 255, 0.98));
    padding: 12px 14px;
  }

  body.generate-mode .cutout-head h3 {
    font-size: 20px;
  }

  body.generate-mode .cutout-card {
    min-height: 0;
    gap: 9px;
    padding: 12px;
  }

  body.generate-mode .cutout-card:not(.cutout-result-card) {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  body.generate-mode .cutout-result-card {
    grid-column: 3;
    grid-row: 2;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  body.generate-mode .cutout-card-head {
    gap: 8px;
  }

  body.generate-mode .cutout-card-head button,
  body.generate-mode .cutout-actions button,
  body.generate-mode .cutout-actions a {
    padding: 8px 9px;
    font-size: 12px;
  }

  body.generate-mode .cutout-upload {
    padding: 10px;
  }

  body.generate-mode .cutout-upload strong {
    font-size: 13px;
  }

  body.generate-mode .cutout-preview {
    min-height: 0;
    height: 100%;
  }

  body.generate-mode .cutout-preview img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: contain;
  }

  body.generate-mode .cutout-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  body.generate-mode .cutout-result-card .cutout-actions {
    grid-template-columns: 1fr;
  }

  body.generate-mode .history,
  body.generate-mode .raw {
    display: none;
  }
}

@media (min-width: 1500px) {
  body.generate-mode {
    overflow-y: auto;
    overflow-x: hidden;
  }

  body.generate-mode .app {
    width: min(1860px, calc(100vw - 32px));
    padding: 16px 0 28px;
  }

  body.generate-mode .app-body {
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 18px;
  }

  body.generate-mode .workspace {
    grid-template-columns: minmax(400px, 450px) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    min-width: 0;
  }

  body.generate-mode .controls,
  body.generate-mode .results {
    height: auto;
    min-height: calc(100vh - 176px);
    overflow: visible;
  }

  body.generate-mode .controls {
    position: sticky;
    top: 12px;
    display: grid;
    align-content: start;
    padding: 16px 18px;
  }

  body.generate-mode .controls > .field,
  body.generate-mode .controls > .option-grid,
  body.generate-mode .controls > .quota-card,
  body.generate-mode .controls > .stat-grid {
    flex: none;
  }

  body.generate-mode textarea,
  body.generate-mode .controls > .field textarea {
    height: auto;
    min-height: 150px;
    max-height: 220px;
    resize: vertical;
  }

  body.generate-mode .controls > .field:has(textarea) {
    display: grid;
    grid-template-rows: auto auto;
    min-height: auto;
  }

  body.generate-mode .stat-grid {
    margin-top: 0;
  }

  body.generate-mode .results {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto;
    gap: 16px;
    padding: 18px;
    min-width: 0;
  }

  body.generate-mode .result-main-column {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-rows: auto minmax(340px, auto) auto;
    gap: 14px;
    min-height: 0;
    min-width: 0;
  }

  body.generate-mode .gallery {
    min-height: 340px;
    max-height: 460px;
    overflow: hidden;
  }

  body.generate-mode .empty {
    min-height: 340px;
  }

  body.generate-mode .image-card img {
    max-height: 420px;
  }

  body.generate-mode .cutout-panel {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    min-height: 0;
    min-width: 0;
    margin-top: 0;
    padding: 16px;
    overflow: visible;
  }

  body.generate-mode .cutout-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    min-height: 0;
    min-width: 0;
  }

  body.generate-mode .cutout-head {
    grid-column: auto;
    grid-row: auto;
    border: 0;
    border-bottom: 1px solid rgba(191, 219, 254, 0.75);
    border-radius: 0;
    background: transparent;
    padding: 0 0 10px;
  }

  body.generate-mode .cutout-card:not(.cutout-result-card),
  body.generate-mode .cutout-result-card {
    grid-column: auto;
    grid-row: auto;
  }

  body.generate-mode .cutout-card {
    display: grid;
    grid-template-rows: auto auto minmax(320px, auto) auto;
    gap: 12px;
    min-height: 0;
    min-width: 0;
    padding: 16px;
  }

  body.generate-mode .cutout-result-card {
    grid-template-rows: auto minmax(320px, auto) auto auto;
  }

  body.generate-mode .cutout-preview {
    min-height: 320px;
    max-height: 430px;
  }

  body.generate-mode .cutout-result-preview {
    min-height: 320px;
  }

  body.generate-mode .cutout-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.generate-mode .cutout-result-card .cutout-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.generate-mode .cutout-result-card .cutout-actions #resetCutoutResult {
    grid-column: 1 / -1;
  }

  body.generate-mode .cutout-metrics {
    display: grid;
    grid-template-columns: 1fr;
  }

  body.generate-mode .cutout-metrics .stat-card {
    padding: 10px 12px;
  }

  body.generate-mode .history,
  body.generate-mode .raw {
    display: block;
    grid-column: 1 / -1;
  }
}

/* Final precedence for the approved shell */
body {
  background:
    radial-gradient(circle at 10% 8%, rgba(37, 99, 235, 0.08), transparent 26%),
    radial-gradient(circle at 92% 84%, rgba(148, 163, 184, 0.12), transparent 24%),
    #f8fafc;
}

.login-screen {
  min-height: 100vh;
  padding: 28px 18px;
  background: linear-gradient(135deg, #f8fbff 0%, #ffffff 55%, #f2f6fb 100%);
}

.login-shell { display: block; width: min(560px, 100%); }
.login-hero { display: none; }
.login-card {
  gap: 16px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 70px rgba(30, 64, 175, 0.12);
  padding: clamp(28px, 6vw, 48px);
}
.login-card-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-card-brand .brand-mark { width: 48px; height: 48px; border-radius: 14px; }
.login-card-brand div { display: grid; gap: 2px; }
.login-card-brand strong { color: #0f172a; font-size: 23px; letter-spacing: 0.02em; }
.login-card-brand span { color: #64748b; font-size: 13px; letter-spacing: 0.18em; }
.login-card h1 { margin: 0; font-size: clamp(28px, 5vw, 36px); letter-spacing: -0.03em; }
.login-card p { margin: 0; }
.login-tabs { border: 0; border-bottom: 1px solid #e2e8f0; border-radius: 0; background: transparent; padding: 0; }
.login-tabs button { border-radius: 10px 10px 0 0; padding: 12px 8px; }
.login-tabs button.active { box-shadow: inset 0 -2px 0 var(--accent); }
.auth-form label { color: #334155; font-size: 13px; font-weight: 800; margin-top: 2px; }
.auth-form input { min-height: 48px; border-radius: 11px; border-color: #d6deea; background: #fff; padding: 0 14px; }
.auth-form .primary { min-height: 50px; margin-top: 6px; border-radius: 11px; background: linear-gradient(135deg, #2563eb, #1769e8); }
.app { width: min(1480px, calc(100vw - 48px)); padding: 20px 0 28px; }
.topbar { margin-bottom: 18px; border: 0; border-bottom: 1px solid rgba(203, 213, 225, 0.75); border-radius: 0; background: transparent; box-shadow: none; padding: 10px 2px 16px; }
.brand h1 { margin: 0; color: #0f172a; font-size: 22px; letter-spacing: -0.03em; }
.brand p { margin: 3px 0 0; color: #94a3b8; font-size: 12px; }
.app-nav { display: none; }
.app-body, body.admin-mode .app-body { grid-template-columns: 218px minmax(0, 1fr); gap: 28px; }
.admin-sidebar { top: 20px; gap: 7px; border: 1px solid rgba(226, 232, 240, 0.95); border-radius: 18px; background: rgba(255, 255, 255, 0.88); box-shadow: 0 18px 48px rgba(15, 23, 42, 0.06); padding: 12px; }
.sidebar-label { padding: 9px 10px 4px; color: #94a3b8; font-size: 11px; letter-spacing: 0.08em; }
.admin-sidebar button { min-height: 44px; border: 1px solid transparent; border-radius: 12px; background: transparent; padding: 10px 12px; font-size: 14px; }
.admin-sidebar button:hover, .admin-sidebar button.active { border-color: #dbeafe; background: #eff6ff; }
.admin-menu { margin-top: 10px; padding-top: 12px; }
.admin-subnav button { min-height: 38px; border-radius: 10px; background: #f8fafc; font-size: 12px; }
.tool-hub { gap: 20px; border-color: rgba(226, 232, 240, 0.9); border-radius: 20px; background: rgba(255, 255, 255, 0.9); box-shadow: 0 20px 60px rgba(15, 23, 42, 0.06); padding: clamp(20px, 3vw, 34px); }
.tool-hub-head { align-items: center; }
.tool-hub-head h2 { margin: 0; font-size: clamp(28px, 4vw, 38px); letter-spacing: -0.04em; }
.tool-hub-head p { margin: 8px 0 0; color: #94a3b8; }
.tool-hub-status { min-width: 168px; border-radius: 14px; background: #f8fbff; padding: 12px 14px; }
.tool-search { display: flex; align-items: center; gap: 10px; width: min(520px, 100%); min-height: 48px; border: 1px solid #dbe3ef; border-radius: 12px; background: #fff; color: #94a3b8; padding: 0 14px; }
.tool-search:focus-within { border-color: #93c5fd; box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08); }
.tool-search svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 2; }
.tool-search input { width: 100%; border: 0; outline: 0; color: #0f172a; background: transparent; }
.tool-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.tool-card { min-height: 176px; border-radius: 16px; background: #fff; padding: 18px; transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease; }
.tool-card:hover { transform: translateY(-2px); box-shadow: 0 16px 30px rgba(37, 99, 235, 0.1); }
.tool-card.tool-search-hidden { display: none; }
.tool-empty { border: 1px dashed #cbd5e1; border-radius: 14px; color: #64748b; padding: 28px; text-align: center; }
.account-menu { position: relative; }
.account-trigger { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; border: 1px solid #dbe3ef; border-radius: 999px; background: rgba(255, 255, 255, 0.92); color: #1e293b; cursor: pointer; padding: 5px 12px 5px 6px; font-weight: 800; }
.account-trigger:hover, .account-menu.open .account-trigger { border-color: #93c5fd; color: var(--accent); }
.account-avatar { display: inline-grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: #eff6ff; overflow: hidden; }
.account-avatar img { width: 100%; height: 100%; }
.account-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chevron { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; transition: transform 160ms ease; }
.account-menu.open .account-chevron { transform: rotate(180deg); }
.account-dropdown { position: absolute; z-index: 20; top: calc(100% + 9px); right: 0; display: grid; min-width: 150px; border: 1px solid #dbe3ef; border-radius: 14px; background: #fff; box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12); padding: 6px; }
.account-dropdown button { border: 0; border-radius: 9px; background: transparent; color: #334155; cursor: pointer; padding: 10px 12px; text-align: left; white-space: nowrap; }
.account-dropdown button:hover { background: #eff6ff; color: var(--accent); }

@media (max-width: 980px) {
  .app { width: min(100vw - 24px, 760px); }
  .topbar { padding-inline: 0; }
  .topbar-actions { justify-content: space-between; }
  .app-body, body.admin-mode .app-body { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-menu { grid-column: 1 / -1; }
  .tool-hub-head { align-items: stretch; flex-direction: column; }
  .tool-hub-status { width: 100%; }
}

@media (max-width: 520px) {
  .login-screen { padding: 12px; }
  .login-card { border-radius: 18px; padding: 24px 18px; }
  .login-tabs { grid-template-columns: 1fr 1fr 1fr; gap: 2px; }
  .login-tabs button { padding-inline: 4px; font-size: 12px; }
  .brand p { display: none; }
  .topbar-actions { gap: 6px; }
  .account-name { max-width: 90px; }
  .status { display: none; }
  .admin-sidebar { grid-template-columns: 1fr; }
  .admin-menu { grid-column: auto; }
}

/* Final admin shell: keep existing management panels, change only the admin chrome. */
body.admin-mode .admin-sidebar > .sidebar-label,
body.admin-mode #showHomeView,
body.admin-mode #showGenerateView,
body.admin-mode #showHealthView,
body.admin-mode #showCanvasView {
  display: none;
}

body.admin-mode .admin-menu {
  display: grid;
  gap: 8px;
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

body.admin-mode .admin-menu > .sidebar-label {
  display: none;
}

body.admin-mode .admin-menu > #adminToggle,
body.admin-mode .admin-menu > #adminSettingsNav {
  min-height: 48px;
  border-radius: 12px;
  padding-inline: 16px;
  font-size: 15px;
}

body.admin-mode .admin-menu > #adminToggle {
  color: var(--accent);
  border-color: #dbeafe;
  background: #eff6ff;
}

body.admin-mode .admin-menu > #adminSettingsNav {
  color: #475569;
  background: #ffffff;
}

body.admin-mode .admin-subnav {
  display: none;
}

body.admin-mode .brand p {
  min-height: 24px;
  margin-top: 0;
  border-left: 1px solid #cbd5e1;
  color: #64748b;
  font-size: 15px;
  letter-spacing: 0.04em;
  padding-left: 18px;
}

body.admin-mode #statusPill {
  display: none;
}

@media (max-width: 980px) {
  body.admin-mode .admin-sidebar > .sidebar-label,
  body.admin-mode #showHomeView,
  body.admin-mode #showGenerateView,
  body.admin-mode #showHealthView,
  body.admin-mode #showCanvasView {
    display: none;
  }

  body.admin-mode .admin-menu {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .password-panel {
    width: 100%;
  }
}
