/* SMM Live: light SMM-panel theme. Colors are roles; platform tints mark categories. */
:root {
  color-scheme: light;
  --bg: #f2f4f8; --surface: #ffffff; --surface-2: #f7f8fb;
  --sidebar: #131c31; --sidebar-text: #c3cbdb; --sidebar-hover: #1f2a44;
  --text: #18202f; --muted: #5b6577; --border: #dfe3eb; --input-border: #8a94a6;
  --primary: #2554d8; --primary-hover: #1c43b3; --primary-soft: #e9effd;
  --success: #12784b; --success-soft: #e5f4ec;
  --warning: #8f5300; --warning-soft: #fdf2e0;
  --danger: #b4233a; --danger-soft: #fbe9ec;
  --neutral: #4b5565; --neutral-soft: #eef0f4;
  --twitch: #6a3dcc; --twitch-soft: #f0eafd;
  --kick: #2a7420; --kick-soft: #e7f5e2;
  --focus: #2554d8;
  --radius: 10px; --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(19, 28, 49, .06);
  --worker-space-sm: 0.5rem;
  --worker-space: 1rem;
  --worker-gap: 1.25rem;
  --worker-body-size: 1.066667rem;
  --worker-name-width: 14rem;
  --worker-target-size: 2.133333rem;
  --worker-label-size: 0.8rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; }
h2 { font-size: 17px; line-height: 1.35; margin-bottom: 16px; }
h3 { font-size: 15px; margin-bottom: 8px; }
p { margin-bottom: 12px; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 13px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; }
.skip:focus { left: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted, .help { color: var(--muted); }
.help { font-size: 13px; margin: 6px 0 0; }
.sub { display: block; color: var(--muted); font-size: 13px; }
.nowrap { white-space: nowrap; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* Controls */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
button:hover, .button:hover { background: var(--surface-2); color: var(--text); }
.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-hover); color: #fff; }
.secondary { border-color: var(--input-border); }
.danger { color: var(--danger); border-color: #e6b7bf; }
.danger:hover { background: var(--danger-soft); color: var(--danger); }
.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.full { width: 100%; margin-top: 8px; }
.link-button { min-height: 36px; padding: 6px 0; border: 0; background: none; color: inherit; font-weight: 500; }
button:disabled { opacity: .6; cursor: wait; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
form > label:not(:first-of-type), fieldset > label:not(:first-of-type) { margin-top: 16px; }
input, select, textarea { display: block; width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; }
textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
input::placeholder, textarea::placeholder { color: #737d8f; }
input[aria-invalid="true"] { border-color: var(--danger); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset:disabled { opacity: .6; }
form > button, fieldset > button { margin-top: 20px; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; min-height: 18px; height: 18px; margin: 0; accent-color: var(--primary); }

/* Layout */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 20px; padding: 20px 14px; background: var(--sidebar); color: var(--sidebar-text); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; padding: 0 6px; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--sidebar-text); }
.brand:hover { color: #fff; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(135deg, var(--twitch) 0 50%, var(--kick) 50% 100%); color: #fff; font-weight: 800; }
.new-order-link { display: block; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--primary); color: #fff; font-weight: 600; text-align: center; text-decoration: none; }
.new-order-link:hover, .new-order-link[aria-current] { background: var(--primary-hover); color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { padding: 10px 12px; border-radius: var(--radius-sm); color: var(--sidebar-text); text-decoration: none; font-weight: 500; }
.sidebar nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar nav a[aria-current] { background: var(--sidebar-hover); color: #fff; box-shadow: inset 3px 0 0 #7ea2ff; }
.logout { margin-top: auto; padding: 0 12px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 28px; background: var(--surface); border-bottom: 1px solid var(--border); }
.content { padding: 24px 28px 32px; max-width: 1360px; }
.api-status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--neutral-soft); color: var(--neutral); font-size: 13px; font-weight: 600; text-decoration: none; }
.api-status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.api-status.on { background: var(--success-soft); color: var(--success); }
.footnote, .refresh { color: var(--muted); font-size: 12px; margin: 16px 0 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card, .side-stack > * + * { margin-top: 16px; }
.split > *, .order-layout > *, .settings-grid > * { margin-top: 0; }
.card h3 { margin-top: 20px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.table-card { padding: 0; overflow: hidden; }
.table-card > .card-head { padding: 16px 20px; margin: 0; border-bottom: 1px solid var(--border); }
.card-note { padding: 12px 20px 0; margin: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.order-layout { display: grid; grid-template-columns: minmax(0, 640px) minmax(260px, 1fr); gap: 20px; align-items: start; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.sticky { position: sticky; top: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 8px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }

/* Feedback */
.alert { padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius-sm); border: 1px solid; }
.alert.error { background: var(--danger-soft); border-color: #efc2ca; color: #7d1527; }
.alert.success { background: var(--success-soft); border-color: #b6dfc8; color: #0c5434; }
.alert.warning { background: var(--warning-soft); border-color: #f0d3a4; color: #6b3e00; }
.field-error, .row-error { color: var(--danger); font-size: 13px; font-weight: 600; margin: 6px 0 0; }
.row-error { display: block; font-weight: 500; }
.empty { padding: 40px 20px; text-align: center; }
.empty h2, .empty h3 { margin-bottom: 6px; }
.empty p { color: var(--muted); }
.empty.compact { padding: 20px; }
.empty.compact p { margin: 0; }

/* Status pills and platform tags */
.status, .tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--neutral-soft); color: var(--neutral); }
.status.running { background: var(--primary-soft); color: var(--primary); }
.status.completed { background: var(--success-soft); color: var(--success); }
.status.failed { background: var(--danger-soft); color: var(--danger); }
.status.queued, .status.recovery_pending { background: var(--warning-soft); color: var(--warning); }
.tag.twitch_live { background: var(--twitch-soft); color: var(--twitch); }
.tag.kick_live { background: var(--kick-soft); color: var(--kick); }
.channel { font-weight: 600; padding-left: 10px; border-left: 3px solid var(--neutral); }
.channel.twitch_live { border-color: var(--twitch); }
.channel.kick_live { border-color: var(--kick); }

/* Orders */
.toolbar { display: flex; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search { display: flex; gap: 8px; align-items: center; flex: 1 1 520px; max-width: 680px; }
.search button { margin-top: 0; }
.search input { flex: 1 1 auto; }
.search select { flex: 0 0 170px; }
.tabs { display: flex; gap: 4px; overflow: auto hidden; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { display: inline-flex; gap: 6px; align-items: center; padding: 10px 14px; color: var(--muted); font-weight: 600; text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current] { color: var(--primary); box-shadow: inset 0 -3px 0 var(--primary); }
.tabs .count { min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--neutral-soft); color: var(--neutral); font-size: 12px; text-align: center; }
.tabs a[aria-current] .count { background: var(--primary-soft); color: var(--primary); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
thead th { background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfd; }
th.numeric { text-align: right; }
td.actions { text-align: right; white-space: nowrap; }
div.actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
td.actions form + form, td.actions .button + form { margin-left: 8px; }
.orders-table td:nth-child(4) { min-width: 190px; }
.actions form { margin: 0; }
.progress { display: flex; align-items: center; gap: 8px; min-width: 140px; }
progress { flex: 1; height: 8px; appearance: none; border: 0; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--neutral-soft); }
progress::-webkit-progress-value { background: var(--primary); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--primary); border-radius: 999px; }
.progress span { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pagination { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.category-row th { background: var(--surface-2); font-size: 13px; color: var(--text); border-left: 4px solid var(--neutral); }
.category-row.twitch_live th { border-left-color: var(--twitch); }
.category-row.kick_live th { border-left-color: var(--kick); }
tr.selected td { background: var(--primary-soft); }
.row-list li.selected { background: var(--primary-soft); }
.row-list .actions form > button { margin-top: 0; } /* row buttons line up with the edit link and status */
.help.lead { margin: 0 0 16px; }

/* New order */
.service-detail { margin-top: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px dashed var(--border); font-size: 14px; color: var(--muted); }
.service-detail strong { color: var(--text); }
.checklist, .steps { margin: 0; padding: 0; }
.checklist { list-style: none; display: grid; gap: 10px; }
.checklist li { display: flex; gap: 10px; align-items: center; }
.checklist .mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 13px; font-weight: 800; }
.checklist .ok .mark { background: var(--success-soft); color: var(--success); }
.checklist .bad .mark { background: var(--warning-soft); color: var(--warning); }
.steps { padding-left: 20px; display: grid; gap: 8px; }

/* Lists */
.row-list { list-style: none; margin: 0; padding: 0; }
.row-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.row-list li:last-child { border-bottom: 0; }
.small-check { margin: 0; font-size: 13px; }

/* Workers */
.worker-list {
  margin-bottom: var(--worker-gap);
}
.workers-table,
.worker-identity,
.worker-detail-grid {
  font-size: var(--worker-body-size);
}
.workers-table .worker-name {
  max-width: var(--worker-name-width);
  overflow-wrap: anywhere;
}
.workers-table .worker-name a {
  display: inline-flex;
  align-items: center;
  min-height: var(--worker-target-size);
}
.workers-table td {
  vertical-align: middle;
}
.workers-table .sub strong {
  color: var(--text);
}
.worker-sections {
  display: flex;
  flex-wrap: wrap;
  gap: var(--worker-space-sm) var(--worker-space);
  margin-bottom: var(--worker-gap);
}
.worker-sections a {
  display: inline-flex;
  align-items: center;
  min-height: var(--worker-target-size);
}
.toolbar.worker-detail-toolbar .button {
  display: inline-flex;
}
.worker-detail-grid .help a,
.worker-orders-table a {
  display: inline-flex;
  align-items: center;
  min-height: var(--worker-target-size);
}
.worker-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--worker-gap);
  margin-top: var(--worker-gap);
}
.worker-detail-grid > .card {
  min-width: 0;
  margin: 0;
}
.worker-wide {
  grid-column: 1 / -1;
}
.worker-facts {
  margin-bottom: 0;
}
.worker-facts dd {
  overflow-wrap: anywhere;
}
.worker-identity h2 {
  overflow-wrap: anywhere;
}
.metrics.worker-resource-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-top: 0;
  border-top: 0;
  gap: var(--worker-space);
}
.worker-detail-grid .capacity {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.worker-detail-grid .worker-settings {
  margin: 0;
  padding: 0;
  border: 0;
}
.worker-detail-grid .worker-settings summary {
  min-height: var(--worker-target-size);
  display: list-item;
}
.worker-detail-grid section,
.worker-settings {
  scroll-margin-top: var(--worker-gap);
}
.worker-orders-table td {
  overflow-wrap: anywhere;
}
.quota meter {
  height: 6px;
}
.limits-table caption { caption-side: bottom; text-align: left; }
.usage { margin-top: 4px; border-top: 1px solid var(--border); font-size: 13px; }
.usage th, .usage td { padding: 6px 4px; border: 0; background: none; }
.usage thead th { background: none; padding-top: 10px; }
.usage tbody tr:hover td { background: none; }
.usage .total th, .usage .total td { font-weight: 700; border-top: 1px solid var(--border); }
.quota { display: grid; gap: 6px; padding: 10px 0 0; font-size: 14px; }
.quota > div { display: flex; justify-content: space-between; gap: 8px; }
.quota meter { width: 100%; }
.quota.over strong { color: var(--danger); }
.quota-none { margin: 8px 0 0; }
.capacity { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.capacity h4 { margin: 0; font-size: 14px; }
.capacity-table { margin-top: 8px; font-size: 13px; }
.capacity-table th, .capacity-table td { padding: 7px 4px; }
.capacity-table thead th { white-space: normal; }
.capacity-table .sub { font-size: 12px; }
.capacity-details summary { min-height: 44px; padding: 10px 0; cursor: pointer; color: var(--primary); font-weight: 600; }
.capacity-point { padding: 12px 0; border-top: 1px solid var(--border); }
.capacity-point h3 { margin: 0 0 8px; font-size: 13px; }
.capacity-point p { margin-bottom: 8px; }
.capacity-point dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; font-size: 13px; }
.capacity-point dt { color: var(--muted); font-size: 12px; }
.capacity-point dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.worker-settings { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.worker-settings summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.worker-settings[open] summary { margin-bottom: 8px; }
.worker-settings .form-grid { margin-top: 8px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--border); }
.metrics dt { color: var(--muted); font-size: 12px; }
.metrics dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.metrics .sub { font-size: 12px; }
.history { margin-bottom: 20px; }
.history summary { cursor: pointer; font-weight: 700; min-height: var(--worker-target-size); }
.history[open] summary { margin-bottom: 12px; }

/* Settings */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 16px; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; font-weight: 600; }
.limits-table { table-layout: fixed; }
.limits-table th:first-child { width: 84px; }
.limits-table th, .limits-table td { padding: 8px; border: 0; background: none; vertical-align: middle; white-space: normal; }
.limits-table thead th { font-size: 13px; }
.limits-table .sub { display: inline; font-weight: 400; }

/* Login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: var(--sidebar); }
.login-card { width: min(400px, 100%); padding: 32px; border-radius: 14px; background: var(--surface); }
.login-brand { color: var(--text); padding: 0; margin-bottom: 24px; }
.login-brand small { color: var(--muted); }
.login-card h1 { margin-bottom: 6px; }
.login-card form { margin-top: 20px; }

@media (max-width: 1100px) {
  .split, .order-layout, .settings-grid, .worker-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; }
  .brand small { display: none; }
  .new-order-link { margin-left: auto; }
  .sidebar nav { flex-direction: row; overflow-x: auto; width: 100%; order: 3; }
  .sidebar nav a { white-space: nowrap; }
  .logout { display: none; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .search { flex-wrap: wrap; }
  .search select, .search button { flex: 1 1 140px; }
  .toolbar .button { display: none; }
  .form-grid, .facts { grid-template-columns: 1fr; }
  .orders-table thead, .services-table thead { display: none; }
  .orders-table, .services-table, .orders-table tbody, .services-table tbody { display: block; }
  .orders-table tr, .services-table tr:not(.category-row) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .services-table .category-row { display: block; }
  .services-table .category-row th { display: block; }
  .orders-table td:nth-child(4), .progress { min-width: 0; }
  .orders-table td, .services-table td { padding: 0; border: 0; }
  .orders-table td::before, .services-table td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
  .orders-table td.numeric, .services-table td.numeric { text-align: left; }
  td.actions { grid-column: 1 / -1; text-align: left; }
  td.actions::before { display: none !important; }
  div.actions { justify-content: flex-start; }
  .row-list li { grid-template-columns: 1fr auto; }
  .row-list .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .workers-table thead,
  .worker-orders-table thead,
  .worker-load-table thead {
    display: none;
  }
  .workers-table,
  .workers-table tbody,
  .worker-orders-table,
  .worker-orders-table tbody,
  .worker-load-table,
  .worker-load-table tbody {
    display: block;
  }
  .workers-table tr,
  .worker-orders-table tr,
  .worker-load-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--worker-space-sm) var(--worker-space);
    padding: var(--worker-space);
    border-bottom: 1px solid var(--border);
  }
  .workers-table td,
  .worker-orders-table td,
  .worker-load-table td,
  .worker-load-table th {
    padding: 0;
    border: 0;
    white-space: normal;
  }
  .workers-table .worker-name {
    max-width: none;
  }
  .workers-table td[data-label]::before,
  .worker-orders-table td[data-label]::before,
  .worker-load-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: var(--worker-label-size);
    font-weight: 600;
  }
  .workers-table td.numeric,
  .worker-orders-table td.numeric,
  .worker-load-table td.numeric {
    text-align: left;
  }
  .worker-load-table th {
    grid-column: 1 / -1;
  }
  .worker-identity .card-head,
  .worker-list .section-head {
    flex-wrap: wrap;
  }
  .worker-facts code {
    word-break: break-all;
  }
}
