:root {
  --ink: #132337;
  --muted: #68788a;
  --line: #dce4ea;
  --paper: #ffffff;
  --canvas: #f3f6f7;
  --navy: #10253b;
  --orange: #ff5a26;
  --orange-dark: #df4214;
  --green: #0a9168;
  --red: #d93c4b;
  --amber: #b97700;
  --shadow: 0 24px 80px rgba(17, 34, 53, 0.1);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 82% 2%, rgba(255, 90, 38, 0.10), transparent 28rem),
    linear-gradient(180deg, #eef3f4 0, #f7f9f9 42rem, #f3f6f7 100%);
}

button, input, select, textarea { font: inherit; }
button, select, label[for] { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
input { min-width: 0; }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(19, 35, 55, 0.11);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.brand { display: inline-flex; gap: 13px; align-items: center; color: inherit; text-decoration: none; }
.brand strong { display: block; font-size: 17px; letter-spacing: -0.02em; }
.brand small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; letter-spacing: 0.08em; text-transform: uppercase; }
.brand-mark { width: 37px; height: 37px; border-radius: 11px; background: var(--navy); display: flex; gap: 3px; align-items: flex-end; justify-content: center; padding: 9px; transform: rotate(-4deg); box-shadow: 0 8px 20px rgba(16, 37, 59, 0.18); }
.brand-mark i { display: block; width: 5px; border-radius: 4px; background: var(--orange); }
.brand-mark i:nth-child(1) { height: 10px; }
.brand-mark i:nth-child(2) { height: 18px; }
.brand-mark i:nth-child(3) { height: 14px; }

.system-state { display: inline-flex; align-items: center; gap: 9px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.55); font-size: 12px; font-weight: 600; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(185,119,0,.12); }
.system-state.online .pulse { background: var(--green); box-shadow: 0 0 0 4px rgba(10,145,104,.12); }
.system-state.offline .pulse { background: var(--red); box-shadow: 0 0 0 4px rgba(217,60,75,.12); }
.account-menu { display: flex; align-items: center; gap: 8px; }
.account-menu button { border: 1px solid var(--line); background: rgba(255,255,255,.7); color: var(--ink); padding: 8px 10px; border-radius: 9px; font-size: 11px; font-weight: 750; }
.account-menu button:last-child { color: var(--red); }
.account-name { display: grid; text-align: right; margin: 0 4px 0 8px; }
.account-name b { font-size: 12px; }
.account-name small { color: var(--orange-dark); font-size: 9px; font-weight: 850; letter-spacing: .1em; }

.login-view { min-height: calc(100vh - 171px); display: grid; place-items: center; padding: 54px 0; }
.login-card { width: min(560px, 100%); background: var(--paper); padding: clamp(28px, 5vw, 52px); border: 1px solid rgba(19,35,55,.07); border-radius: 24px; box-shadow: var(--shadow); }
.login-card h1 { margin: 13px 0 18px; color: var(--navy); font-size: clamp(40px, 7vw, 66px); line-height: .98; letter-spacing: -.06em; }
.login-card h1 span { color: transparent; -webkit-text-stroke: 1.3px #73808c; }
.login-card > p { color: var(--muted); line-height: 1.65; font-size: 14px; }
.login-card form { display: grid; gap: 15px; margin-top: 28px; }
.login-button { margin-top: 3px; justify-content: space-between; width: 100%; }
.login-help { margin: 18px 0 0; text-align: center; font-size: 11px !important; }
.form-message { min-height: 18px; margin: 0; color: var(--red); font-size: 12px; line-height: 1.5; }

.hero { padding: 68px 0 38px; }
.eyebrow, .section-number { color: var(--orange-dark); font-weight: 800; letter-spacing: .16em; font-size: 11px; }
.hero h1 { margin: 15px 0 18px; max-width: 820px; color: var(--navy); font-size: clamp(42px, 6.5vw, 78px); line-height: .98; letter-spacing: -.065em; font-weight: 770; }
.hero h1 span { color: transparent; -webkit-text-stroke: 1.5px #6e7d8c; }
.hero-copy { max-width: 680px; color: var(--muted); font-size: 17px; line-height: 1.7; margin: 0; }

.overview { margin-top: 42px; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.6); overflow: hidden; backdrop-filter: blur(14px); }
.overview-item { padding: 18px 22px; border-right: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.overview-item:last-child { border-right: 0; }
.overview-item span { color: var(--muted); font-size: 12px; font-weight: 650; }
.overview-item strong { font-size: 27px; letter-spacing: -.04em; }
.overview-item.valid strong { color: var(--green); }
.overview-item.invalid strong { color: var(--red); }

.submit-panel { margin-top: 28px; background: var(--paper); border-radius: 22px; padding: 30px; box-shadow: var(--shadow); border: 1px solid rgba(19,35,55,.06); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.panel-heading > div { display: flex; align-items: center; gap: 14px; }
.panel-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.limit-note { color: var(--muted); font-size: 12px; background: var(--canvas); border-radius: 999px; padding: 7px 11px; }

.paste-panel { margin-top: 28px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(255,90,38,.25); outline-offset: 2px; }

.field-grid { display: grid; gap: 14px; }
.field { display: grid; gap: 8px; }
.field > span { font-size: 12px; font-weight: 750; }
.field em { float: right; color: var(--muted); font-style: normal; font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); background: #fbfcfc; border-radius: 12px; color: var(--ink); padding: 12px 14px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--orange); background: white; box-shadow: 0 0 0 3px rgba(255,90,38,.08); }
.field textarea { resize: vertical; min-height: 190px; line-height: 1.55; }

.submit-footer { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.submit-footer p { margin: 0; color: var(--muted); font-size: 12px; }
.submit-footer p span { color: var(--green); font-weight: 900; }
.primary-button { display: inline-flex; align-items: center; gap: 22px; border: 0; border-radius: 12px; padding: 13px 17px 13px 20px; background: var(--orange); color: white; font-weight: 750; box-shadow: 0 10px 24px rgba(255,90,38,.24); transition: .18s ease; }
.primary-button:hover { background: var(--orange-dark); transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .6; transform: none; }
.primary-button b { font-size: 19px; font-weight: 400; }
.secondary-button { border: 0; border-radius: 11px; padding: 12px 15px; background: var(--navy); color: white; font-weight: 750; }

.jobs-section { padding: 72px 0 80px; }
.jobs-heading { padding-bottom: 19px; border-bottom: 1px solid var(--line); }
.retention-note { margin: 13px 0 0; color: var(--muted); font-size: 11px; }
.text-button { border: 0; background: transparent; color: var(--orange-dark); font-size: 12px; font-weight: 800; }
.jobs-list { display: grid; gap: 14px; margin-top: 18px; }
.empty-state { padding: 56px 20px; text-align: center; border: 1px dashed #bac6ce; border-radius: 17px; color: var(--muted); }
.empty-state span { font-size: 30px; color: #a7b2bb; }
.empty-state h3 { color: var(--ink); margin: 9px 0 5px; font-size: 16px; }
.empty-state p { margin: 0; font-size: 13px; }

.job-card { background: white; border: 1px solid var(--line); border-radius: 17px; padding: 20px; box-shadow: 0 8px 30px rgba(19,35,55,.045); }
.job-top { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.job-title { min-width: 0; }
.job-title h3 { margin: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-meta { margin-top: 7px; display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.status-pill { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; font-size: 10px; font-weight: 850; letter-spacing: .05em; text-transform: uppercase; background: #edf1f4; color: var(--muted); }
.status-pill.running { background: #fff1eb; color: var(--orange-dark); }
.status-pill.completed { background: #e8f7f1; color: var(--green); }
.status-pill.failed { background: #fdecef; color: var(--red); }
.status-pill.cancelled { background: #f1f1f1; color: #6b6b6b; }

.job-phase { margin: 18px 0 9px; display: flex; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 12px; }
.job-phase strong { color: var(--ink); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-track { height: 7px; border-radius: 999px; background: #eaf0f2; overflow: hidden; }
.progress-bar { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--orange), #ff8a4f); transition: width .35s ease; }

.job-bottom { margin-top: 17px; display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.job-stats { display: flex; gap: 15px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.job-stats b { color: var(--ink); font-size: 13px; }
.job-stats .good b { color: var(--green); }
.job-stats .bad b { color: var(--red); }
.job-stats .duplicates b { color: var(--amber); }
.queue-position { padding: 2px 7px; border-radius: 999px; background: #edf1f4; color: var(--ink); }
.job-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.job-actions button, .job-actions a { border: 1px solid var(--line); background: white; color: var(--ink); text-decoration: none; padding: 7px 10px; border-radius: 8px; font-size: 11px; font-weight: 750; }
.job-actions a { background: var(--navy); border-color: var(--navy); color: white; }
.job-actions .cancel { color: var(--red); }
.job-actions .delete { color: #775100; }
.owner-chip { color: var(--navy); font-weight: 750; }
.admin-flag { padding: 2px 6px; border-radius: 999px; background: #fff0d8; color: #8a5b00; font-weight: 750; }
.job-error { margin: 14px 0 0; padding: 10px 12px; border-radius: 9px; background: #fff1f2; color: #a92838; font-size: 11px; line-height: 1.5; }
.invalid-results { margin-top: 17px; padding: 15px; border: 1px solid #f2cbd0; border-radius: 13px; background: #fff8f9; }
.admin-id-results { margin-top: 17px; padding: 15px; border: 1px solid #cbd8e0; border-radius: 13px; background: #f7fafb; }
.admin-id-results .invalid-results-heading strong { color: var(--navy); }
.admin-id-results button { border: 1px solid #b9c9d3; border-radius: 8px; background: white; color: var(--navy); padding: 6px 9px; font-size: 11px; font-weight: 750; }
.invalid-results-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.invalid-results-heading > div { display: flex; align-items: baseline; gap: 8px; }
.invalid-results-heading strong { color: var(--red); font-size: 13px; }
.invalid-results-heading span { color: var(--muted); font-size: 11px; }
.invalid-results button { border: 1px solid #e9b7be; border-radius: 8px; background: white; color: #a92838; padding: 6px 9px; font-size: 11px; font-weight: 750; }
.invalid-results button:hover { border-color: var(--red); background: #fff1f2; }
.invalid-id-list { display: grid; gap: 7px; margin: 12px 0 0; padding: 0; list-style: none; }
.invalid-id-list li { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 9px 8px 11px; border-radius: 9px; background: white; border: 1px solid #f0d9dc; }
.invalid-id-list code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font: 12px/1.4 Consolas, monospace; }
.invalid-id-list button { flex: 0 0 auto; }
.id-status { flex: 0 0 auto; color: var(--muted); font-size: 10px; font-weight: 700; }
.job-logs { margin-top: 15px; border-top: 1px solid var(--line); padding-top: 12px; max-height: 220px; overflow: auto; }
.log-line { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 5px 0; color: var(--muted); font: 11px/1.45 Consolas, monospace; }
.log-line time { color: #9aa6af; }

.admin-section { margin-top: 34px; padding: 30px; background: #edf2f3; border: 1px solid var(--line); border-radius: 22px; }
.admin-grid { display: grid; grid-template-columns: minmax(260px, .72fr) minmax(0, 1.6fr); gap: 18px; margin-top: 24px; }
.create-user-card, .users-card { background: white; border: 1px solid var(--line); border-radius: 15px; padding: 18px; }
.create-user-card { display: grid; align-content: start; gap: 14px; }
.create-user-card h3 { margin: 0 0 3px; font-size: 15px; }
.users-list { display: grid; gap: 8px; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; }
.user-row > div:first-child { min-width: 0; display: grid; gap: 4px; }
.user-row strong { font-size: 13px; }
.user-row span { color: var(--muted); font-size: 10px; }
.user-status { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.user-status em { color: var(--amber); font-size: 10px; font-style: normal; font-weight: 700; }
.user-status button { border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--orange-dark); padding: 7px 9px; font-size: 10px; font-weight: 750; }
.credential-result { margin-bottom: 12px; padding: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px solid #b9ddcf; border-radius: 11px; background: #f0faf6; }
.credential-result > div { display: grid; gap: 2px; margin-right: auto; }
.credential-result strong { color: var(--green); font-size: 12px; }
.credential-result span { color: var(--muted); font-size: 10px; }
.credential-result code { padding: 6px 8px; background: white; border: 1px solid #c7e3d8; border-radius: 7px; font-size: 11px; }
.credential-result button { border: 0; border-radius: 7px; background: var(--green); color: white; padding: 7px 9px; font-size: 10px; font-weight: 750; }
.empty-inline { color: var(--muted); font-size: 12px; text-align: center; }
.metrics-panel { margin-top: 18px; padding: 18px; background: white; border: 1px solid var(--line); border-radius: 15px; }
.metrics-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.metrics-heading h3 { margin: 0; font-size: 15px; }
.metrics-heading p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.metrics-heading > span { flex: 0 0 auto; color: var(--muted); font-size: 11px; font-weight: 750; }
.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 15px; }
.metric-card { display: grid; gap: 5px; padding: 12px; border-radius: 11px; background: #f5f8f9; }
.metric-card span { color: var(--muted); font-size: 10px; }
.metric-card strong { color: var(--navy); font-size: 18px; }

.modal-backdrop { position: fixed; z-index: 30; inset: 0; padding: 22px; display: grid; place-items: center; background: rgba(7,20,33,.65); backdrop-filter: blur(8px); }
.modal-card { width: min(500px, 100%); max-height: calc(100vh - 44px); overflow: auto; padding: 27px; background: white; border-radius: 20px; box-shadow: 0 30px 90px rgba(0,0,0,.3); }
.modal-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.modal-heading h2 { margin: 5px 0 0; font-size: 23px; }
.modal-close { border: 0; background: transparent; color: var(--muted); font-size: 28px; line-height: 1; }
.modal-card > p { margin: 15px 0 20px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.modal-card form { display: grid; gap: 14px; }
.modal-card .primary-button { margin-top: 3px; justify-content: space-between; width: 100%; }

footer { min-height: 84px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 20px; color: var(--muted); font-size: 11px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(390px, calc(100vw - 48px)); padding: 13px 16px; border-radius: 11px; background: var(--navy); color: white; box-shadow: 0 15px 45px rgba(16,37,59,.28); font-size: 13px; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #a92838; }

@media (max-width: 760px) {
  .page-shell { width: min(100% - 24px, 1180px); }
  .topbar { min-height: 72px; }
  .system-state span:last-child { display: none; }
  .account-name { display: none; }
  .account-menu button { padding: 7px 8px; font-size: 10px; }
  .account-menu button:first-of-type { display: none; }
  .login-view { min-height: calc(100vh - 155px); padding: 30px 0; }
  .login-card { padding: 28px 22px; border-radius: 18px; }
  .hero { padding-top: 46px; }
  .hero h1 { font-size: clamp(39px, 13vw, 60px); }
  .hero-copy { font-size: 15px; }
  .overview { grid-template-columns: repeat(2, 1fr); }
  .overview-item:nth-child(2) { border-right: 0; }
  .overview-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .submit-panel { padding: 20px; border-radius: 17px; }
  .limit-note { display: none; }
  .submit-footer, .job-bottom, footer { align-items: stretch; flex-direction: column; }
  .primary-button { justify-content: space-between; width: 100%; }
  .job-top { gap: 10px; }
  .job-actions { width: 100%; }
  .job-actions button, .job-actions a { flex: 1; text-align: center; }
  .admin-section { padding: 20px; border-radius: 17px; }
  .admin-grid { grid-template-columns: 1fr; }
  .metrics-heading { flex-direction: column; gap: 8px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .user-row { align-items: flex-start; flex-direction: column; }
  .user-status { width: 100%; justify-content: space-between; }
  .credential-result { align-items: stretch; flex-direction: column; }
  .invalid-results-heading { align-items: stretch; flex-direction: column; }
  .invalid-results-heading button { width: 100%; }
  footer { justify-content: center; padding: 22px 0; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
