:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-muted: #f7f9fc;
  --ink: #182322;
  --muted: #687674;
  --line: #dfe5ec;
  --line-strong: #c8d2df;
  --teal: #0d5c55;
  --teal-soft: #e3f1ee;
  --blue: #2467a8;
  --blue-soft: #e8f1fa;
  --amber: #a76108;
  --amber-soft: #fff1d8;
  --red: #b23b3b;
  --red-soft: #fbe9e8;
  --green: #287a4d;
  --green-soft: #e4f3ea;
  --shadow: 0 12px 32px rgba(25, 47, 44, 0.12);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); font-size: 14px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
svg { width: 18px; height: 18px; flex: 0 0 auto; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: #175f9f; color: #fff; display: flex; flex-direction: column; padding: 20px 14px 16px; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 24px; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #75a9d6; background: #0e4f89; border-radius: 7px; font-weight: 700; }
.brand strong, .brand span { display: block; }
.brand strong { max-width: 164px; overflow: hidden; font-size: 14px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.brand span { color: #c8dced; font-size: 11px; margin-top: 3px; }
.nav { display: grid; align-content: start; gap: 4px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #76a7d0 transparent; }
.nav-item { width: 100%; min-height: 42px; padding: 0 11px; display: flex; align-items: center; gap: 11px; color: #d4e4f2; background: transparent; border: 0; border-radius: 6px; text-align: left; }
.nav-item:hover { background: rgba(255, 255, 255, .11); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, .2); color: #fff; }
.nav-item b { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; display: grid; place-items: center; background: #b84b43; color: white; border-radius: 10px; font-size: 11px; }
.nav-direct { margin-bottom: 7px; }
.nav-group { display: grid; }
.nav-group-toggle { width: 100%; min-height: 42px; padding: 0 11px; display: flex; align-items: center; gap: 11px; color: #d4e4f2; background: transparent; border: 0; border-radius: 6px; text-align: left; font-weight: 600; }
.nav-group-toggle:hover, .nav-group.current > .nav-group-toggle { color: #fff; background: rgba(255, 255, 255, .1); }
.nav-group-toggle .nav-chevron { width: 15px; height: 15px; margin-left: auto; transition: transform .18s ease; }
.nav-group.open > .nav-group-toggle .nav-chevron { transform: rotate(180deg); }
.nav-submenu { display: none; position: relative; padding: 3px 0 5px 14px; }
.nav-submenu::before { content: ""; position: absolute; top: 4px; bottom: 6px; left: 19px; width: 1px; background: #6f9fca; }
.nav-group.open > .nav-submenu { display: grid; gap: 2px; }
.nav-subitem { min-height: 38px; padding-left: 18px; font-size: 13px; position: relative; }
.nav-subitem svg { width: 16px; height: 16px; }
.mobile-menu-button, .sidebar-close, .sidebar-backdrop { display: none; }
.sidebar-settings { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .2); border-radius: 0 0 6px 6px; }
.sidebar-settings > svg:last-child { width: 15px; height: 15px; margin-left: auto; }

.workspace { min-width: 0; background: #fff; }
.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-heading { display: flex; align-items: center; gap: 10px; min-width: 0; }
.eyebrow { margin: 0 0 3px; color: var(--muted); font-size: 11px; }
h1 { font-size: 20px; margin: 0; letter-spacing: 0; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--blue); font-weight: 700; }
#view { width: min(1540px, 100%); margin: 0 auto; padding: 24px 28px 40px; }

.primary-button, .secondary-button, .danger-button, .text-button, .icon-button { border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; }
.primary-button { min-height: 36px; padding: 0 14px; color: #fff; background: var(--teal); border-radius: 6px; font-weight: 600; }
.primary-button:hover { background: #084a45; }
.secondary-button { min-height: 34px; padding: 0 12px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; }
.secondary-button:hover { border-color: #91aaa5; background: #f7faf9; }
.danger-button { min-height: 34px; padding: 0 12px; color: var(--red); background: #fff; border: 1px solid #e6bdb9; border-radius: 6px; }
.text-button { padding: 4px 2px; color: var(--teal); background: transparent; font-weight: 600; }
.text-button.danger-text { color: var(--red); }
.icon-button { width: 34px; height: 34px; color: #536461; background: transparent; border-radius: 6px; }
.icon-button:hover { background: #eef2f1; }
.small-button { min-height: 28px; padding: 0 9px; font-size: 12px; }

.loading { min-height: 420px; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.loading span { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--teal); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.metric-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); border-radius: 7px; overflow: hidden; }
.metric { padding: 18px 20px; border-right: 1px solid var(--line); min-width: 0; }
.metric:last-child { border-right: 0; }
.metric-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.metric-value { display: block; margin: 9px 0 4px; font-size: 25px; font-weight: 700; line-height: 1; }
.metric-note { color: var(--muted); font-size: 11px; }
.metric-note.good { color: var(--green); }
.metric-note.bad { color: var(--red); }

.alert-band { margin: 16px 0; min-height: 56px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; background: var(--amber-soft); border: 1px solid #efd7ad; border-left: 4px solid var(--amber); border-radius: 6px; }
.alert-band > svg { color: var(--amber); }
.alert-band strong, .alert-band span { display: block; }
.alert-band span { margin-top: 3px; color: #71542d; font-size: 12px; }
.alert-band .text-button { margin-left: auto; color: #78500d; }

.layout-2 { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr); gap: 16px; margin-top: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; min-width: 0; overflow: hidden; }
.panel-header { min-height: 54px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 15px; }
.panel-header p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.panel-body { padding: 16px; }
.panel-toolbar { padding: 12px 14px; display: flex; align-items: center; gap: 9px; border-bottom: 1px solid var(--line); background: var(--surface-muted); }
.panel-toolbar .search { flex: 1; max-width: 340px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { height: 47px; padding: 0 14px; border-bottom: 1px solid #e8edeb; text-align: left; white-space: nowrap; }
th { height: 39px; color: var(--muted); background: var(--surface-muted); font-size: 11px; font-weight: 600; }
tbody tr:hover { background: #fafcfb; }
tbody tr.selected-row, tbody tr.selected-row:hover { background: #eef7f5; }
tbody tr:last-child td { border-bottom: 0; }
.cell-main { font-weight: 600; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.cell-note { display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; }
.muted { color: var(--muted); }
.overdue { color: var(--red); font-weight: 600; }
.selection-cell { width: 44px; min-width: 44px; padding: 0 12px; text-align: center; }
.selection-cell input { width: 16px; height: 16px; margin: 0; accent-color: var(--teal); vertical-align: middle; }
.bulk-toolbar { min-height: 52px; padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); background: #fff; }
.bulk-summary { display: flex; align-items: baseline; gap: 7px; color: var(--muted); font-size: 12px; }
.bulk-summary strong { color: var(--teal); font-size: 18px; font-variant-numeric: tabular-nums; }
.selection-dock-spacer { height: 76px; }
.selection-dock { position: fixed; z-index: 40; left: calc(248px + 24px); right: 24px; bottom: 18px; min-height: 58px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid #a8c5c0; border-radius: 8px; background: #fff; box-shadow: 0 10px 30px rgba(20, 48, 43, .18); }
.selection-dock > div:first-child { display: grid; gap: 3px; }
.selection-dock strong { color: var(--ink); font-size: 14px; }
.selection-dock span { color: var(--muted); font-size: 11px; }
.tag-batch-panel { margin-top: 16px; }
.tag-batch-progress { min-width: 150px; display: grid; grid-template-columns: 44px minmax(90px, 1fr); align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.tag-batch-progress .sync-track { height: 6px; }
.batch-success { color: var(--green); font-weight: 600; }
.batch-error { display: block; max-width: 320px; margin-top: 4px; overflow: hidden; color: var(--red); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.compact-empty { padding: 28px 20px; }
.tag-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.tag-operation-panel { margin-bottom: 16px; }
.tag-operation-body { display: grid; grid-template-columns: minmax(280px, 1fr) auto; align-items: end; gap: 20px; }
.tag-source-control select { max-width: 460px; }
.tag-action-buttons { display: flex; align-items: center; gap: 10px; padding-bottom: 1px; }
.tag-action-buttons button { min-width: 150px; min-height: 40px; }
.tag-remove-button { color: var(--red); border-color: #e6bdb9; }
.tag-directory-panel { margin-bottom: 16px; }
.tag-directory-name { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.tag-directory-name svg { width: 15px; height: 15px; color: var(--blue); }
.settings-form { margin-bottom: 16px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 24px; }
.settings-wide { grid-column: 1 / -1; max-width: 720px; }
.settings-submit { min-height: 62px; padding: 12px 16px; display: flex; align-items: center; justify-content: flex-end; gap: 16px; border-top: 1px solid var(--line); background: var(--surface-muted); }
.settings-submit span { margin-right: auto; color: var(--muted); font-size: 12px; }
.settings-tools { margin-bottom: 16px; }
.settings-tool-list { display: grid; }
.settings-tool-list > button { min-height: 62px; padding: 0 16px; display: flex; align-items: center; gap: 12px; color: var(--ink); background: #fff; border: 0; border-bottom: 1px solid var(--line); text-align: left; }
.settings-tool-list > button:last-child { border-bottom: 0; }
.settings-tool-list > button:hover { background: var(--surface-muted); }
.settings-tool-list > button > svg:first-child { color: var(--blue); }
.settings-tool-list > button > svg:last-child { margin-left: auto; color: var(--muted); }
.settings-tool-list span, .settings-tool-list strong, .settings-tool-list small { display: block; }
.settings-tool-list small { margin-top: 4px; color: var(--muted); }

.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border-radius: 4px; font-size: 11px; background: #edf1f0; color: #56625f; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.teal { background: var(--teal-soft); color: var(--teal); }
.tag-list { display: flex; gap: 5px; flex-wrap: wrap; }
.manager-list { display: flex; flex-wrap: wrap; gap: 5px; max-width: 220px; }
.manager-list span { min-height: 23px; padding: 3px 8px; display: inline-flex; align-items: center; border: 1px solid #b8d1cc; border-radius: 4px; color: var(--teal); background: var(--teal-soft); font-size: 11px; }
.wecom-remark { max-width: 220px; color: var(--teal); overflow-wrap: anywhere; }
.wecom-profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--line); }
.wecom-profile-grid > div { min-width: 0; padding: 9px 11px; display: grid; gap: 3px; background: #fff; }
.wecom-profile-grid span { color: var(--muted); font-size: 11px; }
.wecom-profile-grid strong { color: var(--ink); font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.wecom-profile-summary { margin-bottom: 2px; }
.wecom-follower-profile { overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.wecom-follower-profile + .wecom-follower-profile { margin-top: 9px; }
.wecom-follower-profile > header { min-height: 38px; padding: 7px 11px; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-muted); border-bottom: 1px solid var(--line); }
.wecom-follower-profile > header strong { font-size: 12px; }
.wecom-follower-profile > header span { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.wecom-follower-profile .wecom-profile-grid { border: 0; border-radius: 0; }
.tag-action-list { display: flex; flex-wrap: wrap; gap: 8px; min-height: 32px; align-items: center; }
.tag-action { min-height: 32px; display: inline-flex; align-items: center; gap: 5px; padding: 0 10px; border-radius: 5px; background: #fff; font-size: 12px; }
.tag-action.add { color: var(--teal); border: 1px solid #9fc8c2; }
.tag-action.remove { color: var(--red); border: 1px solid #e6bdb9; }
.tag-action:hover { background: var(--surface-muted); }
.tag-action svg { width: 14px; height: 14px; }
.filter-bar { justify-content: flex-start; flex-wrap: wrap; }
.filter-bar .search { flex: 1 1 280px; }
.filter-bar select { min-height: 34px; min-width: 128px; padding: 0 30px 0 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; }
.campaign-list { display: grid; }
.campaign-row { min-height: 104px; display: grid; grid-template-columns: 76px minmax(220px, 1fr) 110px 100px; align-items: center; gap: 18px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.campaign-row:last-child { border-bottom: 0; }
.campaign-qr { width: 72px; height: 72px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.campaign-qr img { width: 100%; height: 100%; object-fit: contain; }
.campaign-qr svg { width: 30px; height: 30px; color: var(--muted); }
.campaign-main strong, .campaign-main span { display: block; }
.campaign-main span { margin-top: 5px; color: var(--muted); font-size: 12px; }
.metric-inline { min-height: 66px; display: grid; grid-template-columns: auto 1fr auto 1fr; align-items: baseline; gap: 6px 10px; }
.metric-inline strong { font-size: 24px; color: var(--teal); }
.metric-inline span { color: var(--muted); }

.funnel { display: grid; gap: 15px; }
.funnel-row { display: grid; grid-template-columns: 92px minmax(90px, 1fr) 70px; gap: 10px; align-items: center; font-size: 12px; }
.bar-track { height: 9px; background: #e9eeec; border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--teal); border-radius: inherit; }
.bar-fill.blue { background: var(--blue); }
.bar-fill.amber { background: #c98222; }
.funnel-row strong { text-align: right; font-variant-numeric: tabular-nums; }

.trend { height: 180px; display: grid; grid-template-columns: repeat(6, 1fr); align-items: end; gap: 12px; padding-top: 16px; }
.trend-item { height: 100%; display: grid; grid-template-rows: 1fr auto; align-items: end; gap: 8px; color: var(--muted); font-size: 11px; text-align: center; }
.trend-bar { min-height: 22px; position: relative; background: #8ab9b1; border-radius: 4px 4px 2px 2px; }
.trend-item:last-child .trend-bar { background: var(--teal); }
.trend-bar span { position: absolute; left: 50%; top: -20px; transform: translateX(-50%); color: var(--ink); font-size: 10px; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.page-heading .row-actions { flex-wrap: wrap; }
.page-heading h2 { margin: 0; font-size: 18px; }
.page-heading p { margin: 6px 0 0; color: var(--muted); }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; height: 34px; padding: 0 10px 0 34px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; outline: none; }
.search input:focus, input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13, 92, 85, .1); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); background: #eef2f1; border-radius: 6px; }
.segmented button { min-height: 28px; padding: 0 10px; border: 0; background: transparent; color: var(--muted); border-radius: 4px; font-size: 12px; }
.segmented button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(15, 42, 37, .12); }

.entity-list, .employee-list { display: grid; gap: 10px; }
.entity-row, .employee-row { min-height: 76px; display: grid; grid-template-columns: minmax(220px, 1fr) 130px 160px auto; align-items: center; gap: 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.entity-name, .employee-name { display: flex; align-items: center; gap: 11px; min-width: 0; }
.entity-icon, .employee-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--teal); background: var(--teal-soft); border-radius: 6px; }
.entity-name strong, .entity-name span, .employee-name strong, .employee-name span { display: block; overflow: hidden; text-overflow: ellipsis; }
.entity-name span, .employee-name span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.entity-stat strong, .entity-stat span { display: block; }
.entity-stat span { color: var(--muted); font-size: 11px; margin-top: 4px; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.sync-progress { grid-column: 1 / -1; padding-top: 11px; border-top: 1px solid var(--line); }
.sync-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; font-size: 11px; color: var(--muted); }
.sync-progress-head > div { display: flex; align-items: center; gap: 9px; min-width: 0; }
.sync-progress-head strong { display: flex; align-items: center; gap: 6px; color: var(--ink); white-space: nowrap; }
.sync-progress-head span { overflow-wrap: anywhere; }
.sync-track { height: 8px; overflow: hidden; border-radius: 4px; background: #e8eeec; }
.sync-track span { display: block; height: 100%; border-radius: inherit; background: var(--blue); transition: width .25s ease; }
.sync-warning, .sync-error { margin-top: 7px; font-size: 11px; }
.sync-warning { color: var(--amber); }
.sync-error { overflow: hidden; color: var(--red); text-overflow: ellipsis; white-space: nowrap; }
.spin-icon { animation: spin 1s linear infinite; }

.rule-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.rule-item { padding: 15px; border: 1px solid var(--line); border-radius: 6px; }
.rule-item header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rule-item h3 { margin: 0; font-size: 13px; }
.rule-item strong { display: block; margin-top: 18px; font-size: 22px; }
.rule-item p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

.modal-layer[hidden] { display: none; }
.modal-layer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16, 29, 27, .48); }
.modal { position: relative; width: min(560px, 100%); max-height: min(760px, calc(100vh - 40px)); overflow: auto; background: #fff; border-radius: 8px; box-shadow: var(--shadow); }
.modal > header { position: sticky; top: 0; min-height: 58px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); z-index: 2; }
.modal h2 { margin: 0; font-size: 16px; }
.modal-form { padding: 18px; display: grid; gap: 14px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #4d5d5a; font-size: 12px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; outline: 0; }
.field textarea { min-height: 80px; resize: vertical; }
.field small { color: var(--muted); line-height: 1.5; }
.batch-operation { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #eef2f1; }
.batch-operation label { position: relative; cursor: pointer; }
.batch-operation input { position: absolute; opacity: 0; pointer-events: none; }
.batch-operation span { min-height: 34px; display: flex; align-items: center; justify-content: center; gap: 7px; border-radius: 4px; color: var(--muted); font-weight: 600; }
.batch-operation input:checked + span { color: var(--teal); background: #fff; box-shadow: 0 1px 3px rgba(15, 42, 37, .12); }
.batch-operation input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: 1px; }
.batch-operation svg { width: 16px; height: 16px; }
.source-operation { grid-template-columns: repeat(3, 1fr); }
.source-operation input:disabled + span { cursor: not-allowed; opacity: .45; }
.tag-source-panel { display: grid; gap: 10px; }
.tag-import-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; }
.tag-import-divider::before, .tag-import-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.tag-search input { min-height: 36px; }
.tag-choice-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.tag-choice-group { padding: 10px 11px; border-bottom: 1px solid var(--line); }
.tag-choice-group:last-child { border-bottom: 0; }
.tag-choice-group h3 { margin: 0 0 8px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tag-choice-group > div { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-choice { position: relative; cursor: pointer; }
.tag-choice input { position: absolute; opacity: 0; pointer-events: none; }
.tag-choice span { min-height: 31px; padding: 0 9px; display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-strong); border-radius: 5px; color: #50615e; background: #fff; font-size: 12px; }
.tag-choice span svg { width: 14px; height: 14px; }
.tag-choice input:checked + span { border-color: #65a49b; color: var(--teal); background: var(--teal-soft); box-shadow: inset 0 0 0 1px #65a49b; }
.tag-choice input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: 2px; }
.tag-preview-actions { display: flex; align-items: center; gap: 10px; }
.tag-preview-actions span { color: var(--muted); font-size: 11px; }
.tag-preview { min-height: 74px; padding: 12px; display: grid; align-content: center; gap: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-muted); }
.tag-preview-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tag-preview-grid > div { min-width: 0; padding-right: 8px; border-right: 1px solid var(--line); }
.tag-preview-grid > div:last-child { border-right: 0; }
.tag-preview-grid strong, .tag-preview-grid span { display: block; }
.tag-preview-grid strong { color: var(--teal); font-size: 18px; font-variant-numeric: tabular-nums; }
.tag-preview-grid span { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.tag-preview-grid .preview-warning strong { color: var(--red); }
.tag-preview-lines { display: grid; gap: 4px; color: #52635f; font-size: 11px; line-height: 1.5; }
.large-batch-confirm { min-height: 40px; padding: 9px 11px; display: flex; align-items: center; gap: 9px; border: 1px solid #e2bd80; border-radius: 6px; color: #71542d; background: var(--amber-soft); font-size: 12px; cursor: pointer; }
.large-batch-confirm input { width: 17px; height: 17px; margin: 0; accent-color: var(--amber); }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 6px; }
.info-box { padding: 12px 13px; border: 1px solid #bcd4e8; border-radius: 6px; color: #315d7d; background: var(--blue-soft); font-size: 12px; line-height: 1.7; }
.warning-box { padding: 12px 13px; border: 1px solid #efd7ad; border-radius: 6px; color: #71542d; background: var(--amber-soft); font-size: 12px; line-height: 1.7; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 200; min-width: 240px; max-width: 420px; padding: 12px 14px; color: white; background: #173d37; border-radius: 6px; 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: #8f3434; }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 28px; height: 28px; display: block; margin: 0 auto 10px; }

.message-feed { display: grid; }
.message-feed-row { min-height: 64px; padding: 10px 16px; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 11px; color: inherit; background: #fff; border: 0; border-bottom: 1px solid var(--line); text-align: left; }
.message-feed-row:last-child { border-bottom: 0; }
.message-feed-row:hover { background: var(--surface-muted); }
.feed-avatar, .conversation-avatar { width: 36px; height: 36px; position: relative; display: grid; place-items: center; border-radius: 6px; color: var(--teal); background: var(--teal-soft); font-weight: 700; }
.feed-main { min-width: 0; }
.feed-main strong, .feed-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-main strong { font-size: 13px; }
.feed-main small { color: var(--muted); font-size: 11px; font-weight: 400; }
.feed-main span, .message-feed-row time { margin-top: 4px; color: var(--muted); font-size: 11px; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-actions button { min-height: 68px; padding: 10px 12px; display: grid; grid-template-columns: 32px minmax(0, 1fr) 18px; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; text-align: left; }
.quick-actions button:hover { border-color: #91aaa5; background: var(--surface-muted); }
.quick-actions button > svg:first-child { color: var(--teal); }
.quick-actions button > svg:last-child { width: 15px; color: var(--muted); }
.quick-actions strong, .quick-actions small { display: block; }
.quick-actions small { margin-top: 4px; color: var(--muted); font-size: 10px; }

.conversation-shell { height: calc(100vh - 150px); min-height: 620px; display: grid; grid-template-columns: 340px minmax(0, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.conversation-sidebar { min-width: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); border-right: 1px solid var(--line); background: var(--surface-muted); }
.conversation-filters { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); background: #fff; }
.conversation-filters > div:last-child { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.conversation-filters select { width: 100%; min-width: 0; }
.conversation-list { min-height: 0; overflow-y: auto; }
.conversation-loading { min-height: 220px; }
.conversation-item { width: 100%; min-height: 74px; padding: 11px 12px; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 10px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; }
.conversation-item:hover { background: #fff; }
.conversation-item.active { background: #eaf3f1; box-shadow: inset 3px 0 0 var(--teal); }
.presence { width: 10px; height: 10px; position: absolute; right: -3px; bottom: -3px; border: 2px solid #fff; border-radius: 50%; background: #9ca8a5; }
.presence.online { background: #34a66b; }
.conversation-item-main { min-width: 0; }
.conversation-item-main strong, .conversation-item-main > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item-main strong { font-size: 13px; }
.conversation-item-main small { margin-left: 5px; color: var(--muted); font-size: 10px; font-weight: 400; }
.conversation-item-main > span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.conversation-item-side { min-width: 42px; align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; }
.conversation-item-side time { color: var(--muted); font-size: 9px; }
.conversation-item-side b { min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--red); font-size: 10px; }
.conversation-detail { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr); background: #f5f7f6; }
.conversation-detail-head { min-height: 66px; padding: 10px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); background: #fff; }
.conversation-detail-head > div:last-child { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.conversation-detail-head strong, .conversation-detail-head span { display: block; }
.conversation-detail-head > div:first-child span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.conversation-notice { min-height: 34px; padding: 7px 14px; display: flex; align-items: center; justify-content: center; gap: 7px; border-bottom: 1px solid #d8e4e1; color: #56706b; background: #edf4f2; font-size: 10px; }
.conversation-notice svg { width: 14px; }
.message-history { min-height: 0; padding: 18px 22px; overflow-y: auto; }
.message-row { display: flex; margin: 10px 0; }
.message-row.employee { justify-content: flex-end; }
.message-row.customer { justify-content: flex-start; }
.message-bubble { width: fit-content; max-width: min(72%, 680px); padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: 0 1px 2px rgba(25, 47, 44, .04); }
.message-row.employee .message-bubble { border-color: #a9cec7; background: #e3f1ee; }
.message-bubble > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.message-bubble strong { font-size: 11px; }
.message-bubble time { color: var(--muted); font-size: 9px; white-space: nowrap; }
.message-bubble p { margin: 7px 0 0; line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; }
.message-type { display: block; margin-top: 6px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.system-message { margin: 12px auto; color: var(--muted); font-size: 10px; text-align: center; }
.system-message time { margin-left: 6px; }
.older-messages { min-height: 30px; margin: 0 auto 14px; padding: 0 10px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 5px; color: var(--teal); background: #fff; font-size: 11px; }
.conversation-empty { min-height: 100%; padding: 30px; display: grid; place-content: center; justify-items: center; gap: 9px; color: var(--muted); text-align: center; }
.conversation-empty > svg { width: 34px; height: 34px; margin-bottom: 4px; }
.conversation-empty strong { color: var(--ink); font-size: 15px; }
.conversation-empty span { max-width: 440px; line-height: 1.7; }
.conversation-empty button { margin-top: 8px; }

.account-status-grid { display: grid; }
.account-status-row { min-height: 66px; padding: 10px 16px; display: grid; grid-template-columns: 38px minmax(180px, 1fr) minmax(140px, .7fr) 90px 110px; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.account-status-row:last-child { border-bottom: 0; }
.account-status-row strong, .account-status-row span { display: block; }
.account-status-row span, .account-status-row time { margin-top: 4px; color: var(--muted); font-size: 10px; }

.auth-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(260px, .7fr) minmax(420px, 1.3fr); background: #175f9f; }
.auth-brand { padding: 46px; display: flex; align-items: flex-start; gap: 13px; color: #fff; }
.auth-brand .brand-mark { width: 42px; height: 42px; }
.auth-brand strong, .auth-brand span { display: block; }
.auth-brand strong { font-size: 18px; }
.auth-brand span { margin-top: 5px; color: #c8dced; font-size: 12px; }
.auth-panel { width: min(520px, calc(100% - 40px)); margin: auto; padding: 38px; display: grid; gap: 18px; background: #fff; border-radius: 8px; box-shadow: var(--shadow); }
.auth-panel h1 { font-size: 26px; }
.auth-copy { margin: -8px 0 4px; color: var(--muted); line-height: 1.7; }
#auth-fields { display: grid; gap: 14px; }
.auth-submit { width: 100%; height: 42px; }
.auth-switch { justify-self: center; min-height: 30px; }
.auth-foot { margin: 4px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

@media (max-width: 1100px) {
  .metric-strip { grid-template-columns: repeat(3, 1fr); }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(3) { border-right: 0; }
  .layout-2 { grid-template-columns: 1fr; }
  .rule-grid { grid-template-columns: 1fr; }
  .entity-row, .employee-row { grid-template-columns: minmax(220px, 1fr) 120px auto; }
  .entity-row > :nth-child(3), .employee-row > :nth-child(3) { display: none; }
  .conversation-shell { grid-template-columns: 300px minmax(0, 1fr); }
  .account-status-row { grid-template-columns: 38px minmax(180px, 1fr) 110px 100px; }
  .account-status-row > :nth-child(3) { display: none; }
}

@media (max-width: 760px) {
  .campaign-row { grid-template-columns: 64px minmax(0, 1fr); }
  .campaign-row .entity-stat, .campaign-row > :last-child { grid-column: 2; text-align: left; }
  .auth-screen { display: block; padding: 24px 0; }
  .auth-brand { padding: 10px 22px 30px; }
  .auth-panel { padding: 26px 20px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: min(286px, 86vw); height: 100vh; padding: 18px 14px 16px; border-right: 1px solid #0f4e86; transform: translateX(-102%); transition: transform .2s ease; box-shadow: 14px 0 38px rgba(6, 30, 54, .24); }
  .sidebar.open { transform: translateX(0); }
  .brand { display: flex; padding-bottom: 20px; }
  .brand > div:nth-child(2) { min-width: 0; }
  .sidebar-close { display: inline-flex; margin-left: auto; color: #d4e4f2; }
  .sidebar-close:hover { color: #fff; background: rgba(255, 255, 255, .11); }
  .nav { height: auto; display: grid; gap: 4px; overflow-y: auto; }
  .nav-item { min-width: 0; min-height: 42px; padding: 0 11px; display: flex; place-items: initial; align-content: initial; gap: 11px; font-size: 13px; }
  .nav-item svg { width: 16px; height: 16px; }
  .nav-item b { display: grid; }
  .sidebar-backdrop { position: fixed; z-index: 55; inset: 0; display: block; width: 100%; height: 100%; padding: 0; border: 0; background: rgba(6, 30, 54, .48); }
  .mobile-menu-button { display: inline-flex; flex: 0 0 auto; margin-left: -6px; }
  body.mobile-nav-open { overflow: hidden; }
  .topbar { height: 66px; padding: 0 14px; }
  .top-actions .primary-button { width: 34px; padding: 0; font-size: 0; }
  #view { padding: 15px 12px 28px; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .metric { padding: 14px; }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-child(3) { border-right: 1px solid var(--line); }
  .metric-value { font-size: 21px; }
  .alert-band { align-items: flex-start; }
  .alert-band .text-button { display: none; }
  .panel-toolbar, .page-heading { align-items: stretch; flex-direction: column; }
  .panel-toolbar .search { flex: none; max-width: none; width: 100%; }
  .bulk-toolbar { align-items: stretch; flex-direction: column; }
  .bulk-toolbar .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .selection-dock { left: 12px; right: 12px; bottom: 74px; padding: 9px 11px; }
  .selection-dock .row-actions { flex: 0 0 auto; }
  .selection-dock .secondary-button { width: 34px; padding: 0; font-size: 0; }
  .source-operation { grid-template-columns: 1fr; }
  .tag-preview-grid { grid-template-columns: 1fr 1fr; }
  .tag-preview-grid > div:nth-child(2) { border-right: 0; }
  .tag-preview-grid > div { padding: 6px; border-bottom: 1px solid var(--line); }
  .tag-preview-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
  .tag-preview-actions { align-items: flex-start; flex-direction: column; }
  .entity-row, .employee-row { grid-template-columns: 1fr auto; gap: 10px; }
  .entity-stat { display: none; }
  .sync-progress-head { align-items: flex-start; flex-direction: column; gap: 5px; }
  .quick-actions { grid-template-columns: 1fr; }
  .tag-metrics { grid-template-columns: 1fr 1fr; }
  .tag-operation-body, .settings-grid { grid-template-columns: 1fr; }
  .settings-wide { grid-column: auto; }
  .tag-action-buttons { align-items: stretch; flex-direction: column; }
  .tag-action-buttons button { width: 100%; }
  .conversation-shell { height: calc(100vh - 160px); min-height: 650px; grid-template-columns: 1fr; grid-template-rows: 260px minmax(0, 1fr); }
  .conversation-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .conversation-detail-head { padding: 9px 12px; align-items: flex-start; flex-direction: column; gap: 6px; }
  .message-history { padding: 12px; }
  .message-bubble { max-width: 88%; }
  .account-status-row { grid-template-columns: 38px minmax(0, 1fr) auto; }
  .account-status-row > :nth-child(3), .account-status-row > :last-child { display: none; }
  .field-grid { grid-template-columns: 1fr; }
  .wecom-profile-grid { grid-template-columns: 1fr; }
  .modal-layer { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: 90vh; border-radius: 8px 8px 0 0; }
}
