:root {
  --ink: #102a2b;
  --muted: #667776;
  --line: #dce6e3;
  --surface: #ffffff;
  --canvas: #f3f7f5;
  --teal: #087f6b;
  --teal-dark: #056454;
  --lime: #d9f66f;
  --danger: #c83f4d;
  --shadow: 0 18px 45px rgba(21, 61, 56, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 75% 15%, #17665d, #082d2f 55%); }
.login-card { width: min(420px, 100%); padding: 34px; border-radius: 22px; background: white; box-shadow: 0 30px 90px rgba(0,0,0,.28); }
.login-card h1 { margin: 9px 0; font-size: 27px; }
.login-card p { color: var(--muted); }
.login-error { display: block; min-height: 20px; margin-top: 10px; color: var(--danger); font-size: 12px; text-align: center; }
.user-menu { display: flex; align-items: center; gap: 8px; color: white; }
.user-menu .secondary { padding: 7px 10px; }
.admin-tabs { display: inline-flex; gap: 5px; padding: 5px; margin-bottom: 14px; border-radius: 12px; background: white; }
.admin-subtab { border: 0; padding: 9px 15px; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 800; }
.admin-subtab.active { color: white; background: var(--teal); }
.admin-card { padding: 20px; }
.log-controls { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.log-controls label { display: grid; gap: 6px; min-width: 220px; font-size: 12px; font-weight: 800; }
.log-controls select { padding: 9px 32px 9px 10px; }
#log-pagination { margin-top: 12px; }
.share-user-list { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.share-user-list label { display: flex; align-items: center; gap: 9px; padding: 10px 12px; margin: 0; border-bottom: 1px solid var(--line); font-weight: 500; }
.share-user-list label:last-child { border-bottom: 0; }
.share-user-list input { width: auto; margin: 0; }
.admin-table-wrap { min-height: 480px; }

button, input, select { font: inherit; }
button { cursor: pointer; }

.hero {
  color: white;
  background:
    radial-gradient(circle at 82% 10%, rgba(217, 246, 111, .18), transparent 24%),
    linear-gradient(125deg, #0a2d2f, #0b4b46);
  padding: 40px 24px 86px;
}

.hero-inner {
  max-width: 1380px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eyebrow, .overline {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  color: #9fcbc2;
}

.hero h1 { margin: 8px 0; font-size: clamp(32px, 4vw, 54px); letter-spacing: -.04em; }
.hero p { margin: 0; color: #c8dbd7; font-size: 17px; }

.hero-badge {
  width: 112px;
  height: 112px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 28px;
  background: rgba(255, 255, 255, .08);
  display: grid;
  place-content: center;
  text-align: center;
  transform: rotate(3deg);
}

.hero-badge .flag {
  display: block;
  color: var(--lime);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .22em;
}
.hero-badge strong { font-size: 34px; }

.app-shell { max-width: 1380px; margin: -52px auto 60px; padding: 0 24px; }

.tabs {
  display: inline-flex;
  padding: 6px;
  border-radius: 14px;
  background: white;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.tab {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  padding: 11px 24px;
  font-weight: 800;
}
.tab.active { color: white; background: var(--teal); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid rgba(210, 225, 221, .85);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  min-height: 125px;
  padding: 22px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 8px 24px rgba(21, 61, 56, .04);
}
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card strong { display: block; font-size: 38px; margin: 5px 0 3px; }
.stat-card small { font-size: 12px; }
.stat-card.accent { background: var(--ink); border-color: var(--ink); }
.stat-card.accent strong { color: var(--lime); }
.stat-card.accent span, .stat-card.accent small { color: #c5d8d5; }

.workspace-grid { display: grid; grid-template-columns: 430px 1fr; gap: 18px; align-items: start; }
.controls-card, .results-card, .library-toolbar, .library-list-card, .library-detail { padding: 26px; }

.section-heading { display: flex; gap: 14px; margin-bottom: 20px; }
.section-heading.compact { margin-bottom: 16px; }
.step {
  flex: 0 0 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: #e3f4ef;
  font-weight: 900;
}
h2, h3, p { margin-top: 0; }
.section-heading h2 { margin: 1px 0 5px; font-size: 19px; }
.section-heading p, .library-toolbar p, .library-empty p, dialog p { color: var(--muted); margin-bottom: 0; font-size: 13px; line-height: 1.6; }

.drop-zone {
  min-height: 154px;
  border: 1.5px dashed #a8c4bd;
  border-radius: 16px;
  background: #f7fbf9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: .2s ease;
}

.source-mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 5px; margin-bottom: 14px; border-radius: 12px; background: #edf4f1; }
.source-mode { border: 0; border-radius: 9px; padding: 10px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 800; }
.source-mode.active { color: white; background: var(--teal); box-shadow: 0 5px 14px rgba(8, 127, 107, .18); }
.source-library-field { margin-top: 0; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbfa; }
.result-mode-grid { margin-top: 4px; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--teal); background: #eff9f5; transform: translateY(-1px); }
.drop-zone input, .mini-upload input { display: none; }
.drop-zone strong { font-size: 15px; }
.drop-zone small { color: var(--muted); margin-top: 6px; }
.upload-icon {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 50%; margin-bottom: 10px; color: white; background: var(--teal); font-size: 22px;
}

.file-meta {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #edf7f3;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.divider { height: 1px; background: var(--line); margin: 24px 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { margin-top: 14px; }
.field label { display: block; font-size: 13px; font-weight: 800; margin-bottom: 7px; }
.field-help { display: block; color: var(--muted); font-size: 11px; line-height: 1.55; margin-top: 7px; }
.help-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid #a9beb9;
  border-radius: 50%;
  color: var(--teal-dark);
  background: white;
  font-size: 11px;
  font-weight: 900;
  vertical-align: 1px;
}
.help-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  z-index: 20;
  width: 260px;
  padding: 10px 12px;
  border-radius: 9px;
  color: white;
  background: var(--ink);
  box-shadow: 0 10px 28px rgba(4, 36, 33, .2);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
  text-align: left;
  white-space: normal;
  transform: translate(-50%, 5px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: .15s ease;
}
.help-tip:hover::after, .help-tip:focus-visible::after, .help-tip.open::after {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
}
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--ink);
  background: white;
  outline: none;
}
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8, 127, 107, .1); }
#result-mode { padding-left: 9px; padding-right: 26px; font-size: 11px; }

.checks { display: grid; gap: 10px; margin: 18px 0; }
.checks label { font-size: 13px; color: #3d5250; display: flex; align-items: center; gap: 8px; }
.checks input { width: 16px; height: 16px; accent-color: var(--teal); }

.compare-section { margin: 18px 0 0; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbfa; }
.compare-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.compare-title strong, .compare-title small { display: block; }
.compare-title strong { font-size: 13px; }
.compare-title small, .empty-hint { color: var(--muted); font-size: 11px; margin-top: 4px; line-height: 1.5; }
.text-button { border: 0; padding: 0; color: var(--teal); background: transparent; font-size: 12px; font-weight: 800; }
.filter-library-scope { width: 100%; margin-bottom: 8px; padding: 8px 30px 8px 10px; font-size: 12px; }
.compare-library-list { display: block; height: 176px; overflow-y: auto; border: 1px solid #dce8e4; border-radius: 10px; background: white; scrollbar-gutter: stable; }
.compare-library-option { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 43px; padding: 9px 11px; background: white; border-bottom: 1px solid #edf2f0; font-size: 12px; }
.compare-library-option:last-child { border-bottom: 0; }
.compare-library-option:hover { background: #f2f8f6; }
.compare-library-option span { display: flex; align-items: center; gap: 8px; }
.compare-library-option input { width: 15px; height: 15px; accent-color: var(--teal); }
.compare-library-option:has(input:disabled) { color: #91a09d; background: #f3f6f5; cursor: not-allowed; }
.compare-library-option small { color: var(--muted); }
.compare-library-list > .empty-hint { display: grid; min-height: 100%; place-items: center; padding: 16px; text-align: center; }

.primary, .secondary, .danger {
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 800;
  border: 1px solid transparent;
}
.primary { color: white; background: var(--teal); }
.primary:hover { background: var(--teal-dark); }
.secondary { color: var(--ink); background: white; border-color: var(--line); }
.secondary:hover { border-color: #9eb9b2; }
.danger { color: var(--danger); background: #fff6f7; border-color: #f3cdd2; }
.danger-text { color: var(--danger); }
button:disabled { cursor: not-allowed; opacity: .45; }
.wide { width: 100%; padding: 13px; }
.status-message { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

.results-header, .library-detail-header, .library-toolbar, .side-title, .search-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.results-header h2, .library-toolbar h2, .library-detail-header h2 { margin: 5px 0 0; }
.result-actions { display: flex; gap: 8px; }
.result-view-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.result-view-tabs { display: flex; gap: 5px; padding: 4px; border-radius: 11px; background: #edf4f1; }
.result-view-tab { border: 0; border-radius: 8px; padding: 8px 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 800; }
.result-view-tab span { display: inline-block; min-width: 20px; margin-left: 3px; padding: 2px 5px; border-radius: 10px; background: rgba(255, 255, 255, .75); font-size: 10px; }
.result-view-tab.active { color: white; background: var(--teal); }
.result-view-tab.active span { color: var(--teal-dark); }
.result-search { max-width: 250px; padding: 9px 11px; font-size: 12px; }
.table-wrap { margin-top: 22px; border: 1px solid var(--line); border-radius: 14px; overflow: auto; min-height: 520px; max-height: 660px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; z-index: 1; background: #f2f7f5; color: #526663; text-align: left; padding: 13px 15px; border-bottom: 1px solid var(--line); }
td { padding: 12px 15px; border-bottom: 1px solid #edf2f0; }
tbody tr:hover { background: #fbfdfc; }
.col-index { width: 78px; }
.col-action { width: 85px; }
.empty-row td { height: 390px; text-align: center; color: var(--muted); }
.empty-row strong, .empty-row span { display: block; }
.empty-row strong { color: var(--ink); margin-bottom: 8px; }
.phone-output { color: var(--teal-dark); font-weight: 800; font-family: Consolas, monospace; }
.tag { display: inline-block; padding: 4px 8px; border-radius: 20px; font-size: 11px; font-weight: 800; }
.tag.valid { color: #08705f; background: #ddf5ed; }
.tag.invalid { color: #a94852; background: #fff0f2; }
.table-footer { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; margin-top: 12px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.pagination label { display: flex; align-items: center; gap: 5px; }
.pagination select { width: 68px; padding: 6px 22px 6px 7px; }
.pagination input { width: 62px; padding: 6px 7px; text-align: center; }
.pagination button { padding: 6px 10px; font-size: 12px; }
.library-pagination { margin-top: 12px; }

.library-toolbar { margin-bottom: 18px; }
.library-toolbar p { margin-top: 5px; }
.library-toolbar-actions { display: flex; align-items: center; gap: 12px; }
.member-library-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800; color: var(--muted); }
.member-library-toggle input { width: auto; margin: 0; accent-color: var(--teal); }
.library-layout { display: grid; grid-template-columns: 310px 1fr; gap: 18px; align-items: start; }
.library-list-card, .library-detail { min-height: 590px; }
.side-title { border-bottom: 1px solid var(--line); padding-bottom: 15px; }
.side-title h3 { margin: 0; }
.side-title span { color: var(--muted); font-size: 12px; }
.library-sort { display: grid; gap: 5px; margin-top: 12px; color: var(--muted); font-size: 12px; font-weight: 800; }
.library-sort select { padding: 8px 30px 8px 9px; font-size: 12px; }
.library-list { display: grid; gap: 8px; margin-top: 14px; }
.library-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 12px;
  padding: 13px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.library-item:hover { background: #f3f8f6; }
.library-item.active { color: var(--teal-dark); border-color: #b9dbd2; background: #eaf6f2; }
.library-item-content { min-width: 0; display: grid; gap: 5px; }
.library-item strong { display: block; font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.library-item-meta { display: grid; grid-template-columns: 58px minmax(0, 1fr); align-items: baseline; gap: 5px; font-size: 10px; line-height: 1.25; }
.library-item-meta small { color: #8b9b98; font-size: 10px; }
.library-item-meta b { color: var(--muted); font-size: 10px; font-weight: 600; overflow-wrap: anywhere; }
.library-count-pill { min-width: 32px; text-align: center; border-radius: 20px; padding: 4px 7px; background: white; font-size: 11px; font-weight: 800; }
.library-empty { min-height: 520px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-symbol { width: 72px; height: 72px; border-radius: 24px; background: var(--ink); color: var(--lime); display: grid; place-items: center; font-size: 26px; font-weight: 900; margin-bottom: 18px; }
.library-empty button { margin-top: 20px; }
.library-import-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 20px 0; border-bottom: 1px solid var(--line); }
.mini-upload { color: white; background: var(--teal); padding: 10px 16px; border-radius: 10px; font-weight: 800; cursor: pointer; }
.search-row { margin-top: 18px; }
.search-row input { max-width: 360px; }
.search-row span { color: var(--muted); font-size: 12px; }
.library-table-wrap { min-height: 360px; max-height: 460px; }
.remove-number { border: 0; background: transparent; color: var(--danger); font-weight: 800; }

dialog {
  width: min(430px, calc(100% - 32px));
  border: 0;
  border-radius: 18px;
  padding: 26px;
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(4, 36, 33, .3);
}
dialog::backdrop { background: rgba(6, 36, 34, .58); backdrop-filter: blur(3px); }
dialog input { margin-top: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.format-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.format-options label { cursor: pointer; }
.format-options input { position: absolute; opacity: 0; pointer-events: none; }
.format-options span { display: block; text-align: center; padding: 15px 8px; border: 1px solid var(--line); border-radius: 10px; font-weight: 800; }
.format-options input:checked + span { color: var(--teal-dark); border-color: var(--teal); background: #e9f7f2; }
.export-field-options { margin: 18px 0; }
.export-field-options strong { display: block; margin-bottom: 9px; font-size: 13px; }
.export-field-options > div { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.export-field-options label { font-size: 12px; color: var(--muted); }
.export-field-options input { width: 15px; margin-right: 5px; accent-color: var(--teal); }
.range-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 13px 18px;
  border-radius: 12px;
  color: white;
  background: var(--ink);
  box-shadow: var(--shadow);
  transform: translateY(80px);
  opacity: 0;
  transition: .25s ease;
  z-index: 10;
}
.toast.show { transform: translateY(0); opacity: 1; }
.hidden { display: none !important; }

@media (max-width: 980px) {
  .workspace-grid, .library-layout { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .library-list-card { min-height: auto; }
  .library-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .hero { padding-top: 28px; }
  .hero-badge { display: none; }
  .app-shell { padding: 0 12px; }
  .stats-grid { gap: 8px; }
  .stat-card { min-height: 108px; padding: 16px; }
  .stat-card strong { font-size: 30px; }
  .form-grid { grid-template-columns: 1fr; }
  .controls-card, .results-card, .library-toolbar, .library-list-card, .library-detail { padding: 18px; }
  .results-header, .library-toolbar, .library-detail-header { align-items: flex-start; flex-direction: column; }
  .result-actions { width: 100%; }
  .result-actions button { flex: 1; }
  .result-view-toolbar { align-items: stretch; flex-direction: column; }
  .result-view-tabs { display: grid; grid-template-columns: repeat(3, 1fr); }
  .result-search { max-width: none; }
  .library-list { grid-template-columns: 1fr; }
  .table-footer { display: grid; gap: 5px; }
  .pagination { justify-content: flex-start; }
}
