:root {
  color-scheme: light;
  --background: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-strong: #eef3f8;
  --sidebar: #ffffff;
  --text: #172033;
  --text-soft: #667085;
  --text-faint: #98a2b3;
  --line: #e4e9f0;
  --line-strong: #d5dde7;
  --accent: #0f8fa6;
  --accent-hover: #0b778c;
  --accent-soft: #e7f8fb;
  --accent-contrast: #ffffff;
  --success: #168a61;
  --success-soft: #e9f8f1;
  --warning: #b7791f;
  --warning-soft: #fff7e4;
  --danger: #c33c4a;
  --danger-soft: #fff0f1;
  --shadow: 0 12px 36px rgba(30, 46, 70, 0.07);
  --shadow-small: 0 4px 16px rgba(30, 46, 70, 0.07);
  --radius-large: 18px;
  --radius-medium: 12px;
  --radius-small: 8px;
  font-family: Inter, "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #0c121b;
  --surface: #141d29;
  --surface-muted: #101822;
  --surface-strong: #1a2634;
  --sidebar: #111923;
  --text: #eef3f8;
  --text-soft: #a9b5c5;
  --text-faint: #748297;
  --line: #263344;
  --line-strong: #35465a;
  --accent: #30c5dc;
  --accent-hover: #63d6e7;
  --accent-soft: #12333c;
  --accent-contrast: #071317;
  --success: #52d2a0;
  --success-soft: #15352b;
  --warning: #f4bd63;
  --warning-soft: #3a2d17;
  --danger: #ff8591;
  --danger-soft: #3c2027;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
  --shadow-small: 0 5px 18px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  color: var(--text);
  background: var(--background);
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

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

/* The login page intentionally mirrors the desktop palette and composition. */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  min-height: 520px;
  overflow: hidden;
  color: #26332f;
  background: #d9e1df;
  isolation: isolate;
}

.login-screen::before {
  position: absolute;
  inset: 0;
  z-index: -4;
  content: "";
  background:
    radial-gradient(circle at 2% 92%, #c7b69b 0 20%, transparent 43%),
    radial-gradient(circle at 92% 8%, #eef0ef 0 24%, transparent 46%),
    radial-gradient(circle at 14% 9%, #b6c7c6 0 13%, transparent 35%),
    linear-gradient(120deg, #d8e0dd, #eef0eb 55%, #d4dedc);
  filter: blur(5px);
  transform: scale(1.04);
}

.login-screen::after {
  position: absolute;
  inset: 0;
  z-index: -3;
  content: "";
  background: rgba(247, 247, 243, 0.37);
  backdrop-filter: blur(18px);
}

.login-backdrop {
  position: absolute;
  z-index: -2;
  pointer-events: none;
  filter: blur(38px);
  opacity: 0.5;
}

.login-orb-left {
  left: -9vw;
  bottom: -22vh;
  width: 48vw;
  height: 65vh;
  border-radius: 60%;
  background: #bca984;
}

.login-orb-right {
  top: -28vh;
  right: -8vw;
  width: 46vw;
  height: 65vh;
  border-radius: 50%;
  background: #ffffff;
}

.login-glass-lines {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: repeating-linear-gradient(90deg,
    transparent 0 10%, rgba(255, 255, 255, 0.19) 10% 16%, transparent 16% 38%);
  opacity: 0.82;
}

.login-center {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  grid-template-columns: minmax(230px, 0.82fr) minmax(340px, 1.18fr);
  grid-template-areas:
    "mascot form"
    "heading form";
  width: min(920px, calc(100vw - 96px));
  min-height: 410px;
  align-items: center;
  padding: clamp(30px, 3.2vw, 50px) clamp(34px, 4.5vw, 68px);
  transform: translate(-50%, -50%);
  background: rgba(238, 241, 237, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(53, 68, 62, 0.17),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(24px);
}

.login-header,
.login-footer {
  position: absolute;
  right: clamp(22px, 3.2vw, 48px);
  left: clamp(22px, 3.2vw, 48px);
  z-index: 2;
  display: flex;
  justify-content: space-between;
  color: #77817b;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.login-header {
  top: clamp(18px, 2.5vh, 28px);
  align-items: flex-start;
}

.login-header > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.login-brand {
  color: #26332f;
  font-size: 25px;
  letter-spacing: -0.04em;
}

.login-footer {
  bottom: clamp(16px, 2.5vh, 26px);
}

.mascot-stage {
  position: relative;
  grid-area: mascot;
  width: 210px;
  height: 210px;
  align-self: end;
  margin: 0 auto;
  animation: mascot-bob 3.2s ease-in-out infinite;
}

.login-mascot {
  position: absolute;
  inset: 5px;
  z-index: 2;
  width: 200px;
  height: 200px;
  object-fit: contain;
}

.mascot-ring {
  position: absolute;
  border: 2px solid #26332f;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 180ms ease;
}

.login-screen.busy .mascot-ring,
.login-screen.success .mascot-ring {
  opacity: 0.72;
}

.mascot-ring-one {
  inset: 1px;
  border-right-color: transparent;
  animation: ring-spin 2.7s linear infinite;
}

.mascot-ring-two {
  inset: 15px;
  border-color: #ffffff transparent #ffffff #ffffff;
  animation: ring-spin 3.4s linear infinite reverse;
}

.mascot-ring-three {
  inset: 29px;
  border-width: 1px;
  border-left-color: transparent;
  animation: ring-spin 2.1s linear infinite;
}

.login-heading {
  grid-area: heading;
  align-self: start;
  margin-top: 4px;
  text-align: center;
}

.login-heading h1 {
  margin: 0;
  color: #26332f;
  font-size: clamp(20px, 1.8vw, 25px);
  font-weight: 600;
  letter-spacing: 0.24em;
}

.login-heading p {
  margin: 8px 0 0;
  color: #77817b;
  font-size: 9px;
  letter-spacing: 0.16em;
}

.login-form {
  display: grid;
  grid-area: form;
  grid-template-columns: 1fr;
  align-content: center;
  min-height: 290px;
  padding-left: clamp(34px, 4.2vw, 64px);
  border-left: 1px solid rgba(99, 115, 104, 0.2);
}

.login-form label {
  margin-bottom: 7px;
  color: #77817b;
  font-size: 10px;
  letter-spacing: 0.03em;
}

.login-form input {
  width: 100%;
  height: 46px;
  margin-bottom: 15px;
  padding: 0 14px;
  color: #26332f;
  background: #f3f4f0;
  border: 1px solid #b7c0b8;
  border-radius: 7px;
  font-size: 13px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-form input:focus {
  outline: none;
  border-color: #be8339;
  box-shadow: 0 0 0 3px rgba(190, 131, 57, 0.12);
}

.login-submit {
  height: 46px;
  margin-top: 3px;
  color: #fafaf4;
  background: #26332f;
  border: 0;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.login-submit:hover:not(:disabled) {
  background: #53674f;
  transform: translateY(-1px);
}

.login-submit:disabled {
  color: #c4ccc2;
  background: #87938a;
  cursor: wait;
}

.login-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 8px;
}

.text-button {
  min-height: 32px;
  padding: 4px 8px;
  color: #637368;
  background: transparent;
  border: 0;
  border-radius: 3px;
  font-size: 10px;
  cursor: pointer;
}

.text-button:hover:not(:disabled) {
  background: #dae1d9;
}

.text-button.strong {
  color: #26332f;
}

.text-button:disabled {
  color: #a6afa5;
  cursor: not-allowed;
}

.login-message {
  min-height: 34px;
  margin: 6px 0 0;
  color: #77817b;
  font-size: 10px;
  line-height: 1.45;
  text-align: center;
}

.login-message.error {
  color: #a85d37;
}

.login-message.success {
  color: #58735f;
}

@keyframes mascot-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes ring-spin {
  to { transform: rotate(360deg); }
}

/* Modern workbench */
.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 18px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--accent-contrast);
  background: var(--accent);
  border-radius: 13px;
  font-size: 21px;
  font-weight: 800;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 22%, transparent);
}

.sidebar-brand div {
  display: flex;
  flex-direction: column;
}

.sidebar-brand strong {
  font-size: 20px;
  letter-spacing: -0.03em;
}

.sidebar-brand small,
.sidebar-footer small {
  color: var(--text-soft);
}

.sidebar-navigation {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  color: var(--text-soft);
  background: transparent;
  border: 0;
  border-radius: 11px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, transform 150ms ease;
}

.nav-item span {
  width: 22px;
  font-size: 19px;
  text-align: center;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-muted);
  transform: translateX(2px);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 9px 0;
  border-top: 1px solid var(--line);
}

.sidebar-footer span {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.main-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  padding: 14px clamp(20px, 3vw, 44px);
  background: color-mix(in srgb, var(--background) 86%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.eyebrow {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: 23px;
  letter-spacing: -0.03em;
}

.topbar-actions,
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  color: var(--success);
  background: var(--success-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill i {
  width: 7px;
  height: 7px;
  background: currentColor;
  border-radius: 50%;
}

.status-pill.running i,
.status-pill.loading i,
.status-pill.stopping i {
  animation: status-pulse 1.3s ease-in-out infinite;
}

.status-pill.attention {
  color: var(--warning);
  background: var(--warning-soft);
}

@keyframes status-pulse {
  50% { opacity: 0.32; transform: scale(1.5); }
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  box-shadow: var(--shadow-small);
}

.icon-button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.icon-button.square {
  width: 40px;
  font-size: 18px;
}

.account-button {
  gap: 8px;
  padding: 4px 12px 4px 5px;
  font-size: 12px;
  font-weight: 700;
}

.avatar {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  color: var(--accent-contrast);
  background: var(--accent);
  border-radius: 8px;
}

.content {
  width: min(100%, 1700px);
  margin: 0 auto;
  padding: 30px clamp(20px, 3vw, 44px) 56px;
}

.page {
  display: none;
  animation: page-enter 180ms ease-out;
}

.page.active {
  display: block;
}

@keyframes page-enter {
  from { opacity: 0; transform: translateY(4px); }
}

.page-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-intro h2 {
  margin: 0 0 5px;
  font-size: clamp(24px, 2.2vw, 32px);
  letter-spacing: -0.04em;
}

.page-intro p,
.panel-header p,
.summary-card small {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.55;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.button.primary {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
}

.button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.button.secondary {
  background: var(--surface);
}

.button.danger,
.button.danger-soft:hover:not(:disabled) {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

.button.danger-soft {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: transparent;
}

.button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.button:disabled {
  color: var(--text-faint);
  background: var(--surface-strong);
  border-color: var(--line);
  cursor: not-allowed;
  opacity: 0.7;
}

.action-toolbar {
  margin-bottom: 18px;
}

.toolbar.compact {
  justify-content: flex-end;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

.summary-card {
  position: relative;
  min-height: 132px;
  padding: 20px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-small);
}

.summary-card::after {
  position: absolute;
  top: 19px;
  right: 19px;
  width: 9px;
  height: 9px;
  content: "";
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 7px var(--accent-soft);
}

.summary-card.success::after { background: var(--success); box-shadow: 0 0 0 7px var(--success-soft); }
.summary-card.pending::after { background: #6686aa; box-shadow: 0 0 0 7px var(--surface-strong); }
.summary-card.attention::after { background: var(--warning); box-shadow: 0 0 0 7px var(--warning-soft); }

.summary-card span {
  display: block;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 35px;
  letter-spacing: -0.05em;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  color: var(--text-soft);
  font-size: 12px;
}

.progress-track {
  height: 7px;
  margin: 8px 0 18px;
  overflow: hidden;
  background: var(--surface-strong);
  border-radius: 999px;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #4fd0b4);
  border-radius: inherit;
  transition: width 250ms ease;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-small);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-header h3 {
  margin: 0 0 3px;
  font-size: 15px;
}

.table-panel {
  min-height: 350px;
  overflow: hidden;
}

.table-scroll {
  max-height: calc(100vh - 445px);
  min-height: 220px;
  overflow: auto;
}

.task-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  font-size: 12px;
}

.task-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 13px;
  color: var(--text-soft);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
}

.task-table td {
  max-width: 320px;
  padding: 13px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-table tbody tr {
  cursor: pointer;
  transition: background 120ms ease;
}

.task-table tbody tr:hover,
.task-table tbody tr.selected {
  background: var(--accent-soft);
}

.task-table tbody tr:last-child td {
  border-bottom: 0;
}

.status-badge {
  display: inline-flex;
  padding: 4px 8px;
  color: var(--text-soft);
  background: var(--surface-strong);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
}

.status-badge.completed,
.status-badge.published {
  color: var(--success);
  background: var(--success-soft);
}

.status-badge.error,
.status-badge.failed,
.status-badge.manual_required,
.status-badge.blocked,
.status-badge.unknown {
  color: var(--danger);
  background: var(--danger-soft);
}

.empty-state {
  display: flex;
  min-height: 250px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 28px;
  color: var(--text-soft);
  text-align: center;
}

.empty-state span {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 8px;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 16px;
  font-size: 24px;
}

.empty-state h3 {
  margin: 8px 0 3px;
  color: var(--text);
}

.empty-state p {
  margin: 0;
  font-size: 12px;
}

.detail-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
}

.image-list-panel {
  align-self: start;
  max-height: calc(100vh - 180px);
  overflow: hidden;
}

.image-list {
  max-height: calc(100vh - 280px);
  padding: 10px;
  overflow: auto;
}

.image-list-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  margin-bottom: 7px;
  padding: 8px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
}

.image-list-item:hover,
.image-list-item.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}

.image-list-item img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  background: var(--surface-strong);
  border-radius: 8px;
}

.image-list-item div {
  min-width: 0;
}

.image-list-item strong,
.image-list-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-list-item small {
  margin-top: 5px;
  color: var(--text-soft);
  font-size: 10px;
}

.detail-main {
  min-width: 0;
}

.image-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.image-card {
  overflow: hidden;
}

.image-card header {
  padding: 13px 16px;
  color: var(--text-soft);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.image-stage {
  display: grid;
  min-height: min(41vw, 520px);
  place-items: center;
  padding: 14px;
  background:
    linear-gradient(45deg, var(--surface-muted) 25%, transparent 25%),
    linear-gradient(-45deg, var(--surface-muted) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--surface-muted) 75%),
    linear-gradient(-45deg, transparent 75%, var(--surface-muted) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.image-stage img {
  max-width: 100%;
  max-height: 510px;
  object-fit: contain;
  border-radius: 8px;
}

.image-stage img:not([src]),
.image-stage img[src=""] {
  visibility: hidden;
}

.detail-facts {
  margin-top: 16px;
  padding-bottom: 18px;
}

.detail-facts .toolbar {
  padding: 16px 20px 0;
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  padding: 4px 20px;
}

.fact-grid div {
  min-width: 0;
  padding: 14px 10px 14px 0;
  border-bottom: 1px solid var(--line);
}

.fact-grid dt {
  color: var(--text-soft);
  font-size: 10px;
}

.fact-grid dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 700;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.72fr) minmax(500px, 1.28fr);
  gap: 16px;
}

.settings-card {
  padding-bottom: 20px;
}

.form-grid,
.prompt-list {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.form-grid.two-columns {
  grid-template-columns: 1fr 1fr;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  color: var(--text);
  background: var(--surface-muted);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 90px;
  padding: 11px;
  line-height: 1.6;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 11%, transparent);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.switch-row {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.switch-row span {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.switch-row strong {
  color: var(--text);
  font-size: 12px;
}

.switch-row small {
  font-weight: 400;
  line-height: 1.4;
}

.branding-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.branding-card {
  padding-bottom: 18px;
}

.branding-card-body {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 18px;
  padding: 18px;
}

.branding-preview {
  display: grid;
  min-height: 140px;
  place-items: center;
  overflow: hidden;
  color: var(--text-faint);
  background: var(--surface-muted);
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
}

.branding-preview img {
  max-width: 100%;
  max-height: 130px;
  object-fit: contain;
}

.branding-fields {
  display: grid;
  gap: 12px;
}

.code-editor {
  margin: 18px 20px 0;
  width: calc(100% - 40px);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  tab-size: 2;
}

.inline-field {
  display: flex;
  align-items: center;
  grid-template-columns: auto 180px;
  gap: 8px;
}

.inline-field select {
  width: 200px;
}

.log-panel {
  min-height: 520px;
  padding: 10px;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100vh - 240px);
  overflow: auto;
}

.log-item {
  display: grid;
  grid-template-columns: 128px 90px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 11px;
}

.log-item:nth-child(odd) {
  background: var(--surface-muted);
}

.log-time,
.log-stage {
  color: var(--text-soft);
}

.log-item.error .log-message {
  color: var(--danger);
}

.log-item.warning .log-message {
  color: var(--warning);
}

.modal {
  width: min(500px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: auto;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
}

.modal::backdrop {
  background: rgba(8, 15, 25, 0.52);
  backdrop-filter: blur(5px);
}

.modal form {
  display: grid;
  gap: 15px;
  padding: 24px;
}

.wide-modal {
  width: min(620px, calc(100vw - 28px));
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.modal-header h2 {
  margin: 4px 0 0;
  font-size: 22px;
}

.modal-close {
  width: 34px;
  height: 34px;
  color: var(--text-soft);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 20px;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 4px;
}

.modal-description,
.form-message {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-line;
}

.form-message.error {
  color: var(--danger);
}

.form-message.success {
  color: var(--success);
}

.confirm-modal {
  width: min(440px, calc(100vw - 28px));
}

.toast-region {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 200;
  display: flex;
  width: min(380px, calc(100vw - 44px));
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 13px 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.5;
  animation: toast-enter 180ms ease-out;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.success {
  border-left-color: var(--success);
}

@keyframes toast-enter {
  from { opacity: 0; transform: translateY(8px); }
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding: 22px 10px; }
  .sidebar-brand { justify-content: center; padding-right: 0; padding-left: 0; }
  .sidebar-brand div, .sidebar-footer { display: none; }
  .nav-item { justify-content: center; padding: 0; font-size: 0; }
  .nav-item span { font-size: 20px; }
  .settings-grid { grid-template-columns: 1fr; }
  .table-scroll { max-height: none; }
}

@media (max-width: 820px) {
  .app-shell { display: block; padding-bottom: 72px; }
  .sidebar { position: fixed; top: auto; right: 0; bottom: 0; left: 0; z-index: 50; width: auto; height: 66px; padding: 7px; border-top: 1px solid var(--line); border-right: 0; }
  .sidebar-brand, .sidebar-footer { display: none; }
  .sidebar-navigation { flex-direction: row; }
  .nav-item { min-height: 50px; }
  .topbar { min-height: 72px; padding: 10px 15px; }
  .topbar h1 { font-size: 18px; }
  .status-pill, .account-button span:last-child { display: none; }
  .account-button { padding-right: 5px; }
  .content { padding: 22px 14px 40px; }
  .page-intro { align-items: flex-start; flex-direction: column; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .detail-layout { grid-template-columns: 1fr; }
  .image-list-panel { max-height: none; }
  .image-list { display: flex; max-height: none; overflow-x: auto; }
  .image-list-item { min-width: 190px; }
  .image-comparison, .branding-grid { grid-template-columns: 1fr; }
  .image-stage { min-height: 75vw; }
  .fact-grid { grid-template-columns: 1fr 1fr; }
  .log-item { grid-template-columns: 92px minmax(0, 1fr); }
  .log-stage { display: none; }
}

@media (min-width: 901px) and (max-height: 700px) {
  .login-center {
    min-height: 340px;
    padding-top: 24px;
    padding-bottom: 24px;
  }
  .mascot-stage { width: 170px; height: 170px; }
  .login-mascot { width: 160px; height: 160px; }
  .login-form { min-height: 260px; }
  .login-form input { height: 42px; margin-bottom: 11px; }
  .login-submit { height: 42px; }
  .login-actions { margin-top: 4px; }
  .login-message { min-height: 26px; margin-top: 2px; }
}

@media (max-width: 900px) {
  .login-screen { min-height: 720px; overflow-x: hidden; overflow-y: auto; }
  .login-center {
    position: relative;
    top: auto;
    left: auto;
    display: block;
    width: min(520px, calc(100vw - 40px));
    min-height: 0;
    margin: 86px auto 72px;
    padding: 28px clamp(34px, 8vw, 62px) 26px;
    transform: none;
  }
  .mascot-stage { width: 168px; height: 168px; }
  .login-mascot { width: 158px; height: 158px; }
  .login-heading { margin-top: 0; }
  .login-heading p { margin-bottom: 20px; }
  .login-form {
    min-height: 0;
    padding: 22px 0 0;
    border-top: 1px solid rgba(99, 115, 104, 0.2);
    border-left: 0;
  }
}

@media (max-width: 560px) {
  .login-screen { min-height: 560px; overflow: auto; }
  .login-header { right: 15px; left: 15px; }
  .login-header > div span:not(.login-brand), .login-header > span { display: none; }
  .login-center { width: calc(100vw - 24px); min-height: 510px; margin-top: 58px; padding: 22px 32px; }
  .mascot-stage { width: 160px; height: 160px; }
  .login-mascot { width: 150px; height: 150px; }
  .login-footer { position: fixed; right: 15px; left: 15px; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card { min-height: 110px; }
  .form-grid.two-columns { grid-template-columns: 1fr; }
  .branding-card-body { grid-template-columns: 1fr; }
  .fact-grid { grid-template-columns: 1fr; }
  .topbar-actions { gap: 5px; }
  .icon-button.square { width: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
