/* GAR Admin — minimal */

*,
*::before,
*::after { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --border: #e6e6e6;
  --border-strong: #d4d4d4;
  --ink: #0f0f10;
  --ink-2: #1f1f22;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --accent: #111213;
  --accent-ink: #ffffff;
  --link: #1f1f22;
  --ok: #15803d;
  --warn: #a15c00;
  --err: #b42318;
  --info: #1d4ed8;
  --radius: 6px;
  --radius-lg: 8px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --surface: #0f0f11;
  --surface-2: #16171a;
  --border: #232428;
  --border-strong: #2f3035;
  --ink: #f4f4f5;
  --ink-2: #e4e4e7;
  --muted: #8a8f99;
  --muted-2: #5e636d;
  --accent: #f4f4f5;
  --accent-ink: #0a0a0b;
  --link: #e4e4e7;
  --ok: #4ade80;
  --warn: #f0b061;
  --err: #f17a7a;
  --info: #93b4ff;
}

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.005em;
}
h2 { font-size: 18px; }
h3 { font-size: 14px; }

p { margin: 0; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ===== Layout ===== */
.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 0 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.brand h1 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand small {
  color: var(--muted);
  font-size: 12px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.topnav a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  text-decoration: none;
}
.topnav a:hover {
  color: var(--ink);
  text-decoration: none;
}
.topnav a.is-active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
.topnav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ===== Theme switch ===== */
.theme-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.theme-toggle button {
  background: transparent;
  border: 0;
  color: var(--muted);
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.theme-toggle button + button { border-left: 1px solid var(--border); }
.theme-toggle button:hover { color: var(--ink); }
.theme-toggle button.is-active {
  background: var(--surface-2);
  color: var(--ink);
}
.theme-toggle .icon { width: 14px; height: 14px; }

/* ===== Buttons ===== */
.btn,
button.btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background 80ms linear, border-color 80ms linear, color 80ms linear;
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  opacity: 0.92;
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 6px 8px;
}
.btn--ghost:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.btn--sm { padding: 4px 8px; font-size: 12px; }

/* ===== Panels ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.panel + .panel { margin-top: 14px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.section-head h2 { font-size: 18px; }
.section-head p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}
.section-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row--end { justify-content: flex-end; }

.muted { color: var(--muted); }
.subtle { color: var(--muted-2); font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ===== Forms ===== */
.field {
  display: grid;
  gap: 6px;
  font-size: 13px;
}
.field-label {
  font-weight: 500;
  color: var(--ink-2);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
}
.field-hint { color: var(--muted); font-size: 12px; }
.field-error { color: var(--err); font-size: 12px; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="datetime-local"],
input[type="file"],
textarea,
select {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 80ms linear;
  min-width: 0;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input[type="file"] { padding: 6px 8px; cursor: pointer; }
::placeholder { color: var(--muted-2); opacity: 1; }

/* ===== Status / pills ===== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}
.pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  display: inline-block;
}

.status-pill { color: var(--muted); }
.status-pill--pending { color: var(--muted); }
.status-pill--scheduled { color: var(--info); }
.status-pill--running { color: var(--warn); }
.status-pill--retry { color: var(--warn); }
.status-pill--done { color: var(--ok); }
.status-pill--failed,
.status-pill--blocked_auth,
.status-pill--failed_competitors { color: var(--err); }

/* ===== Filter chips ===== */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 14px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
}
.filter-chip:hover { color: var(--ink); text-decoration: none; }
.filter-chip.is-active {
  background: var(--ink);
  color: var(--accent-ink);
  border-color: var(--ink);
}
.filter-chip .count {
  font-size: 11.5px;
  color: inherit;
  opacity: 0.7;
}

/* ===== Tables ===== */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: var(--surface);
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.table-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.cell-id { font-family: var(--mono); color: var(--muted); }
.cell-job { display: grid; gap: 2px; min-width: 0; }
.cell-job strong { font-weight: 500; color: var(--ink); }
.cell-job .cell-job-url {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

/* ===== Notices ===== */
.notice {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
}
.notice--err { border-color: var(--err); color: var(--err); }
.notice--ok { border-color: var(--ok); color: var(--ok); }
.notice--info { border-color: var(--info); color: var(--info); }
.notice--warn { border-color: var(--warn); color: var(--warn); }
.notice strong { font-weight: 600; color: inherit; }
.notice ul { margin: 4px 0 0; padding-left: 18px; color: inherit; }
.notice a { color: inherit; text-decoration: underline; }

/* ===== Login ===== */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}
.login-card h2 { font-size: 18px; }
.login-card .login-sub {
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
}
.login-card form { display: grid; gap: 12px; margin-top: 22px; }
.login-shell .theme-floating {
  position: fixed;
  top: 14px;
  right: 14px;
}

/* ===== Job detail ===== */
.metric {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.metric-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.metric-value {
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.metric-sub { font-size: 12px; color: var(--muted); }

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  font-size: 13px;
  margin: 0;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }

.artifact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.artifact-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.artifact-list .artifact-name { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
.artifact-list .artifact-path {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-all;
}

.log-block {
  background: var(--surface-2);
  color: var(--ink);
  padding: 12px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
}
.log-line { display: flex; gap: 10px; }
.log-line .log-time { color: var(--muted); flex-shrink: 0; }
.log-line .log-level { width: 56px; flex-shrink: 0; font-weight: 600; color: var(--muted); }
.log-line .log-level--info { color: var(--info); }
.log-line .log-level--warning, .log-line .log-level--warn { color: var(--warn); }
.log-line .log-level--error { color: var(--err); }
.log-line .log-msg { white-space: pre-wrap; word-break: break-word; }
.log-empty { color: var(--muted); }

/* ===== Batch ===== */
.batch-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.batch-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.batch-table th, .batch-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.batch-table thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: transparent;
  font-weight: 500;
  padding: 8px 8px;
}
.batch-table th.batch-col-actions { width: 36px; }
.batch-table th.batch-col-num { width: 28px; text-align: center; }
.batch-table td.batch-col-num {
  text-align: center;
  font-family: var(--mono);
  color: var(--muted);
  padding-top: 12px;
  font-size: 12px;
}
.batch-table input { font-size: 12.5px; padding: 6px 8px; }
.batch-table input.is-invalid { border-color: var(--err); }
.batch-row.is-empty { opacity: 0.5; }
.batch-row td.batch-col-actions { text-align: right; padding-top: 8px; }
.batch-remove {
  background: transparent;
  border: 1px solid transparent;
  width: 26px; height: 26px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}
.batch-remove:hover { background: var(--surface-2); color: var(--err); }
.batch-preview {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}
.batch-preview.is-warn { color: var(--warn); }

.batch-meta {
  margin-top: 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.csv-paste-area textarea { font-family: var(--mono); font-size: 12.5px; min-height: 100px; }

details.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface);
}
details.disclosure summary {
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13px;
  list-style: none;
}
details.disclosure summary::-webkit-details-marker { display: none; }
details.disclosure summary::before {
  content: "+";
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
  font-family: var(--mono);
  width: 10px;
}
details.disclosure[open] summary::before { content: "−"; }
details.disclosure .disclosure-body { margin-top: 10px; }

.csv-template {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.csv-template pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre;
  overflow-x: auto;
  color: var(--ink);
}

/* ===== Utility ===== */
.stack { display: grid; gap: 12px; }
.stack-lg { display: grid; gap: 18px; }
.flex-grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); border: 0; margin: 14px 0; }

.icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -2px;
}

@media (max-width: 920px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .topnav { justify-content: flex-start; }
  .topnav-actions { margin-left: 0; }
  .shell { padding: 14px; }
}

@media (max-width: 700px) {
  table thead { display: none; }
  table tbody td { display: block; padding: 6px 14px; border: none; }
  table tbody tr {
    display: block;
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  table tbody td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
  }
}
