:root {
  --teal: #2EB5C4;
  --teal-dark: #1a8a96;
  --blue: #2b6cb0;
  --blue-dark: #1a3a5c;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --muted: #718096;
  --green: #38a169;
  --red: #e53e3e;
  --yellow: #d69e2e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.center { text-align: center; }
.mono { font-family: "SF Mono", Consolas, Monaco, "Courier New", monospace; }

.screen { min-height: 100vh; }
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a3a5c 0%, #2EB5C4 100%);
  position: relative;
  overflow: hidden;
}
#login-screen::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: url('/static/logo.svg') center / 80% no-repeat;
  opacity: 0.06;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.login-card {
  background: white;
  border-radius: 12px;
  padding: 36px 40px;
  width: 420px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  position: relative;
  z-index: 1;
}
.logo-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
}
.login-logo {
  width: 64px;
  height: auto;
  margin-bottom: 8px;
}
.brand { font-size: 22px; font-weight: 700; color: var(--blue-dark); }
.brand-sub {
  font-size: 11px;
  color: var(--teal);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
}
.login-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}
.footer-logo-sm { width: 22px; height: auto; opacity: 0.5; }

.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin: 18px 0 6px;
}
.email-row, .code-row { display: flex; gap: 0; align-items: center; }
.email-row input { border-radius: 6px 0 0 6px; flex: 1; }
.email-suffix {
  display: inline-block;
  padding: 9px 12px;
  background: #edf2f7;
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0 6px 6px 0;
  color: var(--muted);
  font-size: 13px;
}
.code-row input { border-radius: 6px 0 0 6px; flex: 1; }
.code-row button { border-radius: 0 6px 6px 0; }

.msg { min-height: 18px; margin: 10px 0; font-size: 12px; }
.msg.err { color: var(--red); }
.msg.ok { color: var(--green); }
.msg.warn { color: var(--yellow); }

.full { width: 100%; }
.btn-success.full { margin-top: 10px; }

input[type="text"], textarea {
  padding: 9px 11px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
input[type="text"]:focus, textarea:focus { border-color: var(--teal); }
input.mono, textarea.mono { font-family: "SF Mono", Consolas, Monaco, monospace; font-size: 12px; }
input:disabled, textarea:disabled { background: #f7fafc; color: var(--muted); cursor: not-allowed; }
textarea { resize: vertical; min-height: 100px; width: 100%; }

button {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  font-family: inherit;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover:not(:disabled) { background: #3182ce; }
.btn-success { background: var(--teal); color: white; }
.btn-success:hover:not(:disabled) { background: var(--teal-dark); }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #edf2f7; }
.btn-link { background: transparent; color: var(--teal); padding: 4px 8px; font-weight: 600; }
.btn-link:hover { text-decoration: underline; }

.pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.pill-red { background: #fff5f5; color: var(--red); border: 1px solid #fed7d7; }
.pill-green { background: #f0fff4; color: var(--green); border: 1px solid #c6f6d5; }
.pill-yellow { background: #fffff0; color: var(--yellow); border: 1px solid #faf089; }

.topbar {
  background: linear-gradient(135deg, var(--blue-dark) 0%, #0f2440 100%);
  color: white;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--teal);
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-logo-img { width: 32px; height: auto; filter: brightness(0) invert(1); }
.topbar-brand { font-size: 17px; font-weight: 700; }
.topbar-tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  vertical-align: middle;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-right .muted { color: #a0c4e8; font-size: 12px; }

.title-logo { width: 20px; height: auto; vertical-align: -4px; margin-right: 4px; }

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  border-left: 3px solid var(--teal);
}
.card-title { font-size: 13px; font-weight: 700; color: var(--blue-dark); margin-bottom: 12px; }

.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.form-row:last-child { margin-bottom: 0; }
.lbl {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  min-width: 110px;
}
.form-row input[type="text"] { flex: 1; min-width: 200px; }
.btn-row { gap: 8px; }
.hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 14px;
}
.tab {
  background: transparent;
  color: var(--muted);
  padding: 8px 18px;
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.tab.active { color: var(--teal); border-bottom-color: var(--teal); font-weight: 600; }
.tab-content { padding-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { background: #f7fafc; font-weight: 600; color: var(--text); font-size: 12px; }
tbody tr:hover { background: #f0fafb; }
td.mono { font-family: "SF Mono", Consolas, monospace; font-size: 12px; }
td.status-ok { color: var(--green); font-weight: 600; }
td.status-fail { color: var(--red); font-weight: 600; }
td.status-pending { color: var(--muted); }
td.status-running { color: var(--teal); font-weight: 600; }

.batch-results { margin-top: 14px; }
#batch-table tbody tr.selected { background: #e6f7f9; }

.info-card { background: #f7fafc; }
.info-line {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--blue-dark);
  margin-bottom: 10px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  transition: width 0.3s;
}
.status-line { font-size: 12px; margin-bottom: 12px; }
.log {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 11px;
  background: #1a202c;
  color: #cbd5e0;
  padding: 12px;
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ============== Agreement ============== */
.agreement-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.agreement-card {
  background: white; border-radius: 12px; max-width: 680px; width: 100%;
  max-height: 90vh; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex; flex-direction: column; overflow: hidden;
}
.agreement-header {
  text-align: center; padding: 24px 24px 12px;
  border-bottom: 3px solid var(--teal);
}
.agreement-header h2 { font-size: 18px; color: var(--blue-dark); margin: 4px 0; }
.agreement-sub { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.agreement-body {
  padding: 16px 24px; flex: 1; overflow: hidden;
}
.agreement-scroll {
  max-height: 360px; overflow-y: auto; padding-right: 8px;
  font-size: 13px; line-height: 1.7; color: var(--text);
}
.agreement-scroll h3 {
  font-size: 14px; color: var(--blue-dark); margin: 16px 0 6px;
  border-bottom: 1px solid var(--border); padding-bottom: 4px;
}
.agreement-scroll h3:first-child { margin-top: 0; }
.agreement-scroll p { margin: 4px 0 10px; }
.agreement-scroll ol { margin: 4px 0 10px; padding-left: 20px; }
.agreement-scroll ol li { margin-bottom: 4px; }
.agreement-scroll strong { color: var(--blue-dark); }
.agreement-highlight {
  background: #fff8e1; border: 1px solid #f6c343;
  border-radius: 6px; padding: 10px 14px; margin-top: 12px !important;
  font-size: 12px; color: #744210;
}
.agreement-actions {
  padding: 16px 24px 24px; border-top: 1px solid var(--border);
}
.agree-check {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; cursor: pointer; margin-bottom: 12px;
  user-select: none;
}
.agree-check input[type="checkbox"] {
  width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0;
  accent-color: var(--teal); cursor: pointer;
}
.agree-check span strong { color: var(--red); }

.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
  color: var(--muted);
  font-size: 11px;
  opacity: 0.7;
}
.footer-logo { width: 22px; height: auto; opacity: 0.4; }
.admin-link { color: var(--teal); font-size: 12px; text-decoration: none; font-weight: 600; margin-right: 8px; }
.admin-link:hover { text-decoration: underline; }
