:root {
  --bg: #f4f6fb;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #fff;
  --ink: #172033;
  --muted: #738097;
  --line: #e7eaf1;
  --primary: #5b5ce2;
  --primary-dark: #4647c9;
  --primary-soft: #eeeefe;
  --danger: #e2495b;
  --danger-soft: #fff0f2;
  --success: #20a978;
  --shadow: 0 24px 60px rgba(39, 47, 77, 0.09);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: linear-gradient(145deg, #f7f8fc 0%, #f2f4fa 48%, #f7f5fb 100%); }
[hidden] { display: none !important; }
.auth-screen { display: grid; min-height: 100vh; padding: 24px; place-items: center; }
.auth-card { width: min(100%, 410px); padding: 34px; border: 1px solid rgba(229, 232, 240, .92); border-radius: 22px; background: var(--surface-solid); box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 9px; font-size: 25px; }
.auth-card p { margin: 0 0 23px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-field { display: block; margin-bottom: 15px; color: #4e5a70; font-size: 12px; font-weight: 650; }
.auth-field input { width: 100%; height: 42px; margin-top: 7px; padding: 0 11px; color: var(--ink); border: 1px solid #e1e4eb; border-radius: 10px; outline: none; background: #fafbfc; }
.auth-field input:focus { border-color: #aaaaf0; background: #fff; box-shadow: 0 0 0 3px rgba(91,92,226,.08); }
.auth-error { margin: -2px 0 14px !important; color: var(--danger) !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.ambient { position: fixed; z-index: -1; border-radius: 999px; filter: blur(2px); pointer-events: none; }
.ambient-one { width: 450px; height: 450px; left: -230px; top: 60px; background: radial-gradient(circle, rgba(108, 99, 255, .12), transparent 70%); }
.ambient-two { width: 520px; height: 520px; right: -280px; bottom: -100px; background: radial-gradient(circle, rgba(43, 199, 189, .1), transparent 68%); }
.app-shell { width: min(1480px, calc(100% - 48px)); margin: 0 auto; padding: 36px 0 56px; }
.header-tools { display: flex; align-items: center; gap: 12px; }
.manager-name { color: #68748a; font-size: 13px; font-weight: 650; }
.logout-button { min-height: 36px; padding: 0 12px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.brand { display: flex; align-items: center; gap: 16px; }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; color: #fff; border-radius: 16px; background: linear-gradient(145deg, #6768eb, #5051d6); box-shadow: 0 12px 28px rgba(83, 84, 216, .28); }
.brand-mark svg { width: 28px; height: 28px; stroke-width: 1.6; }
.eyebrow { margin: 0 0 4px; color: #8d97aa; font-size: 10px; font-weight: 700; letter-spacing: .16em; }
h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.02em; }
.connection-pill { display: flex; align-items: center; gap: 9px; padding: 10px 15px; color: #647187; font-size: 13px; font-weight: 600; border: 1px solid rgba(225, 229, 238, .85); border-radius: 999px; background: rgba(255, 255, 255, .7); backdrop-filter: blur(12px); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #f0aa3c; box-shadow: 0 0 0 4px rgba(240, 170, 60, .13); }
.connection-pill.connected .status-dot { background: var(--success); box-shadow: 0 0 0 4px rgba(32, 169, 120, .13); }
.connection-pill.failed .status-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(226, 73, 91, .12); }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; }
.metric-card { display: flex; align-items: center; gap: 17px; min-height: 108px; padding: 22px 24px; border: 1px solid rgba(230, 233, 241, .9); border-radius: 19px; background: var(--surface); box-shadow: 0 12px 30px rgba(40, 48, 77, .045); }
.metric-icon { display: grid; place-items: center; flex: 0 0 48px; height: 48px; color: #5b5ce2; border-radius: 15px; background: #ededff; }
.metric-icon.violet { color: #985cc9; background: #f5ebfb; }
.metric-icon.cyan { color: #178f9b; background: #e6f7f7; }
.metric-card span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.metric-card strong { font-size: 26px; line-height: 1; letter-spacing: -.03em; }

.workspace { overflow: hidden; border: 1px solid rgba(229, 232, 240, .92); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.workspace-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 26px 28px 20px; }
.workspace h2 { margin: 0 0 6px; font-size: 19px; }
.workspace-head p { margin: 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 11px; font-size: 13px; font-weight: 650; transition: .18s ease; }
.button svg { width: 17px; height: 17px; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button-primary { color: #fff; background: var(--primary); box-shadow: 0 8px 20px rgba(91, 92, 226, .22); }
.button-primary:hover { background: var(--primary-dark); }
.button-dark { color: #fff; background: #252c3d; }
.button-dark:hover { background: #171c28; }
.button-ghost { color: #68748a; border-color: var(--line); background: #fff; }
.button-ghost:hover { color: var(--ink); border-color: #d7dbe5; }
.button-secondary { color: var(--primary); background: var(--primary-soft); }
.button-danger-soft { color: var(--danger); background: var(--danger-soft); }
.button-danger { color: #fff; background: var(--danger); box-shadow: 0 8px 18px rgba(226, 73, 91, .19); }

.search-panel { display: grid; grid-template-columns: minmax(260px, 1fr) 170px auto auto auto; align-items: center; gap: 10px; padding: 0 28px 22px; }
.search-input { position: relative; display: flex; align-items: center; }
.search-input svg { position: absolute; left: 14px; width: 18px; color: #929bad; pointer-events: none; }
.search-panel input[type="search"], .search-panel select, .pagination select { width: 100%; height: 42px; color: var(--ink); border: 1px solid var(--line); border-radius: 11px; outline: none; background: #fafbfc; transition: .18s ease; }
.search-panel input[type="search"] { padding: 0 14px 0 43px; }
.search-panel select, .pagination select { padding: 0 34px 0 12px; }
.search-panel input:focus, .search-panel select:focus { border-color: #aaaaf0; background: #fff; box-shadow: 0 0 0 3px rgba(91, 92, 226, .09); }
.exact-toggle { display: flex; align-items: center; gap: 8px; padding: 0 8px; color: #68748a; font-size: 12px; font-weight: 600; white-space: nowrap; }
.exact-toggle input { position: absolute; opacity: 0; }
.exact-toggle span { position: relative; width: 34px; height: 20px; border-radius: 20px; background: #dfe3ea; transition: .2s; }
.exact-toggle span::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s; }
.exact-toggle input:checked + span { background: var(--primary); }
.exact-toggle input:checked + span::after { transform: translateX(14px); }

.selection-bar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 28px 18px; padding: 12px 14px 12px 16px; border: 1px solid #ddddfb; border-radius: 12px; background: #f7f7ff; }
.selection-bar[hidden] { display: none; }
.selection-bar strong { margin-right: 10px; color: #4647c9; font-size: 13px; }
.selection-bar span { color: #858fa3; font-size: 12px; }
.selection-actions { display: flex; gap: 8px; }
.selection-actions .button { min-height: 35px; padding: 0 13px; }

.table-frame { border-top: 1px solid var(--line); }
.table-scroller { overflow: auto; min-height: 280px; }
table { width: 100%; min-width: 820px; border-collapse: collapse; font-size: 13px; }
thead { color: #7a859a; background: #fafbfc; }
th { height: 48px; padding: 0 15px; text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .035em; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { max-width: 260px; height: 60px; padding: 10px 15px; color: #465166; border-bottom: 1px solid #eff1f5; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
tbody tr { transition: .15s ease; }
tbody tr:hover { background: #fafaff; }
tbody tr.selected { background: #f6f6ff; }
.checkbox-cell { width: 46px; padding-left: 22px; padding-right: 4px; }
.row-checkbox, #selectAll { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.primary-cell { color: #343d50; font-weight: 650; }
.null-value { display: inline-block; padding: 3px 7px; color: #98a1b1; border-radius: 5px; background: #f0f2f5; font-size: 10px; font-weight: 700; }
.cell-value { display: block; overflow: hidden; text-overflow: ellipsis; }
.action-cell { position: sticky; right: 0; width: 116px; min-width: 116px; background: inherit; box-shadow: -8px 0 12px rgba(255,255,255,.8); }
thead .action-cell { background: #fafbfc; }
.row-actions { display: flex; gap: 5px; }
.mini-button { display: grid; place-items: center; width: 32px; height: 32px; color: #69768c; border: 1px solid var(--line); border-radius: 9px; background: #fff; transition: .15s ease; }
.mini-button svg { width: 15px; height: 15px; }
.mini-button:hover { color: var(--primary); border-color: #cfcff7; background: #f8f8ff; }
.mini-button.delete:hover { color: var(--danger); border-color: #f5cbd0; background: #fff7f8; }
.loading-cell, .empty-cell { height: 260px; max-width: none; color: #8490a4; text-align: center; }
.spinner { display: inline-block; width: 16px; height: 16px; margin-right: 7px; vertical-align: -3px; border: 2px solid #d9ddec; border-top-color: var(--primary); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 64px; padding: 10px 24px; color: #8490a4; font-size: 12px; background: #fff; }
.pagination { display: flex; align-items: center; gap: 9px; }
.pagination select { width: auto; min-width: 118px; height: 34px; font-size: 12px; }
.page-button { width: 34px; height: 34px; color: #637087; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 20px; line-height: 1; }
.page-button:hover:not(:disabled) { color: var(--primary); border-color: #cecef5; }
.page-button:disabled { cursor: not-allowed; opacity: .4; }
#pageText { min-width: 54px; text-align: center; color: #596579; font-weight: 650; }

.modal { width: min(680px, calc(100% - 32px)); max-height: min(86vh, 760px); padding: 0; color: var(--ink); border: 0; border-radius: 21px; background: #fff; box-shadow: 0 30px 90px rgba(24, 30, 52, .24); }
.modal::backdrop { background: rgba(25, 31, 48, .42); backdrop-filter: blur(5px); }
.modal form { margin: 0; padding: 27px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 23px; }
.modal-kicker { display: block; margin-bottom: 7px; color: var(--primary); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.modal h3 { margin: 0 0 7px; font-size: 21px; letter-spacing: -.02em; }
.modal-head p, .result-modal p, .confirm-modal > form > p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.icon-button { display: grid; place-items: center; flex: 0 0 34px; height: 34px; color: #8c96a7; border: 0; border-radius: 10px; background: #f5f6f8; font-size: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; max-height: 52vh; padding: 2px 3px 4px; overflow: auto; }
.field-group { min-width: 0; }
.field-group.full-width { grid-column: 1 / -1; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; min-height: 22px; margin-bottom: 7px; }
.field-label { color: #4e5a70; font-size: 12px; font-weight: 650; }
.required-mark { margin-left: 3px; color: var(--danger); }
.field-type { color: #a0a8b6; font-size: 9px; text-transform: uppercase; }
.field-input, .field-group select, .field-group textarea { width: 100%; color: var(--ink); border: 1px solid #e1e4eb; border-radius: 10px; outline: none; background: #fafbfc; transition: .17s ease; }
.field-input, .field-group select { height: 41px; padding: 0 11px; }
.field-group textarea { min-height: 88px; padding: 10px 11px; resize: vertical; }
.field-input:focus, .field-group select:focus, .field-group textarea:focus { border-color: #aaaaf0; background: #fff; box-shadow: 0 0 0 3px rgba(91,92,226,.08); }
.field-input:disabled, .field-group select:disabled, .field-group textarea:disabled { color: #a1a9b6; background: #f0f2f5; }
.field-options { display: flex; align-items: center; gap: 14px; margin-top: 7px; min-height: 18px; }
.small-check { display: flex; align-items: center; gap: 5px; color: #8490a4; font-size: 10px; cursor: pointer; }
.small-check input { width: 13px; height: 13px; accent-color: var(--primary); }
.apply-check { color: var(--primary); font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--line); }
.modal-actions.split { display: grid; grid-template-columns: 1fr 1fr; }

.confirm-modal { width: min(440px, calc(100% - 32px)); text-align: center; }
.confirm-modal form { padding: 32px; }
.confirm-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 18px; color: var(--danger); border-radius: 18px; background: var(--danger-soft); }
.confirm-icon svg { width: 25px; height: 25px; }
.confirm-modal h3 { margin-bottom: 9px; }
.transaction-note { margin-top: 19px; padding: 11px 12px; color: #798499; border-radius: 10px; background: #f6f7f9; font-size: 11px; text-align: left; }
.transaction-note span { margin-right: 6px; color: var(--success); font-weight: 750; }

.import-modal { width: min(650px, calc(100% - 32px)); }
.import-step { display: grid; grid-template-columns: 34px 1fr; gap: 13px; margin-top: 15px; }
.step-number { display: grid; place-items: center; align-self: start; width: 30px; height: 30px; color: var(--primary); border-radius: 9px; background: var(--primary-soft); font-size: 12px; font-weight: 800; }
.step-content { min-width: 0; padding-top: 4px; }
.step-content > strong, .step-title-row strong { display: block; margin-bottom: 4px; color: #3f4a5f; font-size: 13px; }
.step-content > span, .step-title-row span { display: block; color: #8a94a6; font-size: 11px; line-height: 1.5; }
.step-title-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.template-button { flex: 0 0 auto; min-height: 37px; }
.drop-zone { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; min-height: 130px; margin-top: 13px; padding: 18px; color: #7d889b; border: 1.5px dashed #ccd1df; border-radius: 14px; background: #fafbfc; font-size: 12px; text-align: center; cursor: pointer; transition: .18s ease; }
.drop-zone:hover, .drop-zone.dragging { color: var(--primary); border-color: #9f9feb; background: #f8f8ff; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-zone b { color: var(--primary); }
.upload-icon { display: grid; place-items: center; width: 42px; height: 42px; color: var(--primary); border-radius: 12px; background: var(--primary-soft); }
.upload-icon svg { width: 21px; height: 21px; }
.selected-file { display: flex; align-items: center; gap: 11px; min-height: 58px; margin-top: 12px; padding: 9px 10px; border: 1px solid #dfe2eb; border-radius: 12px; background: #fff; }
.selected-file[hidden] { display: none; }
.file-icon { display: grid; place-items: center; flex: 0 0 42px; height: 38px; color: #178a67; border-radius: 9px; background: #e9f7f2; font-size: 9px; font-weight: 850; }
.selected-file div { min-width: 0; flex: 1; }
.selected-file strong, .selected-file span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-file strong { margin-bottom: 3px; color: #465166; font-size: 12px; }
.selected-file div span { color: #98a1b0; font-size: 10px; }
.selected-file .icon-button { flex-basis: 30px; height: 30px; }
.import-note { margin: 20px 0 0 47px; }

.result-modal { width: min(430px, calc(100% - 32px)); text-align: center; }
.result-modal form { padding: 34px; }
.result-icon { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 18px; color: var(--success); border-radius: 50%; background: #eaf8f3; }
.result-icon.error { color: var(--danger); background: var(--danger-soft); }
.result-icon svg { width: 30px; height: 30px; stroke-width: 2.2; }
.result-detail { margin: 20px 0; padding: 12px 14px; color: #69758a; border-radius: 10px; background: #f6f7f9; font-size: 11px; line-height: 1.55; text-align: left; }
.button.full { width: 100%; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 28px; max-width: calc(100% - 32px); padding: 11px 16px; color: #fff; border-radius: 10px; background: #252c3d; box-shadow: 0 12px 30px rgba(30,36,52,.2); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .app-shell { width: min(100% - 28px, 1480px); padding-top: 24px; }
  .metrics { grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 90px; padding: 16px; }
  .metric-icon { display: none; }
  .search-panel { grid-template-columns: 1fr 150px auto; }
  .search-input { grid-column: 1 / -1; }
  .search-panel .button { min-width: 84px; }
}

@media (max-width: 620px) {
  .app-shell { width: calc(100% - 20px); padding: 18px 0 32px; }
  .topbar { align-items: flex-start; margin-bottom: 20px; }
  .header-tools { align-items: flex-end; flex-direction: column; gap: 5px; }
  .manager-name { font-size: 11px; }
  .logout-button { min-height: 30px; font-size: 11px; }
  .brand-mark { width: 44px; height: 44px; border-radius: 13px; }
  .brand-mark svg { width: 24px; }
  h1 { font-size: 21px; }
  .eyebrow { display: none; }
  .connection-pill { padding: 9px; }
  #connectionText { display: none; }
  .metrics { gap: 7px; }
  .metric-card { display: block; min-height: 78px; padding: 14px 12px; border-radius: 14px; }
  .metric-card span { font-size: 10px; }
  .metric-card strong { font-size: 21px; }
  .workspace { border-radius: 17px; }
  .workspace-head { padding: 20px 17px 16px; }
  .workspace-head p { display: none; }
  .workspace-head .button { padding: 0 13px; }
  .head-actions { gap: 7px; }
  .head-actions .button { font-size: 0; }
  .head-actions .button svg { width: 18px; height: 18px; }
  .search-panel { grid-template-columns: 1fr 1fr; padding: 0 17px 17px; }
  .search-panel select { grid-column: 1 / -1; }
  .exact-toggle { padding-left: 1px; }
  .selection-bar { align-items: flex-start; flex-direction: column; margin: 0 17px 16px; }
  .selection-bar span { display: block; margin-top: 3px; }
  .selection-actions { width: 100%; }
  .selection-actions .button { flex: 1; }
  .table-footer { align-items: flex-start; flex-direction: column; padding: 14px 17px; }
  .pagination { width: 100%; justify-content: space-between; }
  .form-grid { grid-template-columns: 1fr; }
  .field-group.full-width { grid-column: auto; }
  .modal form { padding: 22px; }
  .step-title-row { align-items: flex-start; flex-direction: column; }
  .template-button { width: 100%; font-size: 12px; }
  .import-note { margin-left: 0; }
}
