:root {
  --ink: #17221c;
  --muted: #6f7973;
  --line: #e0e6e2;
  --bg: #f5f7f6;
  --white: #fff;
  --green: #23724c;
  --green-bright: #36a56f;
  --green-soft: #e7f3ec;
  --nav: #13231b;
  --red: #c94d50;
  --amber: #a86e14;
  --blue: #3677a1;
  --shadow: 0 10px 30px rgba(22, 45, 31, .07);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif; letter-spacing: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #edf3ef; }
.login-panel { width: min(410px, 100%); background: white; padding: 38px; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 24px 70px rgba(23, 50, 33, .12); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 44px; }
.login-brand > span, .side-brand > span { width: 42px; height: 42px; display: grid; place-items: center; background: var(--green); color: white; border-radius: 7px; font-family: SimSun, serif; font-size: 21px; }
.login-brand strong, .login-brand small, .side-brand strong, .side-brand small { display: block; }
.login-brand strong { font-size: 16px; }
.login-brand small, .side-brand small { color: var(--muted); font-size: 9px; margin-top: 4px; letter-spacing: 1px; }
.login-panel h1 { margin: 0 0 26px; font-size: 25px; }
.login-panel label { display: block; margin-bottom: 17px; }
.login-panel label span { display: block; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.login-panel input { width: 100%; height: 46px; padding: 0 12px; border: 1px solid #cbd4ce; border-radius: 6px; outline: none; }
.login-panel input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(35,114,76,.1); }
.login-panel button { width: 100%; height: 48px; border: 0; border-radius: 6px; background: var(--green); color: white; font-weight: 700; margin-top: 5px; }
.login-panel button:hover { background: #1d603f; }
.login-error { min-height: 19px; color: var(--red); font-size: 12px; text-align: center; }
.login-tip { color: var(--muted); background: var(--bg); border-radius: 6px; padding: 10px; font-size: 11px; text-align: center; margin: 17px 0 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { background: var(--nav); color: white; position: fixed; inset: 0 auto 0 0; width: 244px; display: flex; flex-direction: column; z-index: 30; }
.side-brand { height: 82px; padding: 0 20px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-brand > span { background: #2f8258; }
.side-brand small { color: rgba(255,255,255,.42); }
.sidebar nav { padding: 20px 12px; display: grid; gap: 5px; }
.sidebar nav button { border: 0; border-radius: 6px; background: transparent; color: rgba(255,255,255,.62); min-height: 46px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; text-align: left; padding: 0 13px; font-size: 13px; transition: color .15s, background .15s; }
.sidebar nav button i { width: 22px; height: 22px; display: grid; place-items: center; font-style: normal; font-size: 15px; color: rgba(255,255,255,.46); }
.sidebar nav button b { min-width: 23px; height: 20px; padding: 0 6px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.1); font-size: 10px; }
.sidebar nav button:hover { background: rgba(255,255,255,.06); color: white; }
.sidebar nav button.active { background: #244c37; color: white; font-weight: 700; }
.sidebar nav button.active i { color: #78d4a2; }
.side-user { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding: 16px; display: grid; grid-template-columns: 38px 1fr 32px; gap: 10px; align-items: center; }
.avatar { width: 38px; height: 38px; border-radius: 6px; display: grid; place-items: center; background: #e5b95e; color: #17211b; font-weight: 800; }
.side-user strong, .side-user small { display: block; }
.side-user strong { font-size: 12px; }
.side-user small { color: rgba(255,255,255,.45); font-size: 10px; margin-top: 4px; }
.side-user button { width: 32px; height: 32px; color: rgba(255,255,255,.6); border: 0; background: transparent; font-size: 17px; }

.workspace { grid-column: 2; min-width: 0; }
.workspace-header { height: 82px; padding: 0 30px; display: flex; align-items: center; gap: 16px; justify-content: space-between; background: rgba(245,247,246,.96); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 15; }
.workspace-header > div:first-of-type { margin-right: auto; }
.workspace-header p { color: var(--green); margin: 0 0 4px; font-size: 10px; font-weight: 800; letter-spacing: 1px; }
.workspace-header h1 { margin: 0; font-size: 22px; }
.header-actions { display: flex; gap: 8px; }
.header-actions a, .header-actions button, .secondary-button { min-height: 38px; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--ink); padding: 0 13px; text-decoration: none; font-size: 12px; }
.header-actions a:hover, .header-actions button:hover { border-color: var(--green); color: var(--green); }
.menu-button { display: none; border: 0; background: transparent; font-size: 20px; }
#view-root { padding: 28px 30px 48px; outline: none; max-width: 1560px; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric { min-height: 116px; padding: 20px; background: white; border: 1px solid var(--line); border-radius: 8px; position: relative; overflow: hidden; }
.metric::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: #bdc8c0; }
.metric:nth-child(2)::after { background: #d5a84e; }
.metric:nth-child(3)::after, .metric:nth-child(5)::after { background: var(--green-bright); }
.metric:nth-child(4)::after { background: #5c8fb0; }
.metric span { color: var(--muted); font-size: 11px; }
.metric strong { display: block; font-size: 28px; margin-top: 16px; white-space: nowrap; }
.metric strong.money { font-size: 22px; color: var(--green); }
.dashboard-layout { display: grid; grid-template-columns: 1.05fr .75fr; gap: 16px; }
.panel { background: white; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: 0 1px 2px rgba(22,45,31,.02); }
.panel-header { min-height: 58px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-header h2 { font-size: 14px; margin: 0; }
.panel-header small { color: var(--muted); font-size: 10px; }
.breakdown { padding: 18px; }
.bar-row { display: grid; grid-template-columns: 94px 1fr 32px; gap: 10px; align-items: center; margin: 13px 0; font-size: 11px; }
.bar-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 7px; border-radius: 4px; background: #edf1ee; overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 4px; background: var(--green-bright); }
.status-grid { padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.status-item { padding: 13px 14px; border: 1px solid #edf0ee; border-radius: 6px; background: #fafbfa; display: flex; justify-content: space-between; align-items: center; }
.status-item span { color: var(--muted); font-size: 11px; }
.status-item strong { font-size: 18px; }
.recent-list { grid-column: 1 / -1; }

.toolbar { display: flex; flex-wrap: wrap; gap: 9px; padding: 13px; background: white; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; }
.toolbar input, .toolbar select { height: 38px; border: 1px solid #d2d9d4; border-radius: 6px; background: #fafbfa; padding: 0 10px; min-width: 130px; outline: none; font-size: 12px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--green); background: white; }
.toolbar .search { min-width: 240px; flex: 1; }
.toolbar button, .primary-button, .action-button { border: 0; border-radius: 6px; background: var(--green); color: white; min-height: 38px; padding: 0 15px; font-weight: 700; font-size: 12px; }
.toolbar button:hover, .primary-button:hover { background: #1d603f; }
.toolbar .secondary { background: white; color: var(--ink); border: 1px solid var(--line); }
.batch-toolbar { min-height: 54px; display: flex; flex-wrap: wrap; align-items: center; gap: 9px; padding: 9px 12px; margin-bottom: 10px; border: 1px solid #b9d7c5; border-radius: 8px; background: #f0f8f3; }
.batch-toolbar strong { color: var(--green); font-size: 12px; margin-right: auto; }
.batch-toolbar select { height: 36px; min-width: 130px; border: 1px solid #cbd7cf; border-radius: 5px; background: white; padding: 0 8px; font-size: 11px; }
.batch-toolbar .primary-button { min-height: 36px; }
.table-wrap { overflow: auto; background: white; }
.toolbar + .table-wrap { border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { color: #748078; text-align: left; font-weight: 700; background: #fafbfa; white-space: nowrap; }
th, td { padding: 12px 11px; border-bottom: 1px solid #e8ece9; vertical-align: middle; }
.select-cell { width: 42px; text-align: center; }
.select-cell input { width: 16px; height: 16px; accent-color: var(--green); }
tbody tr { transition: background .15s; }
tbody tr:hover { background: #f9fbfa; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { color: var(--muted); margin-top: 4px; }
.nowrap { white-space: nowrap; }
.cell-input { width: 72px; height: 34px; border: 1px solid #d2d9d4; border-radius: 5px; padding: 0 7px; background: #fafbfa; }
.amount-input { width: 88px; }
.cell-select { height: 34px; border: 1px solid #d2d9d4; border-radius: 5px; padding: 0 6px; background: #fafbfa; min-width: 94px; }
.tiny-button { min-height: 33px; padding: 0 10px; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--ink); font-size: 11px; white-space: nowrap; }
.tiny-button.save { border-color: #acd0ba; color: var(--green); background: #f6fbf8; }
.tiny-button:hover { background: var(--green-soft); }
.tiny-button:disabled { opacity: .45; cursor: default; }
.status-badge, .role-badge, .callback-state { display: inline-flex; min-height: 25px; align-items: center; padding: 0 9px; border-radius: 12px; background: #edf1ee; color: #445149; white-space: nowrap; }
.status-confirmed, .callback-delivered { color: var(--green); background: var(--green-soft); }
.status-wrong_phone, .status-rejected, .status-cancelled, .callback-failed { color: var(--red); background: #f9e9e9; }
.status-contacting, .callback-retrying { color: var(--blue); background: #e8f1f7; }
.status-no_answer, .callback-waiting_config { color: var(--amber); background: #f8f0df; }
.duplicate-badge { display: inline-flex; margin-left: 5px; padding: 2px 6px; border-radius: 9px; background: #f8f0df; color: var(--amber); font-size: 9px; font-weight: 700; vertical-align: middle; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }

.section-tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.section-tabs button { border: 0; background: transparent; padding: 11px 18px; color: var(--muted); border-bottom: 2px solid transparent; }
.section-tabs button.active { color: var(--green); border-color: var(--green); font-weight: 700; }
.form-panel { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 22px; margin-bottom: 16px; }
.form-panel h2 { font-size: 16px; margin: 0 0 6px; }
.form-panel > p { color: var(--muted); font-size: 11px; margin: 0 0 20px; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(200px, 1fr)); }
.form-grid label, .dialog-grid label { display: block; }
.form-grid label > span, .dialog-grid label > span { display: block; font-size: 11px; font-weight: 700; margin-bottom: 7px; }
.form-grid input, .form-grid select, .dialog-grid input, .dialog-grid select, .dialog-grid textarea { width: 100%; min-height: 40px; border: 1px solid #d2d9d4; border-radius: 6px; background: #fafbfa; padding: 8px 10px; outline: none; }
.form-grid input:focus, .dialog-grid input:focus, .dialog-grid textarea:focus, .form-grid select:focus { border-color: var(--green); background: white; box-shadow: 0 0 0 3px rgba(35,114,76,.08); }
.form-grid .full, .dialog-grid .full { grid-column: 1 / -1; }
.inline-toggle { display: flex !important; align-items: center; gap: 8px; min-height: 40px; }
.inline-toggle input { width: 18px; height: 18px; min-height: 0; accent-color: var(--green); }
.inline-toggle span { margin: 0 !important; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.hint { color: var(--muted); font-size: 10px; line-height: 1.7; margin: 8px 0 0; }
.danger-text { color: var(--red); }

dialog { border: 0; border-radius: 8px; padding: 0; width: min(720px, calc(100% - 28px)); max-height: calc(100vh - 32px); box-shadow: 0 30px 90px rgba(0,0,0,.24); }
dialog::backdrop { background: rgba(14, 25, 18, .55); }
.dialog-shell > header, .dialog-shell > footer { min-height: 70px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-shell > footer { border: 0; border-top: 1px solid var(--line); justify-content: flex-end; gap: 9px; }
.dialog-shell h2 { margin: 3px 0 0; font-size: 18px; }
.dialog-shell header small { color: var(--muted); }
.icon-button { border: 0; background: transparent; font-size: 26px; color: var(--muted); }
.dialog-body { padding: 22px; max-height: calc(100vh - 180px); overflow: auto; }
.dialog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dialog-grid textarea { min-height: 90px; resize: vertical; }
.contact-section { margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.contact-heading strong, .contact-heading small { display: block; }
.contact-heading strong { font-size: 13px; }
.contact-heading small { color: var(--muted); font-size: 10px; margin-top: 4px; }
.contact-composer { display: grid; grid-template-columns: 130px 1fr auto; gap: 8px; margin: 14px 0 18px; }
.contact-composer select, .contact-composer input { min-height: 38px; border: 1px solid #d2d9d4; border-radius: 6px; background: #fafbfa; padding: 0 9px; font-size: 11px; }
.contact-composer .primary-button { min-height: 38px; }
.contact-timeline { display: grid; gap: 0; }
.contact-item { display: grid; grid-template-columns: 16px 1fr; gap: 9px; position: relative; padding-bottom: 16px; }
.contact-item::before { content: ""; position: absolute; left: 5px; top: 10px; bottom: 0; width: 1px; background: var(--line); }
.contact-item:last-child::before { display: none; }
.contact-dot { width: 11px; height: 11px; margin-top: 3px; border: 3px solid #c5e2d1; border-radius: 50%; background: var(--green); position: relative; z-index: 1; }
.contact-item strong, .contact-item small { display: block; }
.contact-item strong { font-size: 11px; }
.contact-item small { color: var(--muted); font-size: 9px; margin-top: 3px; }
.contact-item p { margin: 6px 0 0; color: #4d5a52; font-size: 11px; line-height: 1.6; }
.contact-empty { color: var(--muted); font-size: 11px; padding: 12px 0; }
.secondary-button, .primary-button { min-height: 39px; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; }
.toast { width: min(340px, calc(100vw - 40px)); border-radius: 6px; background: var(--nav); color: white; padding: 13px 16px; box-shadow: var(--shadow); font-size: 12px; }
.toast.error { background: #9e282e; }
.loading-block { min-height: 300px; display: grid; place-items: center; color: var(--muted); }
.audit-detail { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-layout { grid-template-columns: 1fr; }
  .recent-list { grid-column: auto; }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 12px 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .workspace { width: 100%; }
  .workspace-header { height: 70px; padding: 0 14px; }
  .menu-button { display: block; }
  .workspace-header p { display: none; }
  .workspace-header h1 { font-size: 18px; }
  .header-actions a { display: none; }
  .header-actions button { padding: 0 10px; }
  #view-root { padding: 16px 12px 36px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric { min-height: 94px; padding: 15px; }
  .metric:last-child { grid-column: 1 / -1; }
  .metric strong { font-size: 23px; margin-top: 12px; }
  .form-grid, .form-grid.two { grid-template-columns: 1fr; }
  .toolbar .search { min-width: 100%; }
  .toolbar input, .toolbar select { flex: 1; min-width: 110px; }
  .dialog-grid { grid-template-columns: 1fr; }
  .contact-composer { grid-template-columns: 1fr; }
  .login-panel { padding: 28px 22px; }
}
