:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #10151d;
  --panel-2: #151c26;
  --panel-3: #0c1118;
  --line: #263140;
  --line-soft: #1c2531;
  --text: #f4f7fb;
  --muted: #93a1b2;
  --muted-2: #6f7c8d;
  --green: #54d69a;
  --green-soft: rgba(84, 214, 154, .12);
  --amber: #f6b73c;
  --amber-soft: rgba(246, 183, 60, .12);
  --blue: #63a7ff;
  --violet: #aa88ff;
  --red: #ff6b78;
  --red-soft: rgba(255, 107, 120, .12);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -10%, rgba(65, 105, 155, .16), transparent 32rem),
    radial-gradient(circle at 90% 5%, rgba(246, 183, 60, .07), transparent 28rem),
    var(--bg);
  font-size: 16px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { color: inherit; }

.topbar {
  height: 72px;
  padding: 0 clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(8, 11, 16, .85);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid #3b495b;
  border-radius: 11px;
  background: linear-gradient(145deg, #202b39, #111721);
  color: var(--amber);
  font-weight: 800;
  letter-spacing: -.04em;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; line-height: 1.15; }
.brand small { color: var(--muted-2); font-size: 12px; margin-top: 3px; }

.topnav { display: flex; align-items: center; gap: 22px; color: var(--muted); font-size: 14px; }
.topnav a:hover, .link-button:hover { color: var(--text); }
.topnav form { margin: 0; }
.user-label { padding-left: 22px; border-left: 1px solid var(--line); }
.link-button { border: 0; padding: 0; background: transparent; cursor: pointer; color: var(--muted); }

.page-shell { width: min(1380px, calc(100% - 36px)); margin: 0 auto; padding: 38px 0 64px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 28px; }
.page-heading.compact { align-items: center; margin-top: 24px; }
.page-heading h1 { font-size: clamp(30px, 4vw, 48px); line-height: 1.05; letter-spacing: -.045em; margin: 7px 0 10px; }
.page-heading.compact h1 { font-size: clamp(28px, 3vw, 38px); }
.page-heading h1 span { color: var(--muted-2); font-weight: 500; }
.page-heading p { margin: 0; color: var(--muted); max-width: 720px; }
.eyebrow { color: var(--amber); font-size: 12px; font-weight: 800; letter-spacing: .16em; }

.global-actions, .bot-actions { display: flex; align-items: center; gap: 10px; }
.global-actions form, .bot-actions form { margin: 0; }

.button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 15px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color .16s ease, transform .16s ease, background .16s ease;
}
.button:hover { border-color: #46566b; transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .5; cursor: wait; transform: none; }
.button-primary { background: #eef4fb; border-color: #eef4fb; color: #0b1119; }
.button-primary:hover { background: #fff; border-color: #fff; }
.button-quiet { background: #171e28; }
.button-danger-quiet { background: var(--red-soft); border-color: rgba(255, 107, 120, .28); color: #ff9aa3; }
.button-wide { width: 100%; }
.button-small { min-height: 34px; padding: 6px 11px; font-size: 13px; }

.priority-note {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 17px;
  margin-bottom: 22px;
  border: 1px solid rgba(246, 183, 60, .2);
  border-radius: 12px;
  color: #d7dde6;
  background: linear-gradient(90deg, rgba(246, 183, 60, .08), rgba(246, 183, 60, .025));
  font-size: 14px;
}
.priority-note span { color: var(--muted); }
.priority-icon { flex: 0 0 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; background: var(--amber); color: #141008 !important; font-weight: 900; }

.bot-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.bot-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(155deg, rgba(24, 32, 43, .96), rgba(13, 18, 25, .98));
  box-shadow: 0 18px 55px rgba(0, 0, 0, .22);
}
.card-accent { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--amber); opacity: .9; }
.accent-blue .card-accent { background: var(--blue); }
.accent-violet .card-accent { background: var(--violet); }
.bot-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.version-line { color: var(--muted-2); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.bot-card h2 { margin: 7px 0 0; font-size: 24px; letter-spacing: -.025em; }
.bot-description { color: var(--muted); min-height: 48px; margin: 17px 0 21px; font-size: 14px; }

.status-pill { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; border: 1px solid var(--line); padding: 7px 10px; border-radius: 999px; font-size: 12px; background: #111821; }
.status-pill > span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); box-shadow: 0 0 0 4px rgba(111, 124, 141, .1); }
.status-running { border-color: rgba(84, 214, 154, .24); color: #91ebbf; background: var(--green-soft); }
.status-running > span { background: var(--green); box-shadow: 0 0 0 4px rgba(84, 214, 154, .1); }
.status-stopped { color: #a7b0bd; }
.status-unknown { color: #ffc978; border-color: rgba(246, 183, 60, .22); }
.status-unknown > span { background: var(--amber); }

.bot-facts { display: grid; grid-template-columns: repeat(3, 1fr); padding: 15px 0; margin: 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.bot-facts div { min-width: 0; padding: 0 10px; border-right: 1px solid var(--line-soft); }
.bot-facts div:first-child { padding-left: 0; }
.bot-facts div:last-child { border: 0; }
.bot-facts dt { color: var(--muted-2); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.bot-facts dd { margin: 5px 0 0; overflow: hidden; text-overflow: ellipsis; color: #d9e0e9; font-size: 13px; font-weight: 700; }

.config-line { display: flex; align-items: center; gap: 8px; margin: 16px 0; font-size: 13px; }
.config-line > span { width: 21px; height: 21px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; font-weight: 900; }
.config-ok { color: #86e9b5; }
.config-ok > span, .config-summary.config-ok { background: var(--green-soft); }
.config-missing { color: #ffca78; }
.config-missing > span, .config-summary.config-missing { background: var(--amber-soft); }

.secondary-actions { display: flex; gap: 8px; margin-top: 18px; }
.secondary-actions a { flex: 1; text-align: center; padding: 9px 5px; border: 1px solid var(--line-soft); border-radius: 9px; color: var(--muted); font-size: 13px; font-weight: 700; }
.secondary-actions a:hover { color: var(--text); border-color: #435166; background: rgba(255,255,255,.025); }
.autostart-form { margin: 13px 0 0; text-align: center; }
.autostart-button { border: 0; padding: 4px; background: transparent; color: var(--muted-2); font-size: 12px; cursor: pointer; }
.autostart-button:hover { color: var(--muted); }
.service-error { margin-top: 12px; color: #ff9ba4; font-size: 12px; overflow-wrap: anywhere; }

.flash-stack { position: fixed; z-index: 50; top: 86px; right: 24px; width: min(440px, calc(100% - 36px)); display: grid; gap: 8px; }
.flash { padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; background: #151c26; box-shadow: 0 16px 40px rgba(0,0,0,.35); font-size: 14px; }
.flash-success { border-color: rgba(84,214,154,.3); color: #a0eac4; }
.flash-error { border-color: rgba(255,107,120,.32); color: #ffabb2; }

.bot-nav { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line-soft); padding-bottom: 12px; overflow-x: auto; }
.bot-nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.bot-nav a:hover, .bot-nav a.active { color: var(--text); background: var(--panel-2); }

.notice { padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px; margin: -8px 0 20px; font-size: 14px; }
.notice-warning { border-color: rgba(246,183,60,.24); background: var(--amber-soft); color: #e5d3b0; }

.settings-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
.settings-side { position: sticky; top: 92px; display: grid; gap: 14px; }
.section-tabs { padding: 8px; border: 1px solid var(--line-soft); border-radius: 13px; background: var(--panel); display: grid; gap: 3px; }
.section-tab { border: 0; border-radius: 8px; background: transparent; color: var(--muted); padding: 10px 11px; text-align: left; cursor: pointer; font-size: 14px; }
.section-tab:hover, .section-tab.active { background: #1a222e; color: var(--text); }
.config-summary { padding: 13px; border: 1px solid currentColor; border-radius: 11px; font-size: 13px; }
.config-summary strong, .config-summary small { display: block; }
.config-summary small { color: var(--muted); margin-top: 5px; overflow-wrap: anywhere; }

.import-box { border: 1px solid var(--line-soft); background: var(--panel); border-radius: 13px; padding: 15px; }
.import-box strong { font-size: 14px; }
.import-box p { color: var(--muted); font-size: 12px; margin: 7px 0 13px; }
.file-picker { display: block; border: 1px dashed #39485b; border-radius: 9px; padding: 10px; margin-bottom: 9px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; }
.file-picker:hover { border-color: #60738b; color: var(--text); }
.file-picker input { display: block; max-width: 100%; margin-top: 7px; font-size: 11px; color: var(--muted-2); }

.settings-form { min-width: 0; }
.settings-section { border: 1px solid var(--line-soft); background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.settings-section.is-hidden { display: none; }
.settings-section-head { min-height: 64px; padding: 15px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); background: rgba(255,255,255,.015); }
.settings-section-head h2 { margin: 0; font-size: 19px; }
.settings-section-head span { color: var(--muted-2); font-size: 12px; }
.field-list { padding: 2px 20px; }
.field-row { display: grid; grid-template-columns: minmax(240px, .85fr) minmax(300px, 1.15fr); gap: 28px; padding: 18px 0; border-bottom: 1px solid var(--line-soft); }
.field-row:last-child { border-bottom: 0; }
.field-label { display: flex; align-items: center; gap: 8px; color: #e6ebf2; font-size: 14px; font-weight: 750; }
.field-row label > small { display: block; margin-top: 5px; max-width: 530px; color: var(--muted-2); font-size: 12px; line-height: 1.45; }
.required-mark { border: 1px solid rgba(246,183,60,.25); border-radius: 5px; padding: 2px 5px; color: #e8bc6b; font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
.field-control > input[type="text"], .field-control > input[type="password"], .field-control > input[type="number"], .field-control > input[type="url"] {
  width: 100%; min-height: 42px; border: 1px solid #303c4c; border-radius: 9px; background: #0c1118; padding: 9px 11px; color: var(--text); outline: none;
}
.field-control > input:focus { border-color: #6c829d; box-shadow: 0 0 0 3px rgba(99,167,255,.1); }
.field-control > input::placeholder { color: #596575; }
.field-row.has-error .field-control > input { border-color: var(--red); }
.field-error { margin-top: 5px; color: #ff969f; font-size: 12px; }
.secret-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 7px; color: var(--muted-2); font-size: 11px; }
.secret-meta label { cursor: pointer; }
.secret-state { padding: 3px 7px; border-radius: 6px; background: rgba(255,255,255,.04); }
.secret-state.configured { color: #7ee3ad; background: var(--green-soft); }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; min-height: 40px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span { width: 43px; height: 24px; border-radius: 999px; background: #293342; border: 1px solid #374457; position: relative; transition: .16s; }
.switch > span::after { content: ""; position: absolute; width: 18px; height: 18px; top: 2px; left: 3px; border-radius: 50%; background: #8e9aaa; transition: .16s; }
.switch input:checked + span { background: rgba(84,214,154,.24); border-color: rgba(84,214,154,.5); }
.switch input:checked + span::after { left: 20px; background: var(--green); }
.switch b { font-size: 13px; color: var(--muted); }

.save-bar { position: sticky; bottom: 14px; margin-top: 13px; padding: 12px 13px 12px 16px; border: 1px solid #344256; border-radius: 13px; background: rgba(18,24,33,.94); backdrop-filter: blur(15px); display: flex; align-items: center; justify-content: space-between; gap: 16px; box-shadow: 0 15px 45px rgba(0,0,0,.35); }
.save-bar span { color: var(--muted); font-size: 12px; }

.log-shell { border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; background: #090e15; }
.log-toolbar { min-height: 48px; padding: 8px 12px 8px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); color: var(--muted-2); font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
.log-output { min-height: 520px; max-height: calc(100vh - 260px); overflow: auto; margin: 0; padding: 18px; color: #b8c5d5; font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.auto-refresh { color: var(--muted); font-size: 13px; cursor: pointer; }

.instructions-card { border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--panel); padding: clamp(18px, 3vw, 34px); }
.instructions-card pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #c3ccd8; font: 14px/1.7 ui-sans-serif, system-ui, sans-serif; }

.login-shell { min-height: calc(100vh - 150px); display: grid; place-items: center; padding: 20px; }
.login-card { width: min(430px, 100%); border: 1px solid var(--line); border-radius: 20px; padding: clamp(26px, 5vw, 40px); background: linear-gradient(155deg, rgba(24,32,43,.98), rgba(12,17,24,.98)); box-shadow: 0 28px 90px rgba(0,0,0,.42); }
.login-card h1 { margin: 8px 0 8px; font-size: 32px; letter-spacing: -.04em; }
.login-card > p { margin: 0 0 24px; color: var(--muted); }
.login-form { display: grid; gap: 15px; }
.login-form label span { display: block; margin-bottom: 6px; color: #cbd3dd; font-size: 13px; font-weight: 700; }
.login-form input { width: 100%; min-height: 45px; border: 1px solid #303c4c; border-radius: 9px; padding: 9px 11px; background: #0b1017; color: var(--text); outline: none; }
.login-form input:focus { border-color: #6c829d; box-shadow: 0 0 0 3px rgba(99,167,255,.1); }
.login-note { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line-soft); color: var(--muted-2); font-size: 12px; }
.error-card { width: min(620px, 100%); margin: 12vh auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; background: var(--panel); }
.error-card h1 { margin: 8px 0; }
.error-card p { color: var(--muted); margin-bottom: 24px; }

@media (max-width: 1050px) {
  .bot-grid { grid-template-columns: 1fr; }
  .bot-description { min-height: auto; }
  .settings-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .field-row { grid-template-columns: 1fr; gap: 10px; }
}

@media (max-width: 760px) {
  .topbar { height: 64px; padding: 0 16px; }
  .brand small, .user-label { display: none; }
  .topnav { gap: 13px; }
  .page-shell { width: min(100% - 24px, 1380px); padding-top: 24px; }
  .page-heading, .page-heading.compact { align-items: flex-start; flex-direction: column; gap: 16px; }
  .global-actions { width: 100%; }
  .global-actions form { flex: 1; }
  .global-actions .button { width: 100%; }
  .settings-layout { display: block; }
  .settings-side { position: static; margin-bottom: 14px; }
  .section-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-section-head, .field-list { padding-left: 14px; padding-right: 14px; }
  .save-bar { align-items: stretch; flex-direction: column; }
  .save-bar .button { width: 100%; }
  .flash-stack { top: 72px; right: 12px; }
  .log-output { min-height: 430px; }
}

@media (max-width: 460px) {
  .bot-card { padding: 20px 17px; }
  .bot-card-head { flex-direction: column; }
  .bot-facts { grid-template-columns: 1fr; gap: 10px; }
  .bot-facts div { padding: 0; border: 0; }
  .secondary-actions { flex-wrap: wrap; }
  .secondary-actions a { flex: 1 0 45%; }
  .section-tabs { grid-template-columns: 1fr; }
  .secret-meta { align-items: flex-start; flex-direction: column; }
}

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

/* Report library */
.report-note { margin-bottom: 20px; padding: 18px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--muted); }
.report-note p { margin: 0 0 8px; }
.report-note a { color: var(--blue); }
.report-library { margin-top: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.report-library-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 18px 22px; }
.report-library-heading h2 { margin: 0; font-size: 20px; }
.report-table-wrap { overflow-x: auto; }
.report-table { border-collapse: collapse; width: 100%; text-align: left; font-size: 14px; }
.report-table th { color: var(--muted); font-weight: 500; background: var(--panel-3); }
.report-table th, .report-table td { padding: 15px 20px; border-top: 1px solid var(--line-soft); }
.report-table td:not(:first-child) { white-space: nowrap; }
.report-filename { overflow-wrap: anywhere; min-width: 190px; }
.report-empty { padding: 0 22px 24px; color: var(--muted); }
.report-pagination { display: flex; gap: 24px; padding: 18px 22px; justify-content: center; }
.report-pagination a { color: var(--blue); }
.muted { color: var(--muted); }
@media (max-width: 640px) {
  .report-library-heading { align-items: flex-start; flex-direction: column; }
  .report-table th, .report-table td { padding: 12px; }
}
