:root {
  color-scheme: light;
  --ink: #102c3a;
  --ink-soft: #315260;
  --muted: #71838a;
  --line: #d7e1df;
  --paper: #f3f5f2;
  --panel: #ffffff;
  --sidebar: #102c3a;
  --sidebar-soft: #254a58;
  --accent: #e79a45;
  --accent-deep: #b96725;
  --success: #2f806d;
  --danger: #bf5a51;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; color: var(--ink); background: var(--paper); font-size: 14px; line-height: 1.5; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 3px solid rgba(231, 154, 69, .55); outline-offset: 3px; }
[hidden] { display: none !important; }

.app-noise { position: fixed; inset: 0; pointer-events: none; opacity: .16; background-image: radial-gradient(#6f858a .7px, transparent .7px); background-size: 7px 7px; mix-blend-mode: multiply; }
.auth-layout { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 42%); }
.auth-panel { width: min(480px, 100%); align-self: center; justify-self: center; padding: 52px 36px; }
.auth-aside { position: relative; padding: 12vh 8vw 9vh; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; color: #edf2ef; background: var(--sidebar); }
.auth-aside::before { content: ""; position: absolute; width: 420px; height: 420px; top: 10%; right: -170px; border: 1px solid rgba(231, 154, 69, .56); border-radius: 50%; box-shadow: 0 0 0 32px rgba(231, 154, 69, .08), 0 0 0 64px rgba(231, 154, 69, .05); }
.brand-lockup { display: flex; align-items: center; gap: 10px; letter-spacing: -.02em; }
.brand-mark { display: grid; width: 31px; height: 31px; place-items: center; color: var(--sidebar); background: var(--accent); border-radius: 8px; font-weight: 800; font-size: 17px; }
.brand-name { font-size: 15px; font-weight: 750; }
.eyebrow { margin: 0 0 8px; color: var(--accent-deep); font-size: 10px; font-weight: 800; letter-spacing: .16em; line-height: 1.3; text-transform: uppercase; }
.auth-panel .brand-lockup { margin-bottom: 74px; }
.auth-panel h1 { max-width: 440px; margin: 0; font-size: clamp(38px, 5vw, 61px); letter-spacing: -.065em; line-height: .99; }
.auth-panel h1 em { color: var(--accent-deep); font-style: normal; }
.auth-intro { max-width: 370px; margin: 20px 0 38px; color: var(--ink-soft); font-size: 16px; }
.stack-form { display: grid; gap: 10px; }
label { color: var(--ink-soft); font-size: 12px; font-weight: 750; }
input, select { min-height: 42px; padding: 9px 12px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
input::placeholder { color: #849398; }
input:focus, select:focus { border-color: var(--accent-deep); outline: 3px solid rgba(231, 154, 69, .18); }
.button { min-height: 42px; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px; font-weight: 750; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.button:active, .table-action:active, .nav-item:active { transform: translateY(1px); }
.button-primary { color: #fff; background: var(--ink); }
.button-primary:hover { background: #1c4858; }
.button-secondary { color: var(--ink); background: transparent; border-color: var(--line); }
.button-secondary:hover { border-color: var(--accent-deep); background: rgba(231, 154, 69, .08); }
.button-quiet { min-height: 36px; padding: 7px 12px; color: var(--ink-soft); background: transparent; border-color: var(--line); }
.button-quiet.is-refreshing { cursor: wait; opacity: .72; }
.button-quiet.is-refreshing span[aria-hidden="true"] { display: inline-block; animation: refresh-spin .8s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }
.button-wide { width: 100%; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: 12px; text-align: center; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.form-note, .field-help { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.form-error { margin: 10px 0 0; color: var(--danger); font-size: 12px; font-weight: 700; }
.aside-stamp { align-self: flex-start; margin-bottom: auto; color: var(--accent); font: 700 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; }
.auth-aside .eyebrow { margin-bottom: 20px; color: var(--accent); }
.aside-quote { max-width: 420px; margin: 0 0 31px; font-size: clamp(27px, 3vw, 46px); letter-spacing: -.05em; line-height: 1.06; }
.aside-rule, .settings-rule { height: 1px; margin-bottom: 15px; background: rgba(231, 154, 69, .5); }
.aside-meta { margin: 0; color: #aac0c2; font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }

.app-shell { min-height: 100dvh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; min-height: 100dvh; padding: 31px 18px 22px; color: #edf2ef; background: var(--sidebar); }
.sidebar .brand-name { color: #fff; }
.sidebar-top { display: flex; flex-direction: column; gap: 26px; padding: 0 12px; }
.status-dot { color: #9db6b8; font-size: 11px; }
.status-dot span, .live-line { display: inline-block; width: 7px; height: 7px; margin-right: 6px; vertical-align: 1px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 0 4px rgba(231, 154, 69, .12); }
.main-nav { display: grid; gap: 5px; margin-top: 58px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; color: #a7bdc0; background: transparent; border: 0; border-radius: 8px; font-weight: 650; text-align: left; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.nav-item.is-active { color: var(--ink); background: var(--accent); }
.nav-glyph { width: 18px; color: currentColor; font-size: 19px; line-height: 1; text-align: center; }
.sidebar-bottom { display: grid; gap: 10px; margin-top: auto; padding: 14px 12px 0; border-top: 1px solid rgba(255, 255, 255, .11); }
.collection-status { display: grid; grid-template-columns: auto 1fr auto; align-items: center; color: #a7bdc0; font-size: 11px; }
.collection-status .live-line { margin: 0 9px 0 0; }
.collection-status strong { color: #e8f1ed; font-size: 11px; }
.sidebar-action { padding: 3px 0; color: #9db6b8; background: transparent; border: 0; font-size: 11px; text-align: left; }
.sidebar-action:hover { color: var(--accent); }
.content-shell { min-width: 0; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 42px clamp(24px, 5vw, 72px) 27px; border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0; font-size: 31px; letter-spacing: -.055em; line-height: 1; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.last-refresh { color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.content-area { max-width: 1440px; padding: 38px clamp(24px, 5vw, 72px) 72px; }
.view { animation: reveal .22s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.section-lead { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 27px; }
.section-lead h3, .panel-heading h3 { margin: 0; font-size: 22px; letter-spacing: -.04em; }
.section-note { max-width: 380px; margin: 0; color: var(--muted); font-size: 12px; text-align: right; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(100px, 1fr)); gap: 10px; }
.metric-card { min-height: 135px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.metric-card-featured { color: #fff; background: var(--ink); border-color: var(--ink); }
.metric-card span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.metric-card-featured span { color: #b3c7c6; }
.metric-card strong { display: block; margin: 21px 0 7px; font: 800 clamp(24px, 3vw, 33px)/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -.08em; }
.metric-card small { color: var(--muted); font-size: 10px; }
.metric-card-featured small { color: #b3c7c6; }
.overview-columns { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .8fr); gap: 10px; margin-top: 10px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 23px 23px 17px; }
.panel-heading .eyebrow { margin-bottom: 5px; }
.text-button { padding: 0; color: var(--accent-deep); background: transparent; border: 0; font-size: 12px; font-weight: 750; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 10px 18px; color: var(--muted); border-top: 1px solid var(--line); font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
td { padding: 14px 18px; color: var(--ink-soft); border-top: 1px solid #e8eeec; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: #fafcf9; }
.primary-cell, .table-primary { color: var(--ink); font-weight: 750; }
.mono-cell { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.table-number { display: block; color: var(--ink); font: 750 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.table-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.status-badge, .health-badge { display: inline-flex; align-items: center; min-height: 23px; padding: 3px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.status-active, .status-success, .health-healthy { color: var(--success); background: #e4f2ed; }
.status-paused, .status-error, .health-degraded { color: var(--danger); background: #f8e9e5; }
.status-not_listed, .status-unknown, .health-unknown { color: var(--muted); background: #edf1ef; }
.table-action { padding: 5px 9px; color: var(--accent-deep); background: transparent; border: 1px solid #e6c29b; border-radius: 6px; font-size: 11px; font-weight: 750; }
.table-action:hover { color: #fff; background: var(--accent-deep); }
.health-list { display: grid; gap: 0; margin: 0; padding: 0 23px; }
.health-list div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid #e8eeec; }
.health-list dt { color: var(--muted); font-size: 11px; }
.health-list dd { margin: 0; color: var(--ink); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
.privacy-note { margin: 20px 23px 23px; padding: 12px; color: var(--ink-soft); background: #f3f6f3; border-left: 3px solid var(--accent); font-size: 11px; }
.toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.search-field { display: grid; grid-template-columns: minmax(190px, 340px) auto; gap: 7px; align-items: end; }
.search-field span { grid-column: 1 / -1; }
.search-field input { width: 100%; }
.search-field button { min-height: 42px; padding: 0 14px; color: var(--ink); background: #e6eeeb; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; font-weight: 750; }
.result-count { color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.table-panel { overflow: hidden; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-top: 1px solid var(--line); }
.pagination-summary { color: var(--muted); font-size: 11px; }
.pagination-controls { display: flex; gap: 7px; }
.page-button { padding: 6px 10px; color: var(--ink-soft); background: #f3f6f3; border: 1px solid var(--line); border-radius: 6px; font-size: 11px; }
.empty-cell { padding: 42px 18px; color: var(--muted); text-align: center; }
.filter-bar { display: grid; grid-template-columns: repeat(6, minmax(100px, 1fr)); align-items: end; gap: 10px; margin-bottom: 13px; }
.filter-bar label { display: grid; gap: 7px; }
.filter-bar .button { white-space: nowrap; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 10px; }
.settings-form, .settings-side { padding: 0 24px 25px; }
.settings-form { display: grid; align-content: start; gap: 9px; }
.settings-form .panel-heading, .settings-side .panel-heading { margin: 0 -24px 11px; }
.settings-form label { display: grid; gap: 7px; margin-top: 8px; }
.settings-form button { margin-top: 18px; justify-self: start; }
.settings-health { padding: 12px; background: #f3f6f3; }
.settings-health p { margin: 12px 0 0; color: var(--ink-soft); font-size: 12px; }
.settings-rule { margin-top: 25px; background: var(--line); }
.bot-settings-panel { margin-top: 10px; padding: 0 24px 25px; }
.bot-settings-panel .panel-heading { margin: 0 -24px 8px; }
.settings-state { padding: 6px 9px; color: var(--accent-deep); background: #fff2dd; border-radius: 999px; font-size: 11px; font-weight: 750; }
.bot-settings-intro { margin: 0 0 17px; }
.bot-settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.bot-settings-section { min-width: 0; padding: 17px; background: #f7f9f7; border: 1px solid var(--line); border-radius: 9px; }
.bot-settings-section h4 { margin: 2px 0 14px; font-size: 17px; letter-spacing: -.03em; }
.bot-settings-section label { display: grid; gap: 7px; margin-top: 10px; }
.format-fieldset { margin: 10px 0 0; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 7px; }
.format-fieldset legend { padding: 0 5px; color: var(--ink-soft); font-size: 11px; font-weight: 750; }
.format-fieldset label { display: flex; grid-template-columns: none; align-items: center; gap: 7px; margin-top: 0; }
.inherit-check { margin-bottom: 10px !important; color: var(--muted); font-size: 11px; }
.format-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 12px; }
.format-options label { color: var(--ink-soft); font-size: 12px; }
.format-options input, .inherit-check input { accent-color: var(--accent-deep); }
.bot-settings-actions { display: flex; align-items: center; gap: 14px; margin-top: 17px; }
.bot-settings-actions .button { margin-top: 0; }
.bot-settings-actions .form-error { margin: 0; }

.permission-dialog { width: min(480px, calc(100% - 30px)); padding: 0; color: var(--ink); background: var(--panel); border: 0; border-radius: var(--radius); box-shadow: 0 24px 80px rgba(16, 44, 58, .25); }
.permission-dialog::backdrop { background: rgba(16, 44, 58, .55); }
.dialog-form { display: grid; gap: 9px; padding: 26px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 3px; }
.dialog-heading h3 { margin: 0; font-size: 21px; letter-spacing: -.04em; }
.dialog-close { width: 30px; height: 30px; padding: 0; color: var(--muted); background: transparent; border: 0; font-size: 25px; line-height: 1; }
.dialog-subject { margin: 0 0 10px; padding: 10px 12px; color: var(--ink-soft); background: #f3f6f3; border-left: 3px solid var(--accent); font-size: 12px; }
.dialog-form label { display: grid; gap: 7px; margin-top: 5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 5; max-width: 360px; padding: 12px 16px; color: #fff; background: var(--ink); border-left: 3px solid var(--accent); border-radius: 8px; box-shadow: 0 12px 30px rgba(16, 44, 58, .2); font-size: 12px; }

@media (max-width: 1150px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .filter-bar { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
}

@media (max-width: 800px) {
  .auth-layout { display: block; }
  .auth-panel { min-height: 100dvh; padding: 32px 24px; }
  .auth-panel .brand-lockup { margin-bottom: 56px; }
  .auth-aside { display: none; }
  .app-shell { display: block; }
  .sidebar { min-height: auto; padding: 16px 18px 12px; }
  .sidebar-top { flex-direction: row; align-items: center; justify-content: space-between; padding: 0; }
  .main-nav { display: flex; gap: 3px; margin-top: 15px; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; width: auto; padding: 9px 10px; font-size: 12px; }
  .nav-glyph { display: none; }
  .sidebar-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 10px 0 0; }
  .collection-status { margin-right: auto; }
  .topbar { padding: 26px 20px 20px; }
  .content-area { padding: 27px 20px 48px; }
  .bot-settings-grid { grid-template-columns: 1fr; }
  .topbar-actions { align-items: flex-end; flex-direction: column; gap: 7px; }
  .section-lead { align-items: flex-start; flex-direction: column; gap: 9px; }
  .section-note { text-align: left; }
  .overview-columns, .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { min-height: 122px; padding: 14px; }
  .metric-card strong { margin-top: 16px; font-size: 23px; }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar .button { grid-column: span 1; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .search-field { width: 100%; grid-template-columns: minmax(0, 1fr) auto; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .sidebar-bottom { flex-wrap: wrap; }
  .collection-status { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
