:root {
  --bg: #0a1628;
  --bg-2: #132240;
  --text: #f8fafc;
  --muted: #b8c6d9;
  --line: rgba(255, 255, 255, 0.16);
  --panel: rgba(255, 255, 255, 0.1);
  --primary: #3b82f6;
  --primary-2: #2563eb;
  --danger: #c83232;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
  --warm: #f4c56f;
  --gate-width: min(980px, 100%);
  --gate-form-width: min(540px, 100%);
  --gate-logo-width: min(360px, 78%);
  --gate-title-size: clamp(42px, 4.6vw, 62px);
  --gate-card-min: 132px;
  --gate-card-pad: 26px 30px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 86% 26%, rgba(36, 91, 127, 0.48), transparent 32%),
    radial-gradient(circle at 50% 72%, rgba(12, 41, 78, 0.62), transparent 42%),
    linear-gradient(112deg, #1c252d 0%, #071426 44%, #0b2038 100%);
}

.hidden { display: none !important; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.gate-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 74px 74px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.82), rgba(0,0,0,.34) 70%, transparent 100%);
}

.login-box {
  width: var(--gate-form-width);
  background: rgba(8, 18, 32, 0.78);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 12px;
  padding: 32px;
  position: relative;
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
}

.entry-box {
  width: var(--gate-width);
  text-align: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.auth-box {
  width: var(--gate-form-width);
  text-align: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.mode-box {
  width: var(--gate-width);
  text-align: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.entry-box h1,
.auth-box h1,
.mode-box h1 {
  font-size: var(--gate-title-size);
  font-weight: 800;
  color: #fff;
  letter-spacing: 0;
  text-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  margin: 0;
}

.auth-box label {
  margin: 18px auto 0;
  text-align: left;
  width: 100%;
}

.auth-box input {
  min-height: 54px;
  border-radius: 13px;
  font-size: 18px;
  background: rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

#loginEyebrow,
#roleLabel {
  display: none;
}

#modeView .eyebrow {
  display: none;
}

.auth-box .primary,
.auth-box .secondary {
  min-height: 54px;
  font-size: 18px;
  border-radius: 13px;
}

.entry-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 30px;
}

.mode-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-top: 34px;
}

.mode-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 30px;
}

.entry-card,
.mode-card {
  width: 100%;
  min-height: var(--gate-card-min);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  margin: 0;
  padding: var(--gate-card-pad);
  text-align: left;
  color: var(--text);
  background: rgba(52, 74, 104, 0.58);
  border: 1px solid rgba(190, 210, 238, 0.26);
  border-radius: 14px;
  box-shadow: 0 24px 62px rgba(0, 0, 0, 0.24);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
  transition: background .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.entry-card:hover,
.mode-card:hover {
  background: rgba(62, 86, 120, 0.68);
  border-color: rgba(244, 197, 111, 0.72);
  transform: translateY(-1px);
  box-shadow: 0 24px 58px rgba(0, 0, 0, 0.24);
}

.entry-card strong,
.mode-card-body {
  min-width: 0;
}

.mode-card-body {
  display: grid;
  gap: 7px;
}

#dataModeBtn .mode-card-body {
  gap: 14px;
}

.entry-card strong,
.mode-card strong {
  color: #fff;
  font-size: 28px;
  line-height: 1.1;
}

.mode-card span,
.mode-card small {
  display: block;
}

.mode-card-body > span {
  color: #d7e2f1;
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.mode-card-body > .mode-meta-line {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.mode-card .mode-data-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.mode-card .mode-data-item {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid rgba(190, 210, 238, 0.18);
  border-radius: 10px;
  background: rgba(8, 18, 32, 0.2);
}

.mode-data-label,
.mode-data-value {
  display: block;
  min-width: 0;
}

.mode-data-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.mode-data-value {
  color: #edf4ff;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.mode-card small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.mode-box .eyebrow {
  text-align: left;
  width: var(--gate-width);
  margin: 8px auto 10px;
  font-size: 17px;
  color: var(--warm);
}

.mode-box .secondary {
  width: min(760px, 100%);
  min-height: 54px;
  margin-top: 22px;
  font-size: 18px;
  border-radius: 13px;
}

.entry-card strong {
  display: block;
  margin-bottom: 9px;
}

.entry-card span {
  display: block;
  color: var(--muted);
  font-size: 17px;
}

.brand-logo {
  display: block;
  width: var(--gate-logo-width);
  height: auto;
  margin: 0 auto 24px;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.24));
}

.brand-logo.small {
  width: var(--gate-logo-width);
  margin-bottom: 24px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6, #38bdf8);
  box-shadow: 0 12px 32px rgba(56, 189, 248, 0.25);
  font-weight: 800;
  font-size: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--warm);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

h1 { margin: 0; font-size: 26px; }
.intro { color: var(--muted); margin: 8px 0 20px; }

.version-card {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding: 14px;
  border: 1px solid rgba(244, 197, 111, 0.26);
  border-radius: 10px;
  background: rgba(244, 197, 111, 0.08);
}

.version-card div {
  display: grid;
  gap: 3px;
}

.version-card span {
  color: var(--muted);
  font-size: 13px;
}

.version-card strong {
  color: #fff8e8;
  font-size: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: #d7e2f1;
  margin-top: 16px;
}

input, select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 42px;
  font: inherit;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  outline: none;
}

select option {
  color: #172033;
}

input:focus, select:focus {
  border-color: rgba(96, 165, 250, 0.8);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 42px;
  font: inherit;
  cursor: pointer;
  margin-top: 18px;
}

.primary { background: var(--primary); color: #fff; width: 100%; }
.primary:hover { background: var(--primary-2); }

.secondary {
  width: 100%;
  color: #d7e2f1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  margin-top: 10px;
}

.secondary:hover {
  background: rgba(255, 255, 255, 0.13);
}

.compact {
  width: auto;
  min-height: 38px;
  margin: 0;
  padding: 8px 14px;
}

.msg { min-height: 22px; margin-top: 10px; color: var(--muted); }
.msg.error { color: #fecaca; }

.manager-shell {
  min-height: 100vh;
  padding: 28px;
}

.manager-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 980px;
  margin: 0 auto 18px;
}

.manager-header h1 {
  margin-top: 2px;
}

.manager-panel {
  max-width: 980px;
  margin: 0 auto 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}

.manager-panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 14px;
  align-items: end;
}

.upload-row .primary {
  margin-top: 0;
}

.batch-list {
  display: grid;
  gap: 10px;
}

.batch-item {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) minmax(150px, .9fr) minmax(180px, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.batch-item span {
  color: var(--muted);
  font-size: 14px;
}

.empty-text {
  color: var(--muted);
}

.app-frame-wrap {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: #0a1628;
  position: relative;
}

.app-back-btn {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
}

.return-menu-btn {
  width: auto;
  min-height: 48px;
  margin: 0;
  padding: 10px 18px;
  color: #f8fafc;
  background: rgba(31, 47, 70, 0.86);
  border: 1px solid rgba(190, 210, 238, 0.26);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 24px rgba(0, 0, 0, 0.18);
  font-size: 15px;
  font-weight: 800;
}

.return-menu-btn:hover {
  background: rgba(62, 86, 120, 0.82);
  border-color: rgba(244, 197, 111, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 12px 28px rgba(0, 0, 0, 0.20);
}

iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

@media (max-width: 720px) {
  .entry-actions,
  .mode-actions,
  .mode-card-grid,
  .upload-row,
  .batch-item {
    grid-template-columns: 1fr;
  }

  .gate {
    padding: 22px;
    align-items: start;
  }

  .entry-box {
    transform: none;
    padding-top: 52px;
  }

  .mode-box {
    transform: none;
    padding-top: 46px;
  }

  .brand-logo {
    width: min(340px, 92%);
    margin-bottom: 20px;
  }

  .entry-box h1 {
    font-size: 42px;
  }

  .entry-actions {
    gap: 14px;
    margin-top: 34px;
  }

  .entry-card {
    min-height: 104px;
    padding: 24px;
  }

  .mode-card {
    min-height: 0;
    padding: 24px;
  }

  .manager-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
