:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --line: #dfe4e8;
  --text: #17202a;
  --muted: #66717c;
  --primary: #087e8b;
  --primary-dark: #05616b;
  --danger: #b42318;
  --success: #16794d;
  --sidebar: #17212b;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); font: 14px/1.5 system-ui, "Microsoft YaHei", sans-serif; letter-spacing: 0; }
a { color: var(--primary-dark); text-decoration: none; }
button, input, select, textarea { font: inherit; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 224px; display: flex; flex-direction: column; color: #fff; background: var(--sidebar); }
.brand { height: 72px; padding: 16px 18px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #2b3742; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; color: #fff; background: var(--primary); border-radius: 6px; font-weight: 800; }
.brand-mark.large { width: 48px; height: 48px; font-size: 17px; }
.brand small { display: block; color: #9dadba; }
nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
nav a, .nav-disabled { min-height: 40px; padding: 10px 12px; color: #c8d1d9; border-radius: 5px; }
nav a:hover, nav a.active { color: #fff; background: #283744; }
.nav-disabled { display: flex; justify-content: space-between; opacity: .55; }
.nav-label { padding: 18px 12px 5px; color: #758594; font-size: 11px; text-transform: uppercase; }
.logout-form { margin: auto 14px 18px; }
.main { min-height: 100vh; margin-left: 224px; padding: 0 30px 40px; }
.topbar { min-height: 88px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
h1, h2, p { margin-top: 0; }
.topbar h1 { margin-bottom: 2px; font-size: 22px; }
.topbar p, .section-head p { margin-bottom: 0; color: var(--muted); }
.admin-chip { padding: 6px 10px; background: #e7eef0; border-radius: 4px; font-weight: 600; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; margin: 24px 0; border: 1px solid var(--line); background: var(--line); }
.metrics div, .metrics article { padding: 20px; background: var(--surface); }
.metrics span { display: block; color: var(--muted); }
.metrics strong { display: block; margin-top: 8px; font-size: 28px; }
.section-head { margin: 24px 0 12px; display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.section-head.compact { margin: 0; padding: 16px 18px; align-items: center; border-bottom: 1px solid var(--line); }
.section-head h2, .form-section h2 { margin-bottom: 3px; font-size: 16px; }
.actions, .form-actions, .action-cell { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.button { min-height: 36px; padding: 8px 13px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #cbd3d9; border-radius: 5px; color: var(--text); background: #fff; cursor: pointer; }
.button:hover { border-color: #9da9b2; background: #f8fafb; }
.button-primary { color: #fff; border-color: var(--primary); background: var(--primary); }
.button-primary:hover { color: #fff; border-color: var(--primary-dark); background: var(--primary-dark); }
.button-danger { color: var(--danger); border-color: #e5b7b2; }
.button-danger-solid { color: #fff; border-color: var(--danger); background: var(--danger); }
.button-quiet { color: var(--muted); background: transparent; }
.button-small { min-height: 30px; padding: 5px 9px; font-size: 13px; }
.full { width: 100%; }
.table-section, .form-section { background: var(--surface); border: 1px solid var(--line); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th { padding: 11px 14px; text-align: left; color: var(--muted); background: #f8fafb; font-size: 12px; font-weight: 650; white-space: nowrap; }
td { padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
td > strong, td > code { white-space: nowrap; }
td.right, th.right { text-align: right; }
.block { display: block; margin-top: 3px; color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.status { display: inline-flex; padding: 3px 7px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.status.success { color: var(--success); background: #e6f4ed; }
.status.neutral { color: #5a6670; background: #edf0f2; }
.status.danger { color: var(--danger); background: #fff0ef; }
.mini-card { min-width: 260px; margin-top: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfd; }
.compact-actions { margin-top: 7px; justify-content: flex-start; flex-wrap: wrap; }
.compact-actions form { margin: 0; }
.check-label { flex-direction: row; align-items: center; font-weight: 500; }
.check-label input { width: 18px; min-height: 18px; }
.price-input { max-width: 180px; }
.amount-positive { color: var(--success); font-weight: 700; }
.amount-negative { color: var(--danger); font-weight: 700; }
code { font-family: ui-monospace, Consolas, monospace; }
.filters { display: flex; gap: 8px; margin-bottom: 12px; }
.filters select { min-width: 160px; }
.filters input { max-width: 260px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.pagination span { margin-right: auto; color: var(--muted); }
.confirm-panel { max-width: 560px; margin-top: 24px; padding: 24px; background: #fff; border: 1px solid var(--line); }
.confirm-entity { padding: 12px; background: #f2f5f6; font-size: 16px; font-weight: 700; }
.config-status { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 24px; border: 1px solid var(--line); background: var(--line); }
.config-status div { padding: 14px 16px; background: #fff; }
.config-status span { display: block; color: var(--muted); font-size: 12px; }
.config-status strong { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.config-status .ok { color: var(--success); }
.config-status .bad { color: var(--danger); }
.notice { max-width: 980px; margin-top: 14px; padding: 12px 14px; color: #24515a; border: 1px solid #add1d5; background: #edf8f9; }
.notice.warning { color: #71551b; border-color: #e4cc92; background: #fff8e7; }
.editor-form { max-width: 980px; }
.editor-form.narrow { max-width: 760px; }
.form-section { margin-top: 18px; padding: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
label.wide { grid-column: 1 / -1; }
label small { color: var(--muted); font-weight: 400; }
input, select, textarea { width: 100%; min-height: 40px; padding: 9px 10px; color: var(--text); background: #fff; border: 1px solid #bdc7ce; border-radius: 4px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 2px solid #cfe9ec; }
.toggle-row { flex-direction: row; align-items: center; align-self: end; min-height: 40px; }
.toggle-row input { width: 18px; min-height: 18px; }
.form-actions { margin-top: 18px; }
.alert { margin-top: 18px; padding: 11px 14px; border: 1px solid; border-radius: 5px; }
.alert-success { color: var(--success); border-color: #a9d7c1; background: #eaf7f0; }
.alert-error { color: var(--danger); border-color: #e7b8b3; background: #fff0ef; }
.auth-page { min-height: 100vh; background: #e9eef1; }
.auth-main { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-panel { width: min(420px, 100%); padding: 30px; background: #fff; border: 1px solid var(--line); box-shadow: 0 12px 30px rgba(23, 32, 42, .08); }
.login-heading { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.login-heading h1 { margin-bottom: 2px; font-size: 21px; }
.login-heading p, .security-note { margin-bottom: 0; color: var(--muted); }
.form-stack { display: grid; gap: 16px; }
.security-note { margin-top: 18px; font-size: 12px; }
.preview-layout { display: grid; grid-template-columns: minmax(360px, 620px) 280px; gap: 20px; margin-top: 24px; align-items: start; }
.telegram-preview { min-height: 540px; padding: 0 22px 24px; background: #dce9e7; border: 1px solid #bdcfcc; }
.telegram-bar { margin: 0 -22px 24px; padding: 13px 18px; background: #fff; border-bottom: 1px solid #ccd8d7; font-weight: 700; }
.message-bubble { max-width: 440px; padding: 15px; background: #fff; border-radius: 7px; white-space: pre-line; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.preview-buttons { max-width: 440px; display: grid; gap: 2px; margin-top: 3px; }
.preview-buttons span { padding: 9px; color: #087e8b; text-align: center; background: #fff; font-weight: 650; }
.preview-info { padding: 18px; background: #fff; border: 1px solid var(--line); }
.preview-info .button { margin-top: 8px; }
.banner-preview { grid-column: 1 / -1; margin: 0; }
.banner-preview img { display: block; width: min(100%, 750px); aspect-ratio: 1500 / 560; object-fit: cover; border: 1px solid var(--line); }
.banner-preview figcaption, .banner-empty { margin: 7px 0 0; color: var(--muted); }
.banner-empty.wide { grid-column: 1 / -1; }
dl { display: grid; grid-template-columns: 90px 1fr; gap: 8px; }
dt { color: var(--muted); }
dd { margin: 0; }
details pre { max-width: 420px; white-space: pre-wrap; }
@media (max-width: 900px) {
  .sidebar { position: static; width: 100%; min-height: auto; }
  .sidebar nav { display: grid; grid-template-columns: repeat(2, 1fr); }
  .nav-label, .nav-disabled, .logout-form { display: none; }
  .main { margin-left: 0; padding: 0 16px 28px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .config-status { grid-template-columns: 1fr; }
  .preview-layout { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar, .section-head { align-items: flex-start; }
  .section-head { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  label.wide { grid-column: auto; }
  .filters { flex-wrap: wrap; }
  .metrics { grid-template-columns: 1fr 1fr; }
}
