:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #2563eb;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .05);
  --shadow-lg: 0 16px 48px rgba(15, 23, 42, .18);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
svg.ic { vertical-align: -3px; flex-shrink: 0; }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, #1e3a8a 0%, transparent 60%), linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%); }
.login-card { background: #fff; padding: 40px 36px; border-radius: 18px; width: 400px; max-width: 100%; box-shadow: 0 24px 70px rgba(0, 0, 0, .35); }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 26px; }
.login-card .field { margin-bottom: 16px; }
.login-card input { width: 100%; padding: 12px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.login-card button { width: 100%; padding: 12px; background: linear-gradient(180deg, #3b82f6, var(--primary)); color: #fff; border: none; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; box-shadow: 0 6px 18px rgba(37, 99, 235, .3); transition: filter .15s, transform .05s; }
.login-card button:hover { filter: brightness(1.05); }
.login-card button:active { transform: translateY(1px); }
.login-err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- 主布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 232px; background: linear-gradient(180deg, #0f172a 0%, #172554 55%, #1e3a8a 100%); color: var(--sidebar-text); flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar .brand { padding: 22px 20px 18px; font-size: 17px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255, 255, 255, .08); letter-spacing: .3px; }
.sidebar .brand small { display: block; font-weight: 400; font-size: 11px; color: #94a3b8; margin-top: 3px; letter-spacing: .4px; }
.sidebar nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar .nav-group { padding: 14px 20px 6px; font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: .8px; }
.sidebar a.nav { display: flex; align-items: center; gap: 11px; padding: 9px 20px; margin: 1px 10px; color: var(--sidebar-text); cursor: pointer; border-radius: 9px; font-size: 14px; transition: background .12s, color .12s; }
.sidebar a.nav:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar a.nav.active { background: linear-gradient(90deg, var(--sidebar-active), #3b82f6); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .4); }
.sidebar .foot { padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; color: #94a3b8; }
.sidebar .foot strong { color: #e2e8f0; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--card); padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm); position: relative; z-index: 20; }
.topbar h2 { font-size: 17px; white-space: nowrap; }
.topbar .userbox { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.topbar .role-badge { background: #eef2ff; color: var(--primary); padding: 3px 11px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.topbar button.link { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.topbar button.link:hover { color: var(--danger); }
.content { padding: 24px; overflow-y: auto; flex: 1; }

/* ---------- 顶栏全局搜索 ---------- */
.gsearch { position: relative; flex: 1; max-width: 440px; margin: 0 auto; }
.gsearch-box { display: flex; align-items: center; gap: 9px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; height: 38px; transition: background .15s, border-color .15s, box-shadow .15s; }
.gsearch-box:focus-within { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.gsearch-box .ic { color: var(--muted); }
.gsearch-box input { flex: 1; border: none; background: transparent; outline: none; font-size: 14px; color: var(--text); }
.gsearch-box input::placeholder { color: #94a3b8; }
.gsearch-kbd { font-size: 11px; color: #94a3b8; border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; background: #fff; }
.gsearch-results { position: absolute; left: 0; right: 0; top: calc(100% + 8px); background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); display: none; max-height: 480px; overflow-y: auto; }
.gsearch-results.open { display: block; }
.gsearch-group { padding: 12px 16px 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; display: flex; align-items: center; gap: 6px; }
.gsearch-group .ic { color: var(--primary); }
.gsearch-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; cursor: pointer; font-size: 14px; }
.gsearch-item:hover { background: var(--primary-soft); }
.gsearch-item .gtitle { font-weight: 600; }
.gsearch-item .gsub { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.gsearch-item .gmeta { color: var(--muted); font-size: 12px; }
.gsearch-empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 通用 ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card h3 { font-size: 15px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar input[type=text], .toolbar select, .toolbar input[type=date] { padding: 8px 11px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; background: #fff; }
.toolbar input[type=text]:focus, .toolbar select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.btn { padding: 8px 15px; border: 1px solid var(--border); background: #fff; border-radius: 9px; cursor: pointer; font-size: 14px; color: var(--text); transition: background .12s, border-color .12s, box-shadow .12s, transform .05s; }
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #3b82f6, var(--primary)); border-color: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(37, 99, 235, .25); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.loading { pointer-events: none; opacity: .75; }
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #f8fafc; white-space: nowrap; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* 金额配色 */
.money-pos { color: var(--success); font-weight: 600; }
.money-neg { color: var(--danger); font-weight: 600; }
.money-warn { color: var(--warning); font-weight: 600; }

/* 空状态 */
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .empty-ic { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; background: var(--bg); display: flex; align-items: center; justify-content: center; color: #94a3b8; }
.empty .empty-title { font-size: 15px; font-weight: 600; color: #475569; margin-bottom: 4px; }
.empty .empty-sub { font-size: 13px; }

/* 徽章 */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; line-height: 1.5; }
.badge.gray { background: #f1f5f9; color: #475569; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.yellow { background: #fef9c3; color: #a16207; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.purple { background: #ede9fe; color: #6d28d9; }

/* 统计卡片 */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 25px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .value.warn { color: var(--warning); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* 工作台快捷操作 */
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.qa-btn { display: flex; align-items: center; gap: 11px; padding: 14px 18px; background: #fff; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .12s; }
.qa-btn:hover { border-color: var(--primary); box-shadow: 0 8px 22px rgba(37, 99, 235, .14); transform: translateY(-1px); }
.qa-btn .qa-ic { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); }
.qa-btn.green .qa-ic { background: var(--success-soft); color: var(--success); }
.qa-btn.amber .qa-ic { background: var(--warning-soft); color: var(--warning); }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; font-family: inherit; background: #fff; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.field input.invalid, .field select.invalid, .field textarea.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .1); }
.field textarea { resize: vertical; min-height: 60px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .err-msg { font-size: 12px; color: var(--danger); margin-top: 4px; min-height: 0; }

/* 明细行编辑 */
.item-row, .item-head { display: grid; grid-template-columns: minmax(140px, 1fr) 56px 70px 84px 52px 90px 30px; gap: 8px; margin-bottom: 8px; align-items: center; }
.item-head { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.item-head span { text-align: center; }
.item-head span:first-child { text-align: left; }
.item-row select, .item-row input { padding: 7px 8px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; width: 100%; min-width: 0; }
.item-row .sub { text-align: right; font-weight: 600; font-size: 13px; white-space: nowrap; }
.item-row .rm { color: var(--danger); cursor: pointer; font-size: 18px; text-align: center; }

/* 模态框 */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: 640px; max-width: 100%; padding: 0; box-shadow: 0 24px 70px rgba(0, 0, 0, .35); animation: pop .16s ease; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: .6; } to { transform: none; opacity: 1; } }
.modal.wide { width: 840px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-head .close { cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; }
.modal-head .close:hover { color: var(--danger); }
.modal-body { padding: 22px 24px; max-height: 70vh; overflow-y: auto; }
.modal-body table thead th { position: sticky; top: 0; z-index: 2; }
.modal-foot { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* toast */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 11px; color: #fff; font-size: 14px; box-shadow: 0 10px 28px rgba(0, 0, 0, .2); animation: slidein .2s ease; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 客户详情 */
.detail-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.detail-head .avatar { width: 54px; height: 54px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), #7c3aed); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; flex-shrink: 0; box-shadow: 0 6px 16px rgba(37, 99, 235, .3); }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.info-item .k { font-size: 12px; color: var(--muted); }
.info-item .v { font-size: 15px; margin-top: 2px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs .tab { padding: 10px 16px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* 表格行操作下拉菜单 */
.actmenu { position: relative; display: inline-block; }
.actmenu-panel { position: absolute; right: 0; top: calc(100% + 4px); min-width: 150px; background: #fff; border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow-lg); z-index: 60; display: none; overflow: hidden; }
.actmenu.open .actmenu-panel { display: block; }
.actmenu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 14px; font-size: 13px; color: var(--text); background: none; border: none; cursor: pointer; text-align: left; white-space: nowrap; }
.actmenu-item:hover { background: var(--bg); }
.actmenu-item.danger { color: var(--danger); }
.actmenu-item.danger:hover { background: var(--danger-soft); }

/* 打印样式 */
.print-only { display: none; }
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; padding: 20px; }
}
.print-doc { font-family: "SimSun", "Microsoft YaHei", serif; }
.print-doc h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.print-doc .doc-no { text-align: center; margin-bottom: 14px; }
.print-doc .meta { margin-bottom: 12px; }
.print-doc table { border: 1px solid #000; }
.print-doc th, .print-doc td { border: 1px solid #000; padding: 6px 8px; }

/* 权限勾选 */
.perm-group { margin-bottom: 14px; }
.perm-group h4 { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.perm-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.perm-checks label { display: flex; align-items: center; gap: 5px; background: #f8fafc; border: 1px solid var(--border); padding: 5px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.perm-checks input { accent-color: var(--primary); }

.bar { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); }
.chart { width: 100%; height: 220px; }

/* ---------- AI 助手 ---------- */
#ai-fab {
  position: fixed; right: 24px; bottom: 24px; width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, #3b82f6, #7c3aed); color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 10px 28px rgba(37, 99, 235, .4); z-index: 300; user-select: none; transition: transform .12s;
}
#ai-fab:hover { transform: translateY(-2px); }
#ai-panel {
  position: fixed; right: 24px; bottom: 92px; width: 400px; max-width: calc(100vw - 32px);
  height: 540px; max-height: calc(100vh - 130px); background: #fff; border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .3); display: none; flex-direction: column; z-index: 300; overflow: hidden;
}
#ai-panel.open { display: flex; }
.ai-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: #fff; }
.ai-title { font-weight: 700; flex: 1; display: flex; align-items: center; gap: 7px; }
.ai-head select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px; font-size: 12px; max-width: 130px; }
.ai-close { cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; }
.ai-close:hover { color: var(--danger); }
.ai-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #f8fafc; }
.ai-msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.ai-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.ai-msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.ai-msg.ai-thinking { color: var(--muted); font-style: italic; background: #fff; border: 1px dashed var(--border); }
.ai-acts { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.ai-act { background: #eef2ff; color: #4338ca; border-radius: 8px; padding: 3px 8px; font-size: 12px; }
.ai-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: #fff; }
.ai-input input { flex: 1; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.ai-input input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.ai-input button { padding: 9px 16px; background: var(--primary); color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; }
.ai-input button:hover { background: var(--primary-dark); }
#ai-attach { background: #fff; color: #475569; border: 1px solid var(--border); padding: 9px 10px; font-size: 16px; }
#ai-attach:hover { background: #f1f5f9; }

/* ---------- 通知面板 ---------- */
#notif-panel { position: fixed; right: 24px; top: 64px; width: 360px; max-width: calc(100vw - 32px); max-height: 70vh; background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); display: none; flex-direction: column; z-index: 300; overflow: hidden; }
#notif-panel.open { display: flex; }
.notif-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-head strong { flex: 1; }
.notif-close { cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; }
.notif-close:hover { color: var(--danger); }
.notif-list { overflow-y: auto; max-height: 60vh; }
.notif-item { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #eff6ff; }
.notif-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.notif-content { font-size: 13px; color: #475569; margin-bottom: 3px; }
.notif-time { font-size: 12px; color: var(--muted); }

/* ---------- 手机端自适应 ---------- */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; background: linear-gradient(180deg, #0f172a, #1e3a8a); }
  .sidebar .brand { padding: 10px 14px; border-bottom: none; flex-shrink: 0; font-size: 15px; }
  .sidebar .brand small { display: none; }
  .sidebar nav { display: flex; flex-direction: row; overflow-x: auto; padding: 0; white-space: nowrap; flex: 1; }
  .sidebar .nav-group { display: none; }
  .sidebar a.nav { display: inline-flex; margin: 0 2px; padding: 10px 12px; flex-shrink: 0; font-size: 13px; }
  .sidebar a.nav .ic { display: none; }
  .sidebar .foot { display: none; }
  .main { min-width: 0; }
  .topbar { padding: 0 12px; height: 54px; gap: 8px; }
  .topbar h2 { font-size: 15px; }
  .topbar .role-badge { display: none; }
  .topbar .gsearch { max-width: none; margin: 0 4px; }
  .gsearch-kbd { display: none; }
  .content { padding: 12px; }
  .card { padding: 14px; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 20px; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .modal { width: 100%; margin: 0 10px; }
  .modal.wide { width: 100%; }
  .modal-body { max-height: 68vh; }
  .modal-mask { padding: 20px 10px; }
  .toolbar input[type=text] { width: 100% !important; }
  .item-row, .item-head { grid-template-columns: minmax(96px, 1fr) 40px 50px 62px 42px 68px 24px; gap: 4px; }
  .item-row select, .item-row input { font-size: 12px; padding: 6px 4px; }
  .item-head { font-size: 11px; }
  .detail-head { flex-direction: column; }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
  #ai-fab { right: 14px; bottom: 14px; width: 50px; height: 50px; }
  #ai-panel { right: 8px; bottom: 74px; width: calc(100vw - 16px); height: 72vh; }
  .chart { height: 180px; }
}
