:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f8faf9;
    --border: #dfe4e7;
    --border-strong: #cbd3d8;
    --text: #192126;
    --muted: #66747c;
    --green: #16784a;
    --green-dark: #0d6039;
    --green-soft: #eaf6ef;
    --amber: #9a5a00;
    --amber-soft: #fff5dd;
    --red: #b42318;
    --red-soft: #fff0ee;
    --blue: #245ea8;
    --shadow: 0 1px 2px rgba(20, 31, 38, .06);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
code, pre { font-family: Consolas, "SFMono-Regular", monospace; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: #182329; color: #dbe3e6; padding: 18px 14px; display: flex; flex-direction: column; z-index: 20; }
.brand-lockup { display: flex; align-items: center; gap: 11px; }
.brand-lockup strong { display: block; font-size: 15px; line-height: 1.3; }
.brand-lockup small { display: block; color: #8fa0a8; font-size: 11px; margin-top: 2px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 7px; background: #1f9d62; color: #fff; font-weight: 700; }
.sidebar-brand { padding: 4px 8px 22px; }
.nav-list { display: grid; gap: 3px; }
.nav-list a { min-height: 40px; display: flex; align-items: center; padding: 0 12px; border-radius: 6px; color: #b9c6cc; }
.nav-list a:hover { background: #223139; color: #fff; }
.nav-list a.active { background: #2a3d45; color: #fff; box-shadow: inset 3px 0 #37b875; }
.sidebar-footer { margin-top: auto; border-top: 1px solid #314149; padding: 14px 8px 2px; display: flex; justify-content: space-between; align-items: center; color: #adbbc1; }
.text-button, .button-as-link { border: 0; background: transparent; padding: 0; }
.text-button { color: #dbe3e6; }
.main-column { min-width: 0; }
.topbar { min-height: 64px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; padding: 0 28px; position: sticky; top: 0; z-index: 10; }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 650; }
.topbar > div { flex: 1; }
.content { width: min(1440px, 100%); margin: 0 auto; padding: 26px 28px 64px; }
.menu-toggle { display: none; }

.button { min-height: 38px; padding: 8px 14px; border: 1px solid transparent; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.button-primary { background: var(--green); color: #fff; }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.button-secondary:hover { background: #f2f5f6; }
.button-warning { background: var(--amber-soft); color: var(--amber); border-color: #f0d49c; }
.button-danger { background: #fff; color: var(--red); border-color: #e7aaa4; }
.button-danger:hover { background: var(--red-soft); }
.button-small { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.button-block { width: 100%; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.table-link { color: var(--blue); font-weight: 600; }
.table-link:hover { text-decoration: underline; }

.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); border: 1px solid var(--border); background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.stat { padding: 18px 20px; border-right: 1px solid var(--border); }
.stat:last-child { border-right: 0; }
.stat span, .stat small { color: var(--muted); display: block; }
.stat strong { display: block; font-size: 27px; line-height: 1.25; margin: 8px 0 3px; }
.stat small { font-size: 12px; }
.section-block { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 22px; }
.section-block.no-top-border { margin-top: 0; border-top: 0; padding-top: 0; }
.form-section { background: var(--surface); border: 1px solid var(--border); padding: 22px; border-radius: 8px; box-shadow: var(--shadow); }
.section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-header h2 { margin: 0; font-size: 16px; }
.section-header p { margin: 5px 0 0; color: var(--muted); line-height: 1.5; }
.empty-state { min-height: 180px; border: 1px dashed var(--border-strong); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 28px; background: var(--surface-soft); }
.empty-state strong { font-size: 16px; }
.empty-state p { color: var(--muted); margin: 8px 0 16px; }
.empty-state.compact { min-height: 92px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 680px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: #f6f8f9; color: #52616a; font-size: 12px; font-weight: 650; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfc; }
.wide-table { min-width: 1040px; }
.table-subtext { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.truncate-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-cell { max-width: 340px; }
.message-cell strong, .message-cell span { display: block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-cell span { color: var(--muted); margin-top: 3px; }
.error-text { color: var(--red); }
.status { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 650; white-space: nowrap; }
.status-success { background: var(--green-soft); color: var(--green-dark); }
.status-warning { background: var(--amber-soft); color: var(--amber); }
.status-danger { background: var(--red-soft); color: var(--red); }

.alert, .notice { border: 1px solid; border-radius: 7px; padding: 12px 14px; line-height: 1.5; }
.alert { margin-bottom: 18px; }
.alert-success, .notice.success { background: var(--green-soft); color: var(--green-dark); border-color: #b8dec8; }
.alert-error { background: var(--red-soft); color: var(--red); border-color: #efc2bd; }
.notice.warning { background: var(--amber-soft); color: #754600; border-color: #ecd39f; }
.notice { margin: 12px 0 18px; }
.notice strong { display: block; }
.notice p { margin: 4px 0 0; }

.form-stack, .form-grid { display: grid; gap: 16px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.compact-form { gap: 13px 16px; }
label { display: grid; gap: 7px; font-weight: 600; color: #34434b; }
label small { color: var(--muted); font-weight: 400; }
input, select, textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: 6px; background: #fff; color: var(--text); padding: 9px 11px; min-height: 40px; outline: none; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22, 120, 74, .1); }
.span-2 { grid-column: 1 / -1; }
.checkbox-label { display: flex; align-items: center; gap: 8px; min-height: 40px; font-weight: 500; }
.checkbox-label input { width: 17px; min-height: 17px; height: 17px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.inline-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.muted { color: var(--muted); }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 28px 16px; background: #eef2f3; }
.auth-shell { width: min(440px, 100%); }
.auth-shell > .brand-lockup { justify-content: center; margin-bottom: 18px; }
.auth-shell .brand-lockup small { color: var(--muted); }
.auth-panel { border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 28px; box-shadow: 0 12px 32px rgba(25, 33, 38, .08); }
.panel-heading { margin-bottom: 22px; }
.panel-heading h1 { margin: 3px 0 8px; font-size: 23px; }
.panel-heading p { color: var(--muted); margin: 0; line-height: 1.6; }
.eyebrow { color: var(--green) !important; text-transform: uppercase; font-size: 11px; font-weight: 700; }

.item-list, .channel-list { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); overflow: hidden; }
.list-row { display: grid; grid-template-columns: minmax(240px, 1fr) auto auto 24px; gap: 24px; align-items: center; padding: 15px 16px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: #f8faf9; }
.list-primary strong, .list-primary span { display: block; }
.list-primary span { color: var(--muted); margin-top: 4px; font-size: 12px; }
.list-metrics { display: flex; gap: 18px; color: var(--muted); }
.row-arrow { font-size: 22px; color: #91a0a7; }
.detail-heading { margin-bottom: 16px; }
.back-link { color: var(--muted); display: inline-block; margin-bottom: 10px; }
.title-line { display: flex; align-items: center; gap: 12px; }
.title-line h2 { font-size: 22px; margin: 0; }
.detail-heading p { margin: 6px 0 0; color: var(--muted); }
.wizard-progress { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--border); border-radius: 7px; overflow: hidden; margin-bottom: 20px; background: #fff; }
.wizard-progress span { padding: 11px 14px; border-right: 1px solid var(--border); color: var(--muted); text-align: center; font-size: 12px; }
.wizard-progress span:last-child { border-right: 0; }
.wizard-progress .current { background: var(--amber-soft); color: var(--amber); font-weight: 650; }
.wizard-progress .done { background: var(--green-soft); color: var(--green-dark); font-weight: 650; }
.copy-field { display: flex; min-width: 0; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; background: #f7f9fa; }
.copy-field code { flex: 1; padding: 9px 11px; overflow-x: auto; white-space: nowrap; }
.copy-field .button { border-width: 0 0 0 1px; border-radius: 0; }
.verification-time { color: var(--muted); font-size: 12px; }
.user-picker { border: 1px solid var(--border); border-radius: 7px; max-height: 260px; overflow: auto; padding: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.user-picker:not([hidden]) { display: grid; }
.user-option { display: flex; align-items: center; gap: 7px; padding: 7px; border-radius: 5px; font-weight: 500; }
.user-option:hover { background: #f1f5f3; }
.user-option input { width: 16px; height: 16px; min-height: 16px; }
.danger-zone { margin-top: 30px; border: 1px solid #edc1bc; border-radius: 8px; background: #fff; padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.danger-zone h2 { color: var(--red); margin: 0; font-size: 15px; }
.danger-zone p { color: var(--muted); margin: 5px 0 0; }
.danger-form { display: flex; gap: 8px; }
.danger-form input { width: 140px; }

.credential-banner { background: #eef8f2; border: 1px solid #9fd0b4; border-radius: 8px; padding: 20px; margin-bottom: 22px; }
.credential-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.channel-row { border-bottom: 1px solid var(--border); }
.channel-row:last-child { border-bottom: 0; }
.channel-row summary { list-style: none; display: grid; grid-template-columns: minmax(230px, 1fr) 100px 90px 160px; gap: 18px; align-items: center; padding: 14px 16px; cursor: pointer; }
.channel-row summary::-webkit-details-marker { display: none; }
.channel-row[open] summary { background: #f7faf8; border-bottom: 1px solid var(--border); }
.channel-detail { padding: 18px; display: grid; gap: 14px; background: #fff; }
.channel-type { font-family: Consolas, monospace; color: var(--muted); }
.channel-actions { padding-top: 4px; }

.settings-grid { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 24px; }
.definition-list { margin: 0; }
.definition-list div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.definition-list div:last-child { border-bottom: 0; }
.definition-list dt { color: var(--muted); }
.definition-list dd { margin: 0; overflow-wrap: anywhere; }
.backup-list { display: grid; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.backup-list a { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 11px 13px; border-bottom: 1px solid var(--border); }
.backup-list a:last-child { border-bottom: 0; }
.backup-list a:hover { background: #f7faf8; }
.backup-list strong, .backup-list small { display: block; }
.backup-list small { color: var(--muted); margin-top: 3px; }
.docs-content pre { margin: 0 0 20px; padding: 16px; border: 1px solid #2d3a40; border-radius: 7px; background: #1c282e; color: #e7f0f2; overflow-x: auto; line-height: 1.6; }
.docs-content h3 { margin: 22px 0 10px; font-size: 14px; }
.docs-content > p { color: var(--muted); line-height: 1.7; }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .stat { border-bottom: 1px solid var(--border); }
    .settings-grid { grid-template-columns: 1fr; }
    .user-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; left: -250px; width: 232px; transition: left .18s ease; box-shadow: 8px 0 24px rgba(0,0,0,.18); }
    .sidebar.open { left: 0; }
    .menu-toggle { display: inline-grid; place-items: center; }
    .topbar { padding: 0 14px; }
    .content { padding: 18px 14px 44px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stat { border-right: 1px solid var(--border); }
    .form-grid, .credential-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .list-row { grid-template-columns: 1fr auto; gap: 10px; }
    .list-metrics, .row-arrow { display: none; }
    .channel-row summary { grid-template-columns: 1fr auto; }
    .channel-row summary > span:nth-last-child(-n+2) { display: none; }
    .section-header { align-items: stretch; flex-direction: column; }
    .wizard-progress { grid-template-columns: 1fr; }
    .wizard-progress span { border-right: 0; border-bottom: 1px solid var(--border); }
    .wizard-progress span:last-child { border-bottom: 0; }
    .danger-zone, .danger-form { align-items: stretch; flex-direction: column; }
    .danger-form input { width: 100%; }
    .user-picker { grid-template-columns: 1fr; }
}

