@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --background: #f7f7f7;
  --foreground: #111111;
  --card: #ffffff;
  --muted: #f2f3f4;
  --muted-foreground: #737373;
  --border: #e5e5e5;
  --input: #e5e5e5;
  --primary: #8dff8a;
  --header: #111111;
  --header-foreground: #ffffff;
  --success: #20a965;
  --success-bg: #eefbf4;
  --warning: #a66d00;
  --warning-bg: #fff7df;
  --danger: #cc1f1a;
  --danger-bg: #fff1f0;
  --radius: 8px;
  --max-width: 1400px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--background); }

body {
  min-height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 14px/1.45 Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
h1, h2, h3, p { margin: 0; }
h2 { margin-top: 3px; font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 15px; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
p, .muted { color: var(--muted-foreground); }

.app-header {
  background: var(--header);
  color: var(--header-foreground);
  border-bottom: 1px solid rgba(255,255,255,.10);
}

.app-header-inner {
  max-width: var(--max-width);
  height: 56px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-logo {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  color: #fff;
  text-decoration: none;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.app-logo span { color: var(--primary); }
.app-logo em { margin-left: 6px; color: rgba(255,255,255,.55); font-size: 13px; font-style: italic; font-weight: 500; }
.app-header-spacer { flex: 1; }

.admin-console-chip {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  color: rgba(255,255,255,.55);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.tabs-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
}

.tabs a,
.tabs button {
  height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  text-decoration: none;
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}

.tabs a:hover,
.tabs button:hover { color: var(--foreground); background: rgba(0,0,0,.025); }
.tabs a.active { color: var(--foreground); border-bottom-color: var(--primary); }
.tabs span, .tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
}
.tabs form { margin-left: auto; }

.actions {
  max-width: var(--max-width);
  margin: 20px auto 12px;
  padding: 0 24px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.schedule-actions { margin-bottom: 12px; }

.schedule-shell {
  max-width: calc(var(--max-width) - 48px);
  margin: 0 auto 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.schedule-table-wrap { overflow-x: auto; }
.schedule-table { width: 100%; min-width: 920px; border-collapse: collapse; table-layout: fixed; }
.schedule-table thead th {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  color: var(--muted-foreground);
  font-size: 10px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.schedule-table thead th:nth-child(1) { width: 39%; }
.schedule-table thead th:nth-child(2) { width: 17%; }
.schedule-table thead th:nth-child(3) { width: 25%; }
.schedule-table thead th:nth-child(4) { width: 9%; text-align: center; }
.schedule-table thead th:nth-child(5) { width: 10%; }
.schedule-section th {
  padding: 15px 14px 9px;
  border-bottom: 1px solid var(--border);
  background: var(--muted);
  text-align: left;
}
.schedule-section span { font-size: 15px; font-weight: 800; }
.schedule-section small { margin-left: 9px; color: var(--muted-foreground); font-size: 11px; font-weight: 600; }
.schedule-task td {
  height: 66px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.schedule-task:last-child td { border-bottom-color: transparent; }
.schedule-task.enabled { background: #fcfffc; }
.schedule-task-name strong { display: block; font-size: 13px; font-weight: 750; }
.schedule-task-name small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: 11px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.schedule-control {
  display: flex;
  align-items: center;
  gap: 7px;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}
.schedule-control span { color: var(--muted-foreground); font-size: 11px; }
.schedule-control input { width: 82px; min-height: 32px; padding: 5px 8px; font-size: 12px; }
.schedule-control input[type="time"] { width: 104px; }
.schedule-command { white-space: nowrap; }
.schedule-command code {
  display: inline-block;
  max-width: calc(100% - 22px);
  overflow: hidden;
  color: #555;
  font: 11px/1.35 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.status-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-left: 7px;
  border-radius: 50%;
  vertical-align: middle;
}
.status-dot.ready { background: var(--success); }
.status-dot.pending { background: var(--warning); }
.schedule-toggle { text-align: center; }
.schedule-toggle .switch { display: inline-grid; }
.schedule-run { text-align: right; }
button.run-once.compact { min-height: 32px; padding: 0 10px; font-size: 11px; white-space: nowrap; }
.schedule-console td { padding: 0 14px 14px; border-bottom: 1px solid var(--border); background: #fcfcfc; }
.schedule-console .live-console { margin: 14px 0 0; }
.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;
}

.flash {
  max-width: calc(var(--max-width) - 48px);
  margin: 18px auto 0;
  padding: 11px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.flash.ok { background: var(--success-bg); color: var(--success); border: 1px solid #beeccd; }
.flash.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #ffd0cc; }

.primary,
.secondary {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 6px;
  padding: 0 13px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, filter .15s;
}

.primary { border: 0; background: var(--primary); color: #0a0a0a; }
.primary:hover { filter: brightness(.96); }
.secondary { border: 1px solid var(--border); background: var(--card); color: var(--foreground); }
.secondary:hover { background: var(--muted); }
.secondary.strong { min-height: 36px; border-color: var(--border); box-shadow: none; }
.secondary.strong:hover { background: var(--foreground); border-color: var(--foreground); color: #fff; }

.carrier {
  max-width: calc(var(--max-width) - 48px);
  margin: 16px auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.carrier.inactive { opacity: .62; }

.carrier header,
.platform-summary {
  min-height: 88px;
  padding: 22px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--border);
}

.platform-summary { cursor: pointer; list-style: none; }
.platform-summary::-webkit-details-marker { display: none; }
.platform-summary::marker { content: ""; }
.platform-card[open] .platform-summary { border-bottom: 1px solid var(--border); }
.summary-actions { display: flex; align-items: center; gap: 12px; }

.chevron {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--muted-foreground);
  font-size: 14px;
  transition: .15s;
}
.platform-card[open] .chevron { transform: rotate(180deg); }

.platform {
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.pill {
  border: 1px solid var(--foreground);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 800;
}

.steps { padding: 22px 28px; }
.step { display: grid; grid-template-columns: 30px 1fr; gap: 16px; margin-bottom: 18px; }
.step:last-child { margin-bottom: 0; }
.num {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--success-bg);
  color: var(--success);
  font-size: 13px;
  font-weight: 800;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--card);
}

.task-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.task-grid,
.diagnostic-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(170px, 250px) 1fr minmax(150px, 190px);
  gap: 14px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--foreground);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--input);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--card);
  color: var(--foreground);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(141,255,138,.24);
}

textarea { resize: vertical; min-height: 118px; }
.run-cell { display: grid; gap: 6px; justify-items: start; align-self: end; }

button.run-once {
  appearance: none;
  min-height: 36px;
  border: 1px solid var(--foreground);
  border-radius: 6px;
  padding: 0 13px;
  background: var(--foreground);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

button.run-once:hover { background: var(--primary); border-color: var(--primary); color: #050505; }
.run-note { display: block; max-width: 180px; color: var(--muted-foreground); font-size: 11px; line-height: 1.25; }

.switch input { display: none; }
.switch span {
  display: block;
  width: 48px;
  height: 26px;
  padding: 3px;
  border-radius: 999px;
  background: #e8e8e8;
  transition: .15s;
}
.switch span::before {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  transition: .15s;
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(22px); }

.tag { background: var(--muted); color: #555; margin-left: 0; }
.tag.ok,
.tag.success { background: var(--success-bg); color: var(--success); }
.tag.warn,
.tag.skipped { background: var(--warning-bg); color: var(--warning); }
.tag.failed,
.alert-error { background: var(--danger-bg); color: var(--danger); }
.tag.launched,
.tag.command,
.tag.manual { background: var(--muted); color: var(--muted-foreground); }

.log-list { padding: 14px 28px 28px; }
.log-row {
  display: grid;
  grid-template-columns: 86px 220px 1fr 170px;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.log-row small { grid-column: 2 / -1; color: var(--muted-foreground); font-size: 12px; }

.webhook-table-wrap { padding: 16px 28px 8px; overflow-x: auto; }
.webhook-table { width: 100%; border-collapse: collapse; min-width: 940px; font-size: 13px; }
.webhook-table th {
  padding: 10px 12px;
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,.018);
}
.webhook-table td { padding: 12px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.webhook-table tr.inactive { opacity: .55; }
.webhook-table small { display: block; margin-top: 3px; color: var(--muted-foreground); font-size: 11px; }
.webhook-table .error-text { max-width: 340px; color: var(--danger); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.webhook-table .mono { font: 12px/1.35 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #555; }
.webhook-table .empty { color: var(--muted-foreground); text-align: center; }
.switch.compact span { width: 44px; height: 24px; }
.switch.compact span::before { width: 18px; height: 18px; }
.switch.compact input:checked + span::before { transform: translateX(20px); }
.compact-action { min-width: 76px; min-height: 34px; }

.audit-result {
  margin: 18px 28px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}

.audit-result header {
  min-height: 76px;
  margin: 0;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.audit-result code {
  font: 12px/1.35 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #444;
}

.audit-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.audit-table-wrap { max-height: 720px; overflow: auto; }
.audit-table { width: 100%; min-width: 1200px; border-collapse: collapse; font-size: 12px; }
.audit-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  color: var(--muted-foreground);
  font-size: 10px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.audit-table td {
  max-width: 280px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.audit-table strong { display: block; font-weight: 800; }
.audit-table small { display: block; margin-top: 3px; color: var(--muted-foreground); line-height: 1.35; }
.audit-table .empty { color: var(--muted-foreground); text-align: center; }
.audit-response-button {
  width: max-content;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--foreground);
  padding: 0 11px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}
.audit-response-button:hover,
.audit-response-button:focus {
  background: var(--foreground);
  border-color: var(--foreground);
  color: #fff;
}
.audit-response pre {
  width: min(720px, 70vw);
  max-height: 420px;
  margin: 10px 0 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fbfbfb;
  color: #222;
  white-space: pre;
  font: 11px/1.45 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.console-link { margin-left: 8px; color: var(--foreground); font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.live-console { margin: 0 28px 28px; border: 1px solid #242424; border-radius: var(--radius); overflow: hidden; background: #111; color: #f4f4f4; }
.live-console.task-console { margin: 16px 0 0; }
.console-head { display: flex; justify-content: space-between; gap: 16px; padding: 12px 14px; background: #1d1d1d; border-bottom: 1px solid #333; }
.console-head span { color: #aaa; }
#live-console-output { min-height: 280px; max-height: 560px; margin: 0; overflow: auto; padding: 14px; white-space: pre-wrap; font: 12px/1.5 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.task-console #live-console-output { min-height: 180px; max-height: 360px; }

.result {
  margin: 18px 28px 28px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfbfb;
  font: 12px/1.5 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.diagnostic-grid { padding: 22px 28px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
.diagnostic-grid .panel { display: grid; gap: 12px; align-content: start; }

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(380px, 100%);
  text-align: center;
}

.login-brand {
  color: var(--foreground);
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.login-brand span { color: var(--primary); }
.login-card > p { margin-top: 8px; font-size: 12px; }
.login form {
  margin-top: 22px;
  display: grid;
  gap: 14px;
  padding: 20px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.login .primary { width: 100%; }
.alert { padding: 10px 12px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.alert-error { border: 1px solid #ffd0cc; }

@media (max-width: 850px) {
  .app-header-inner,
  .tabs-inner,
  .actions { padding-left: 16px; padding-right: 16px; }
  .admin-console-chip { display: none; }
  .task-grid,
  .diagnostic-grid,
  .log-row { grid-template-columns: 1fr; }
  .carrier,
  .schedule-shell { max-width: calc(100vw - 32px); margin-left: 16px; margin-right: 16px; }
  .carrier header,
  .actions,
  .platform-summary { align-items: flex-start; flex-direction: column; }
  .summary-actions { width: 100%; justify-content: space-between; }
  .steps,
  .carrier header,
  .platform-summary,
  .diagnostic-grid,
  .log-list,
  .webhook-table-wrap { padding-left: 18px; padding-right: 18px; }
  .webhook-table { min-width: 0; }
  .audit-result { margin-left: 18px; margin-right: 18px; }
  .audit-table { min-width: 0; }
  .audit-table thead { display: none; }
  .audit-table,
  .audit-table tbody,
  .audit-table tr,
  .audit-table td { display: block; width: 100%; }
  .audit-table tr { padding: 12px 0; border-bottom: 1px solid var(--border); }
  .audit-table td { display: grid; grid-template-columns: 110px 1fr; gap: 12px; max-width: none; padding: 8px 14px; border-bottom: 0; }
  .audit-table td::before {
    content: attr(data-label);
    color: var(--muted-foreground);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
  }
  .webhook-table thead { display: none; }
  .webhook-table,
  .webhook-table tbody,
  .webhook-table tr,
  .webhook-table td { display: block; width: 100%; }
  .webhook-table tr { padding: 12px 0; border-bottom: 1px solid var(--border); }
  .webhook-table td { display: grid; grid-template-columns: 100px 1fr; gap: 12px; padding: 8px 0; border-bottom: 0; }
  .webhook-table td::before {
    content: attr(data-label);
    color: var(--muted-foreground);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
  }
  .webhook-table .error-text { max-width: none; white-space: normal; }
}
