:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
  --nav: #1e3a8a;
  --nav-soft: #1d4ed8;
  --blue: #2563eb;
  --blue-strong: #1d4ed8;
  --blue-soft: #dbeafe;
  --bg: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --line: rgba(148, 163, 184, 0.32);
  --input: #f8fafc;
  --shadow: none;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  font-family: var(--font-sans);
}

html.dark {
  color-scheme: dark;
  --nav: rgba(0, 0, 0, 0.42);
  --nav-soft: rgba(30, 58, 138, 0.5);
  --blue: #60a5fa;
  --blue-strong: #3b82f6;
  --blue-soft: rgba(30, 58, 138, 0.46);
  --bg: #08204a;
  --text: #ffffff;
  --muted: #9ca3af;
  --panel: rgba(31, 41, 55, 0.82);
  --panel-solid: #111827;
  --line: rgba(255, 255, 255, 0.11);
  --input: rgba(17, 24, 39, 0.55);
  --shadow: none;
  --green: #4ade80;
  --red: #f87171;
  --amber: #fbbf24;
}

* {
  box-sizing: border-box;
  font-family: var(--font-sans) !important;
  letter-spacing: 0 !important;
}

*::before,
*::after {
  box-sizing: border-box;
  font-family: var(--font-sans) !important;
}

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  font-family: var(--font-sans) !important;
  text-rendering: auto;
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
}

button,
input,
textarea,
select,
table,
pre,
code {
  font-family: var(--font-sans) !important;
}

button {
  font-family: var(--font-sans) !important;
  letter-spacing: 0;
  box-shadow: none;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: #f8fafc;
  transition: background .4s ease;
}

html.dark .page-bg {
  background: linear-gradient(135deg, #172554 0%, #1e3a8a 52%, #312e81 100%);
}

.page-bg::after { display: none; }

.preloader {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  transition: opacity .4s ease, visibility .4s ease;
}

html.dark .preloader { background: #172554; }
.preloader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  margin-bottom: 22px;
}

.loader-logo {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 14px;
  color: #fff;
  background: var(--blue);
  font-weight: 900;
}

.loader-ring {
  position: absolute;
  inset: 0;
  border: 4px solid #e2e8f0;
  border-top-color: var(--blue);
  border-radius: 999px;
  animation: spin .9s linear infinite;
}

html.dark .loader-ring { border-color: rgba(30, 58, 138, .5); border-top-color: #60a5fa; }
.preloader h1 { margin: 0 0 8px; font-size: 20px; text-transform: uppercase; }
.preloader p { margin: 0; color: var(--blue); font-size: 14px; font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(220px, auto) minmax(170px, 1fr);
  align-items: center;
  gap: 16px;
  height: 80px;
  padding: 0 clamp(16px, 4vw, 42px);
  color: #fff;
  background: var(--nav);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
  backdrop-filter: none;
}

.brand {
  display: flex;
  align-items: center;
  color: #fff;
  text-decoration: none;
}

.brand-text { font-size: 24px; font-weight: 800; letter-spacing: 0; }
.nav-title { text-align: center; color: #bfdbfe; font-size: 17px; font-weight: 700; }
.nav-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }

.nav-pill,
.icon-pill {
  color: #fff;
  background: rgba(30, 64, 175, 0.76);
  border: 1px solid rgba(147, 197, 253, 0.24);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  transition: background .18s ease, transform .18s ease, opacity .18s ease;
}

.nav-pill { min-height: 34px; padding: 0 14px; }
.icon-pill { display: grid; place-items: center; min-width: 52px; height: 38px; padding: 0 12px; font-size: 13px; }
.nav-pill:hover, .icon-pill:hover { background: rgba(29, 78, 216, .9); transform: none; }

.main {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 32px 0 54px;
}

.ambient-light { display: none; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  align-items: stretch;
}

.panel {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: none;
}

.guide-panel { padding: 30px; }

.panel-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 30px;
}

.heading-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: #fff;
  background: var(--blue);
  font-weight: 900;
  font-style: normal;
}

.panel-heading h1,
.tab-heading h2,
.history-head h2,
.result-head h3 {
  margin: 0;
  color: var(--text);
}

.panel-heading h1 { font-size: 25px; line-height: 1.15; }
.panel-heading p,
.tab-heading p,
.history-head p,
.result-head p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.steps { display: grid; gap: 28px; }
.step { display: flex; gap: 16px; align-items: flex-start; }

.step-no {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  color: var(--blue-strong);
  background: var(--blue-soft);
  border: 1px solid rgba(37, 99, 235, .18);
  font-weight: 900;
}

.step h2 { margin: 0 0 5px; font-size: 16px; color: var(--text); }
.step p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.62; }

.notice-box {
  margin-top: 28px;
  padding: 16px;
  border-radius: 14px;
  background: rgba(37, 99, 235, .08);
  border: 1px solid rgba(37, 99, 235, .18);
}
.notice-box p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  min-height: 64px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}

.tab-btn span {
  display: inline;
  min-width: 0;
  height: auto;
  margin-right: 6px;
  border-radius: 0;
  background: transparent;
  color: var(--blue-strong);
  font-size: inherit;
  font-weight: inherit;
}
.tab-btn:hover { color: var(--blue-strong); }
.tab-btn.active {
  color: var(--blue-strong);
  border-bottom-color: var(--blue-strong);
  background: rgba(37, 99, 235, .08);
}

.panel-body { padding: 30px; }
.tab-content { display: none; }
.tab-content.active { display: block; }

@keyframes fadeIn {}

.tab-heading { text-align: center; margin-bottom: 26px; }
.tab-heading h2 { font-size: 25px; }

label {
  display: block;
  margin: 18px 0 8px;
  color: color-mix(in srgb, var(--text) 76%, var(--muted));
  font-size: 14px;
  font-weight: 800;
}

.input-icon { position: relative; }
.input-icon span {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-weight: 900;
  pointer-events: none;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  color: var(--text);
  background: var(--input);
  padding: 14px 15px;
  font-size: 14px;
  line-height: 1.55;
  transition: border-color .18s ease, background .18s ease;
}

.input-icon input { padding-left: 44px; }
textarea { min-height: 156px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #94a3b8; }
input:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: none;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.button-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.primary-btn,
.secondary-btn,
.icon-btn {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: opacity .18s ease, background .18s ease, border-color .18s ease, color .18s ease;
}

.primary-btn {
  color: #fff;
  background: var(--blue);
  padding: 14px 18px;
  box-shadow: none;
}

.primary-btn:hover { background: var(--blue-strong); transform: none; }
.primary-btn.full { width: 100%; margin-top: 20px; }

.secondary-btn {
  color: var(--text);
  background: #f1f5f9;
  border: 1px solid var(--line);
  padding: 11px 14px;
}

html.dark .secondary-btn { background: rgba(55, 65, 81, .72); color: #fff; }
.secondary-btn:hover { transform: none; background: #e2e8f0; }
html.dark .secondary-btn:hover { background: rgba(75, 85, 99, .82); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.alert {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

html.dark .alert { background: rgba(17, 24, 39, .52); }
.alert.success { color: var(--green); border-color: rgba(22, 163, 74, .24); background: rgba(22, 163, 74, .08); }
.alert.error { color: var(--red); border-color: rgba(220, 38, 38, .22); background: rgba(220, 38, 38, .08); }
.alert.info { color: var(--blue-strong); border-color: rgba(37, 99, 235, .22); background: rgba(37, 99, 235, .08); }

.metric-grid,
.bulk-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.bulk-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-grid div,
.bulk-summary div {
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(37, 99, 235, .06);
  padding: 18px 12px;
}

.metric-grid strong,
.bulk-summary strong {
  display: block;
  color: var(--blue-strong);
  font-size: 34px;
  line-height: 1;
}

.metric-grid span,
.bulk-summary span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.result-box {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(248, 250, 252, .72);
  padding: 18px;
}

html.dark .result-box { background: rgba(17, 24, 39, .36); }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }

.progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .28);
  overflow: hidden;
  margin-bottom: 14px;
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--blue);
  transition: width .25s ease;
}

.panel-footer {
  padding: 14px 30px;
  border-top: 1px solid var(--line);
  background: rgba(248, 250, 252, .72);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

html.dark .panel-footer { background: rgba(17, 24, 39, .36); }

.history-panel { margin-top: 28px; padding: 24px; }
.history-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 10px; }
.history-actions { display: flex; gap: 10px; align-items: center; width: min(620px, 100%); }
.history-actions input { flex: 1; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  font-size: 13px;
}

th {
  text-align: left;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  font-size: 11px;
}

td {
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  padding: 13px 10px;
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
  vertical-align: top;
}

tr:hover td { background: rgba(37, 99, 235, .05); }
.mono { font-family: var(--font-sans) !important; }
.link-cell { max-width: 360px; word-break: break-all; }
.link-cell a { color: var(--blue-strong); text-decoration: none; font-weight: 700; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 900;
}

html.dark .status { background: rgba(55, 65, 81, .62); }
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}
.status.running, .status.pending, .status.valid { color: var(--blue-strong); }
.status.success, .status.completed { color: var(--green); }
.status.failed, .status.invalid, .status.error { color: var(--red); }
.status.cancelled { color: var(--amber); }
.usage-used { color: var(--amber); font-weight: 800; }
.usage-free { color: var(--green); font-weight: 800; }
.usage-none { color: var(--muted); font-weight: 800; }

.small-btn {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f1f5f9;
  color: var(--text);
  cursor: pointer;
  padding: 7px 11px;
  font-weight: 900;
}

html.dark .small-btn { background: rgba(55, 65, 81, .72); color: #fff; }
.small-btn.danger { color: var(--red); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .7);
  backdrop-filter: none;
}

.modal-panel {
  display: flex;
  flex-direction: column;
  width: min(1080px, 100%);
  max-height: 86vh;
  overflow: hidden;
  border-radius: 18px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

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

.modal-head h2 { margin: 0; }
.modal-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 20px 22px; overflow: auto; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--text);
  background: rgba(148, 163, 184, .18);
  font-size: 26px;
}

.hidden { display: none !important; }

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr auto;
    height: auto;
    min-height: 78px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .nav-title { grid-column: 1 / -1; grid-row: 2; font-size: 14px; }
  .content-grid { grid-template-columns: 1fr; }
  .history-head { flex-direction: column; }
  .history-actions { width: 100%; }
}

@media (max-width: 680px) {
  .main { width: min(100% - 18px, 1180px); padding-top: 18px; }
  .brand-text { display: block; font-size: 20px; }
  .guide-panel, .panel-body, .history-panel { padding: 18px; }
  .tabs { grid-template-columns: 1fr; }
  .form-row, .result-head, .history-actions { flex-direction: column; align-items: stretch; }
  .button-row { flex-direction: column; }
  .metric-grid, .bulk-summary { grid-template-columns: 1fr; }
}
