:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #18212f;
    --muted: #667085;
    --border: #d9dee7;
    --primary: #176b54;
    --primary-hover: #125641;
    --danger: #b42318;
    --danger-hover: #912018;
    --warning-bg: #fff8e6;
    --focus: #2e90fa;
    --success: #12b76a;
    --sidebar: #202936;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); font-size: 14px; line-height: 1.5; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(46, 144, 250, .28); outline-offset: 1px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 22px; line-height: 1.3; }
h2 { margin: 0; font-size: 18px; }
.muted, .page-heading p { color: var(--muted); }
.hidden { display: none !important; }

.topbar { height: 56px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; color: #fff; background: #131a24; border-bottom: 1px solid #303a48; }
.brand, .topbar-actions, .heading-actions { display: flex; align-items: center; gap: 12px; }
.brand-mark, .product-mark { display: grid; place-items: center; color: #fff; background: var(--primary); font-weight: 700; border-radius: 4px; }
.brand-mark { width: 28px; height: 28px; }
.environment { padding: 3px 8px; border: 1px solid #f5c451; color: #ffe29a; border-radius: 4px; font-size: 12px; font-weight: 700; }
.app-shell { min-height: calc(100vh - 56px); display: grid; grid-template-columns: 176px minmax(0, 1fr); }
.sidebar { padding: 16px 10px; background: var(--sidebar); }
.nav-item { width: 100%; min-height: 42px; padding: 0 12px; margin-bottom: 4px; border: 0; border-radius: 4px; color: #cbd3df; background: transparent; text-align: left; cursor: pointer; }
.nav-item:hover { background: #2b3646; color: #fff; }
.nav-item.active { color: #fff; background: var(--primary); font-weight: 600; }
.content { min-width: 0; padding: 24px; }
.view { display: none; max-width: 1500px; margin: 0 auto; }
.view.active { display: block; }
.page-heading { min-height: 52px; margin-bottom: 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-heading p { margin-bottom: 0; }
.filter-bar { display: flex; align-items: flex-end; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px 6px 0 0; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.grow { flex: 1; min-width: 180px; }
.field.compact { width: 130px; }
label { color: #344054; font-weight: 600; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid #b9c1cc; border-radius: 4px; background: #fff; color: var(--text); }
textarea { min-height: 76px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #7b8798; }
.primary-button, .secondary-button, .danger-button, .text-button, .icon-button { min-height: 40px; padding: 8px 14px; border-radius: 4px; cursor: pointer; border: 1px solid transparent; font-weight: 600; text-decoration: none; white-space: nowrap; }
.primary-button { background: var(--primary); color: #fff; }
.primary-button:hover { background: var(--primary-hover); }
.secondary-button { color: #344054; border-color: #b9c1cc; background: #fff; }
.secondary-button:hover { background: #f0f2f5; }
.danger-button { color: #fff; background: var(--danger); }
.danger-button:hover { background: var(--danger-hover); }
.text-button { min-height: 32px; padding: 4px 8px; color: inherit; background: transparent; }
.icon-button { min-height: 36px; padding: 5px 9px; color: #475467; border-color: var(--border); background: #fff; }
.link-button { display: inline-flex; align-items: center; }
.full-width { width: 100%; }
button:disabled { opacity: .5; cursor: not-allowed; }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-top: 0; background: var(--surface); }
table { width: 100%; min-width: 920px; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e7eaf0; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; color: #475467; background: #f8f9fb; font-size: 12px; font-weight: 700; }
tbody tr:hover { background: #f7faf9; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.status::before { width: 7px; height: 7px; border-radius: 50%; background: #98a2b3; content: ""; }
.status.success::before { background: #12b76a; }
.status.failed::before { background: #f04438; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions button { min-height: 32px; padding: 4px 8px; }
.empty-state { padding: 44px 16px; border: 1px solid var(--border); background: #fff; color: var(--muted); text-align: center; }
.section-title { margin: 20px 0 8px; font-size: 15px; }
.summary-strip { display: flex; gap: 20px; padding: 10px 14px; border: 1px solid #a9d8ca; background: #eef8f4; }
.settings-band { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; padding: 14px 16px; border: 1px solid var(--border); background: var(--surface); }
.setting-summary { min-width: 190px; align-self: center; display: flex; flex-direction: column; }
.toggle-control { min-height: 40px; align-self: flex-end; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.toggle-control input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--primary); }

dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 16px 40px rgba(16, 24, 40, .22); }
dialog::backdrop { background: rgba(16, 24, 40, .55); }
.wide-dialog { width: min(720px, calc(100vw - 24px)); }
.dialog-form { width: 100%; min-width: 0; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
#binding-sync-form { max-height: calc(100vh - 34px); overflow: auto; }
.dialog-form label { display: flex; flex-direction: column; gap: 5px; }
.dialog-heading, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-actions { justify-content: flex-end; padding-top: 4px; }
.warning-text { margin: 0; padding: 9px 11px; color: #7a4b00; background: var(--warning-bg); border-left: 3px solid #f5b83d; }
.payload-preview { max-height: 260px; overflow: auto; margin: 0; padding: 12px; color: #d8dee9; background: #1f2937; border-radius: 4px; white-space: pre-wrap; word-break: break-all; }
.detail-list { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px 12px; margin: 0; }
.detail-list dt { color: var(--muted); font-weight: 600; }
.detail-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.sync-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 16px 0; }
.sync-comparison section { min-width: 0; }
.sync-comparison h3, .sync-section h3 { margin: 0 0 10px; font-size: 15px; }
.sync-section { padding-top: 4px; }
.compact-list { margin: 0; padding-left: 20px; display: grid; gap: 5px; }
.warning-list { color: #7a4b00; }
.success-band { padding: 12px; color: #136c4a; background: #e8f7f0; border-left: 3px solid var(--success); }
.pagination { min-height: 54px; padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 12px; border: 1px solid var(--border); border-top: 0; background: var(--surface); }
.pagination .secondary-button { min-height: 36px; }
.confirm-message { margin: 0; color: #344054; white-space: pre-wrap; overflow-wrap: anywhere; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; max-width: 420px; padding: 12px 16px; color: #fff; background: #1f2937; border-radius: 4px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

.login-body { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: #eef1f4; }
.login-panel { width: min(380px, 100%); padding: 32px; border: 1px solid var(--border); border-radius: 6px; background: #fff; box-shadow: 0 10px 30px rgba(16, 24, 40, .08); }
.login-panel h1 { margin: 14px 0 2px; }
.login-panel form { display: flex; flex-direction: column; gap: 8px; margin-top: 24px; }
.login-panel .primary-button { margin-top: 10px; }
.product-mark { width: 40px; height: 40px; font-size: 20px; }
.password-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.form-error { min-height: 21px; margin: 2px 0 0; color: var(--danger); }

@media (max-width: 760px) {
    .sync-comparison { grid-template-columns: 1fr; }
    .topbar { padding: 0 12px; }
    .brand strong { display: none; }
    .app-shell { display: block; }
    .sidebar { display: flex; overflow-x: auto; padding: 8px; }
    .nav-item { min-width: 104px; margin: 0 4px 0 0; text-align: center; }
    .content { padding: 16px 10px; }
    .page-heading, .filter-bar { align-items: stretch; flex-direction: column; }
    .settings-band { align-items: stretch; flex-direction: column; }
    .field.compact { width: 100%; }
    .heading-actions { flex-wrap: wrap; }
    .pagination { justify-content: center; }
}

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