:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #f0f3f4;
  --ink: #182126;
  --muted: #66737a;
  --line: #dbe1e4;
  --accent: #087e6b;
  --accent-strong: #056353;
  --blue: #2563a7;
  --danger: #b53c35;
  --warning: #9b6a14;
  --success-bg: #e6f4ef;
  --radius: 6px;
  --shadow: 0 12px 32px rgba(32, 45, 51, .11);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.loading-screen { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; background: var(--ink); color: white; font-weight: 800; border-radius: 4px; }
.brand-mark.small { width: 36px; height: 36px; font-size: 12px; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; background: white; }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, 1fr) minmax(420px, 560px); }
.auth-brand { padding: clamp(48px, 8vw, 112px); background: #152229; color: white; display: flex; flex-direction: column; justify-content: center; }
.auth-brand h1 { margin: 28px 0 8px; font-size: 42px; font-weight: 750; }
.auth-brand > p { color: #b9c6cb; margin: 0 0 48px; font-size: 17px; }
.auth-facts { margin: 0; border-top: 1px solid #34434a; max-width: 580px; }
.auth-facts div { display: grid; grid-template-columns: 110px 1fr; padding: 16px 0; border-bottom: 1px solid #34434a; }
.auth-facts dt { color: #93a4aa; }
.auth-facts dd { margin: 0; overflow-wrap: anywhere; }
.auth-panel { background: var(--surface); padding: clamp(36px, 6vw, 80px); display: flex; flex-direction: column; justify-content: center; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.auth-tab { border: 0; background: transparent; padding: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.auth-tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }
.stack-form { display: grid; gap: 18px; }
.inline-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.inline-field button { min-height: 42px; }
.oauth-buttons { display: grid; gap: 8px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.oauth-link { display: block; text-align: center; text-decoration: none; border: 1px solid var(--line); border-radius: 4px; padding: 10px 14px; color: var(--ink); font-weight: 650; }
.oauth-link:hover { border-color: var(--accent); color: var(--accent-strong); }
label { display: grid; gap: 8px; color: #3e4b51; font-size: 14px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid #cdd5d9; background: white; color: var(--ink); border-radius: 4px; padding: 11px 12px; outline: none; }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8, 126, 107, .12); }
button.primary, button.secondary, button.danger, button.ghost { border-radius: 4px; padding: 10px 15px; font-weight: 650; border: 1px solid transparent; }
button.primary { background: var(--accent); color: white; }
button.primary:hover { background: var(--accent-strong); }
button.secondary { background: var(--ink); color: white; }
button.ghost { background: white; color: var(--ink); border-color: var(--line); }
button.danger { background: white; color: var(--danger); border-color: #e5bbb8; }
button:disabled { opacity: .55; cursor: not-allowed; }
.wide { width: 100%; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: #17242a; color: white; display: flex; flex-direction: column; padding: 18px 14px; z-index: 20; }
.sidebar-brand { height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 6px 14px; border-bottom: 1px solid #314047; }
.sidebar-brand strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-nav { display: grid; gap: 3px; padding: 18px 0; overflow-y: auto; }
.nav-label { color: #819198; font-size: 11px; padding: 16px 12px 6px; text-transform: uppercase; }
.nav-button { border: 0; background: transparent; color: #c3ced2; border-radius: 4px; padding: 10px 12px; text-align: left; }
.nav-button:hover { background: #23333a; color: white; }
.nav-button.active { background: #e8f3ef; color: #075c4e; font-weight: 700; }
.sidebar-user { margin-top: auto; border-top: 1px solid #314047; padding: 16px 8px 2px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sidebar-user div { min-width: 0; display: grid; gap: 3px; }
.sidebar-user strong { overflow: hidden; text-overflow: ellipsis; }
.sidebar-user span { color: #8ea0a7; font-size: 11px; }
.text-button { border: 0; padding: 4px; background: transparent; color: #a9b8bd; }
.mobile-header { display: none; }
.content-shell { min-width: 0; }
.page-header { min-height: 104px; padding: 24px clamp(22px, 4vw, 52px); display: flex; align-items: center; justify-content: space-between; gap: 24px; background: white; border-bottom: 1px solid var(--line); }
.page-header h2 { margin: 4px 0 0; font-size: 25px; }
.eyebrow { color: var(--accent); text-transform: uppercase; font-size: 11px; font-weight: 800; margin: 0; }
.page-actions { display: flex; align-items: center; gap: 8px; }
.page-content { max-width: 1500px; padding: 28px clamp(22px, 4vw, 52px) 72px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.metric { padding: 22px; border-right: 1px solid var(--line); min-width: 0; }
.metric:last-child { border-right: 0; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 10px; font-size: 25px; overflow-wrap: anywhere; }
.metric small { display: block; margin-top: 5px; color: var(--muted); }
.section { margin-top: 30px; }
.section:first-child { margin-top: 0; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-heading h3 { margin: 0; font-size: 17px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.data-panel { background: white; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #f2f5f6; color: #59666c; text-align: left; font-weight: 700; padding: 11px 14px; white-space: nowrap; }
td { padding: 13px 14px; border-top: 1px solid #e7ebed; vertical-align: middle; }
tbody tr:hover { background: #fafcfc; }
.cell-title { display: block; font-weight: 700; }
.cell-subtitle { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.actions { display: flex; gap: 10px; align-items: center; white-space: nowrap; }
.link-button { border: 0; background: transparent; padding: 2px 0; color: var(--blue); }
.link-button.danger-link { color: var(--danger); }
.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #9aa5aa; }
.status.active::before, .status.ok::before { background: var(--accent); }
.status.error::before, .status.disabled::before { background: var(--danger); }
.status.warning::before { background: var(--warning); }
.empty { padding: 54px 24px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 8px; }

.split-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); gap: 22px; align-items: start; }
.info-panel { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.info-panel h3 { margin: 0 0 14px; font-size: 16px; }
.info-list { display: grid; gap: 0; margin: 0; }
.info-list div { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.info-list div:last-child { border-bottom: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; overflow-wrap: anywhere; }
.code-block { position: relative; background: #16242b; color: #d8e5e9; border-radius: 4px; padding: 18px; overflow-x: auto; font: 12px/1.7 Consolas, monospace; white-space: pre; }
.secret-box { background: #edf7f4; border: 1px solid #b8ddd4; padding: 16px; border-radius: 4px; overflow-wrap: anywhere; font-family: Consolas, monospace; }
.notice { border-left: 3px solid var(--accent); background: #edf7f4; padding: 12px 14px; color: #30534c; font-size: 13px; }
.danger-notice { border-left-color: var(--danger); background: #fbefee; color: #6e3430; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.toolbar label { min-width: 160px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-row input[type="file"] { flex: 1; min-width: 220px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; }
.checkbox-label input { width: auto; }
.pricing-calculator { border: 1px solid var(--line); background: #f7faf9; border-radius: 4px; padding: 14px; display: grid; gap: 10px; }
.pricing-calculator > div { display: grid; gap: 5px; }
.pricing-calculator strong { font-size: 14px; }
.pricing-calculator span { color: #31514c; font-size: 13px; line-height: 1.5; }
.pricing-calculator .checkbox-label { align-items: flex-start; }
.brand-preview { display: flex; align-items: center; gap: 14px; margin: 16px 0 18px; }
.brand-preview strong { display: block; font-size: 18px; }
.brand-preview p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
details.advanced { border-top: 1px solid var(--line); padding-top: 14px; }
details.advanced summary { cursor: pointer; color: var(--blue); font-weight: 700; }
details.advanced[open] summary { margin-bottom: 16px; }
.field-help { margin: -2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; border: 0; border-radius: 6px; padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(13, 25, 31, .55); }
.dialog-header { position: sticky; top: 0; z-index: 2; background: white; display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.dialog-header h3 { margin: 4px 0 0; font-size: 20px; }
#modal-body { padding: 24px; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; border: 0; background: transparent; color: var(--ink); font-size: 22px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: min(380px, calc(100vw - 48px)); background: #17242a; color: white; padding: 12px 16px; border-radius: 4px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8e302b; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .split-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-brand { min-height: 310px; padding: 38px 24px; justify-content: start; }
  .auth-brand h1 { margin-top: 22px; font-size: 32px; }
  .auth-brand > p { margin-bottom: 24px; }
  .auth-facts { width: 100%; }
  .auth-panel { padding: 34px 24px 56px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 244px; transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-header { height: 58px; padding: 0 12px; background: #17242a; color: white; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 15; }
  .mobile-header .icon-button { color: white; }
  .mobile-header strong { font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .mobile-header span { font-size: 12px; }
  .page-header { min-height: 90px; padding: 18px; align-items: end; }
  .page-header h2 { font-size: 21px; }
  .page-actions button { padding: 9px 11px; }
  .page-content { padding: 20px 16px 56px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { padding: 16px; }
  .metric strong { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  th, td { padding: 11px 12px; }
}

@media (max-width: 430px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .page-header { align-items: center; }
  .page-actions { max-width: 45%; }
  .auth-facts div { grid-template-columns: 90px 1fr; }
}
