:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #17212b;
  --muted: #63707d;
  --line: #dce2e7;
  --line-strong: #c9d1d8;
  --accent: #116b5a;
  --accent-hover: #0d594b;
  --blue: #236a9e;
  --green: #177245;
  --amber: #a35c00;
  --red: #b42318;
  --shadow: 0 14px 38px rgba(23, 33, 43, 0.09);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(140deg, #eef7f3 0 42%, #f4f6f8 42% 72%, #eef3f8 72%); }
.login-panel { width: min(100%, 390px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 36px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; background: var(--accent); color: white; border-radius: 7px; }
.brand-mark svg { width: 23px; height: 23px; }
.brand-mark.small { width: 38px; height: 38px; }
.eyebrow { margin: 22px 0 6px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0; }
h1, h2, p { margin-top: 0; }
.login-panel h1 { margin-bottom: 30px; font-size: 28px; line-height: 1.2; }
label { display: block; margin: 16px 0 7px; font-size: 13px; font-weight: 700; }
.input-wrap, .search-wrap { display: flex; align-items: center; gap: 9px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 12px; }
.input-wrap:focus-within, .search-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(17, 107, 90, 0.1); }
.input-wrap svg, .search-wrap svg { width: 17px; color: var(--muted); flex: none; }
input { min-width: 0; width: 100%; height: 42px; border: 0; outline: 0; background: transparent; color: var(--ink); }
.form-error { margin: 12px 0 0; color: var(--red); font-size: 13px; line-height: 1.5; }

.primary-button, .secondary-button, .icon-button, .text-button { border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; border-radius: 6px; font-weight: 700; }
.primary-button { padding: 0 16px; background: var(--accent); color: white; }
.primary-button:hover { background: var(--accent-hover); }
.primary-button.wide { width: 100%; margin-top: 24px; min-height: 44px; }
.secondary-button { padding: 0 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); }
.secondary-button:hover, .icon-button:hover { background: #eef2f4; }
.icon-button { width: 38px; height: 38px; padding: 0; color: var(--ink); background: transparent; border: 1px solid var(--line); }
.text-button { padding: 0; background: transparent; color: var(--blue); }
button svg { width: 17px; height: 17px; }
button:disabled { cursor: wait; opacity: 0.58; }

.topbar { height: 66px; padding: 0 clamp(18px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand-lockup, .top-actions { display: flex; align-items: center; gap: 12px; }
.brand-lockup > div { display: grid; gap: 2px; }
.brand-lockup strong { font-size: 15px; }
.brand-lockup span { font-size: 12px; color: var(--muted); }
.brand-lockup .brand-mark { color: white; }
.sync-time { color: var(--muted); font-size: 12px; }
.content { width: min(1480px, 100%); margin: 0 auto; padding: 34px clamp(18px, 4vw, 56px) 60px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-heading .eyebrow { margin: 0 0 5px; }
.page-heading h1 { margin: 0; font-size: 32px; line-height: 1.2; }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 26px; }
.metric { min-width: 0; padding: 19px 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span, .metric small { display: block; color: var(--muted); font-size: 12px; white-space: normal; }
.metric strong { display: block; margin: 6px 0 4px; font-size: 28px; line-height: 1; }
.metric strong.text-metric { font-size: 18px; line-height: 28px; color: var(--amber); }

.account-section { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.section-toolbar { min-height: 75px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.section-toolbar h2 { margin: 0 0 3px; font-size: 17px; }
.section-toolbar > div > span { color: var(--muted); font-size: 12px; }
.filters { display: flex; gap: 10px; }
.search-wrap { width: min(270px, 34vw); }
select { min-width: 130px; height: 42px; padding: 0 34px 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: var(--surface); }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 1040px; border-collapse: collapse; table-layout: fixed; }
th { padding: 11px 14px; background: var(--surface-soft); color: var(--muted); text-align: left; font-size: 11px; font-weight: 800; }
td { padding: 14px; border-top: 1px solid var(--line); vertical-align: middle; font-size: 13px; overflow-wrap: anywhere; }
th:nth-child(1) { width: 19%; } th:nth-child(2) { width: 10%; } th:nth-child(3) { width: 9%; } th:nth-child(4) { width: 11%; } th:nth-child(5) { width: 14%; } th:nth-child(6) { width: 25%; } th:nth-child(7) { width: 12%; }
.identity { display: grid; gap: 4px; }
.identity strong { font-size: 14px; }
.identity code { color: var(--muted); font-size: 11px; }
.status { display: inline-flex; align-items: center; gap: 6px; min-height: 25px; padding: 0 8px; border-radius: 4px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-ready { color: var(--green); background: #eaf7ef; }
.status-busy { color: var(--blue); background: #eaf3f9; }
.status-invalid, .status-disabled { color: var(--red); background: #fceeed; }
.status-cooldown { color: var(--amber); background: #fff4e1; }
.task-count { display: grid; gap: 3px; }
.task-count span { font-weight: 800; }
.task-count small, .muted { color: var(--muted); font-size: 11px; }
.concurrency-control { display: flex; align-items: center; gap: 6px; }
.concurrency-control input { width: 62px; height: 34px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 5px; }
.concurrency-control button { width: 34px; height: 34px; }
.error-cell { color: var(--muted); font-size: 12px; line-height: 1.45; }
.error-cell.has-error { color: var(--red); }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.row-actions .icon-button { width: 34px; height: 34px; }
.row-actions .danger { color: var(--red); }
.empty-state { min-height: 230px; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--muted); }
.empty-state svg { width: 28px; }

dialog { width: min(660px, calc(100% - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); color: var(--ink); }
dialog::backdrop { background: rgba(23, 33, 43, 0.48); }
.dialog-shell { padding: 22px; }
.dialog-shell header, .dialog-shell footer, .import-options { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-shell header { margin-bottom: 18px; }
.dialog-shell header .eyebrow { margin: 0 0 4px; }
.dialog-shell h2 { margin: 0; font-size: 20px; }
textarea { width: 100%; resize: vertical; min-height: 240px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 6px; outline: 0; color: var(--ink); background: #fbfcfd; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(17, 107, 90, 0.1); }
.import-options { margin-top: 12px; }
.check-control { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; }
.check-control input { width: 16px; height: 16px; accent-color: var(--accent); }
.dialog-shell footer { margin-top: 20px; justify-content: flex-end; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; display: flex; align-items: center; gap: 9px; max-width: min(380px, calc(100% - 40px)); padding: 12px 15px; background: var(--ink); color: white; border-radius: 6px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: 160ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.toast svg { width: 18px; flex: none; }

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:last-child { border-bottom: 0; }
  .section-toolbar { align-items: stretch; flex-direction: column; }
  .filters { width: 100%; }
  .search-wrap { width: 100%; }
}

@media (max-width: 600px) {
  .topbar { height: auto; min-height: 64px; padding: 12px 16px; }
  .sync-time, .secondary-button span { display: none; }
  .content { padding: 24px 14px 40px; }
  .page-heading { align-items: center; }
  .page-heading h1 { font-size: 24px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 15px; }
  .metric strong { font-size: 23px; }
  .filters { flex-direction: column; }
  select { width: 100%; }
  .login-panel { padding: 28px 22px; }
  .import-options { align-items: flex-start; flex-direction: column; }
}
