: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);
}

* {
  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.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-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.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;
}

.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(2, 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.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 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-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);
}

.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;
}

.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;
}

.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;
}

.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-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 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,
#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,
#clearHistory,
#clearImage,
#clearReferenceImage {
  background: #eef4ff;
  color: var(--accent);
}

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

#downloadJson:disabled,
#downloadImage: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-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(310px, 1fr));
  gap: 14px;
  min-height: 430px;
}

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

.empty {
  min-height: 430px;
  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: 280px;
  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: 760px;
  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%;
  }

  .app-nav button {
    flex: 1;
  }

  .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,
  .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,
  .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;
  }
}
