:root {
  --primary: #24169a;
  --primary-soft: #eeecff;
  --text: #18181b;
  --muted: #71717a;
  --line: #e7e7ea;
  --surface: #ffffff;
  --background: #f8f8fa;
  --danger: #c83232;
  --radius: 4px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--background);
  font-synthesis: none;
}

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

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 48px 24px; }
.login-card { width: 100%; max-width: 448px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 32px rgba(25, 25, 45, .035); overflow: hidden; }
.login-brand { padding: 32px; text-align: center; border-bottom: 1px solid var(--line); }
.brand-block { width: 36px; height: 36px; border-radius: var(--radius); background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 700; flex: 0 0 auto; }
.brand-block-large { width: 56px; height: 56px; margin: 0 auto 20px; font-size: 24px; }
.login-brand h1 { font-size: 20px; font-weight: 600; margin: 0 0 8px; }
.login-brand p, .logo-group p { color: var(--muted); margin: 0; font-size: 12px; }
.login-form { padding: 32px; }
.login-form > label, .field label { color: var(--muted); display: block; font-size: 12px; margin-bottom: 7px; }
.input-with-icon { position: relative; }
.input-with-icon > span { position: absolute; z-index: 1; left: 13px; top: 50%; transform: translateY(-50%); color: #85858f; font-size: 18px; }
.input-with-icon input { padding-left: 40px; }
input, select { width: 100%; height: 42px; padding: 0 12px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); outline: none; }
input:focus, select:focus { border-color: #8e87c6; box-shadow: 0 0 0 3px rgba(36,22,154,.08); }
input::placeholder { color: #a3a3ab; }
.primary, .secondary, .ghost { min-height: 40px; padding: 0 20px; border-radius: var(--radius); border: 1px solid transparent; transition: opacity .15s, background .15s; }
.primary { color: white; background: var(--primary); }
.primary:hover { opacity: .9; }
.full { width: 100%; margin-top: 20px; }
.secondary { background: transparent; color: var(--text); border-color: var(--line); }
.secondary:hover, .ghost:hover { background: #f2f2f4; }
.ghost { background: transparent; color: var(--muted); padding-inline: 10px; }
.small { min-height: 32px; font-size: 12px; }
.square { width: 36px; min-height: 36px; padding: 0; }
.privacy { color: var(--muted); font-size: 12px; line-height: 1.7; text-align: center; margin: 18px 0 0; }
.login-footer { padding: 20px 32px; text-align: center; color: var(--muted); background: #fafafa; border-top: 1px solid var(--line); font-size: 12px; }
.inline-error { margin-top: 14px; padding: 12px 14px; color: var(--danger); background: #fff0f0; border-radius: var(--radius); font-size: 13px; }

.dashboard { min-height: 100vh; }
.topbar { position: sticky; z-index: 20; top: 0; height: 65px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.topbar-inner { max-width: 1280px; height: 100%; margin: auto; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.logo-group { display: flex; align-items: center; gap: 12px; }
.logo-group h1 { font-size: 16px; font-weight: 600; margin: 0 0 2px; }
.member-area { display: flex; align-items: center; gap: 14px; }
.member-copy { text-align: right; min-width: 100px; }
.member-copy strong { display: block; font-size: 14px; font-weight: 500; }
.member-copy span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.quota-box { display: flex; align-items: center; gap: 15px; padding: 9px 14px; color: var(--muted); background: #f5f5f6; border-radius: var(--radius); font-size: 12px; }
.quota-box strong { color: var(--text); font-weight: 600; }
.quota-box i { width: 1px; height: 14px; background: var(--line); }
.main { max-width: 1280px; margin: auto; padding: 32px; }
.filter-card, .table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.filter-card { padding: 24px; margin-bottom: 24px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.field input, .field select { height: 40px; font-size: 13px; }
.compact > span { left: 12px; font-size: 16px; }
.compact input { padding-left: 36px; }
.filter-actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.result-count { margin-left: auto; color: var(--muted); }
.result-count strong { color: var(--text); font-weight: 600; }
.table-card { overflow: hidden; }
.table-grid { display: grid; grid-template-columns: 3fr 3fr 2fr 2fr; align-items: center; }
.table-head { padding: 13px 20px; background: #f6f6f7; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 11px; letter-spacing: .08em; }
.lead-row { position: relative; padding: 15px 20px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .15s, opacity .15s; }
.lead-row:hover, .lead-row:focus { background: #fafafe; outline: none; }
.lead-row.is-opening { cursor: wait; background: #f8f7ff; }
.lead-row.is-opening > .date-cell { visibility: hidden; }
.row-opening-status { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); display: none; align-items: center; gap: 7px; color: var(--primary); font-size: 12px; font-weight: 500; white-space: nowrap; }
.lead-row.is-opening .row-opening-status { display: flex; }
.row-opening-status i { width: 14px; height: 14px; border: 2px solid rgba(36,22,154,.18); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.lead-cell { min-width: 0; padding-right: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-cell { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.company-mark, .company-icon { color: var(--primary); background: var(--primary-soft); border-radius: var(--radius); display: grid; place-items: center; flex: 0 0 auto; }
.company-mark { width: 32px; height: 32px; }
.company-icon { width: 44px; height: 44px; font-size: 18px; }
.badge { display: inline-block; padding: 5px 8px; background: #f1f1f3; border-radius: var(--radius); font-size: 12px; }
.date-cell { color: var(--muted); font-size: 13px; }
.empty-state { min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.empty-icon { color: #b9b9c0; font-size: 34px; }
.spinner { width: 24px; height: 24px; border: 2px solid #e2e2e6; border-top-color: var(--primary); border-radius: 999px; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pagination { min-height: 58px; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }
.pagination div { display: flex; gap: 8px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(24,24,27,.42); backdrop-filter: blur(3px); }
.modal { position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(672px, calc(100vw - 32px)); max-height: 90vh; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 22px 70px rgba(0,0,0,.2); animation: modal-in .22s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 16px)) scale(.985); } }
.modal-header { padding: 24px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--line); }
.modal-title-wrap { display: flex; align-items: flex-start; gap: 13px; }
.modal h2 { margin: 1px 0 5px; font-size: 18px; font-weight: 600; }
.modal-header p { margin: 0; color: var(--muted); }
.modal-body { max-height: calc(90vh - 94px); overflow-y: auto; padding: 24px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.tag { padding: 7px 11px; color: var(--muted); background: #f2f2f4; border-radius: var(--radius); font-size: 12px; }
.tag.primary-tag { color: var(--primary); background: var(--primary-soft); }
.modal-body h3 { color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .1em; margin: 24px 0 11px; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.contact-grid > div { padding: 14px 16px; }
.contact-grid > div:nth-child(odd) { border-right: 1px solid var(--line); }
.contact-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.contact-grid strong { font-size: 14px; font-weight: 500; }
.description { padding: 16px; color: #3f3f46; background: #fafafa; border: 1px solid var(--line); border-radius: var(--radius); line-height: 1.8; white-space: pre-wrap; }
.attachments { display: grid; gap: 8px; }
.attachment { padding: 12px 14px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.toast { position: fixed; z-index: 70; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: min(520px, calc(100vw - 32px)); padding: 12px 18px; color: white; background: #222228; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.toast.error { background: #b83333; }

@media (max-width: 900px) {
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quota-box { display: none; }
  .table-head { display: none; }
  .lead-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
  .lead-cell { padding-right: 0; }
  .lead-row > div:nth-child(2) { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  body { font-size: 13px; }
  .topbar { height: 98px; }
  .topbar-inner { position: relative; height: 98px; padding: 0 12px 40px; gap: 8px; }
  .logo-group { min-width: 0; gap: 8px; }
  .logo-group .brand-block { width: 32px; height: 32px; }
  .logo-group h1 { margin: 0; font-size: 14px; white-space: nowrap; }
  .logo-group p, .member-company, .member-copy span { display: none; }
  .member-area { min-width: 0; gap: 2px; }
  .member-copy { min-width: 0; text-align: right; }
  .member-copy strong { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
  #logout-button { min-height: 32px; padding-inline: 6px; white-space: nowrap; }
  .quota-box {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 8px;
    height: 32px;
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 6px 10px;
    font-size: 11px;
  }
  .quota-box i { height: 12px; }

  .main { padding: 12px; }
  .filter-card { padding: 14px; margin-bottom: 12px; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
  .filter-grid .field:first-child, .filter-grid .field:last-child { grid-column: 1 / -1; }
  .login-form > label, .field label { margin-bottom: 5px; }
  .field input, .field select { height: 38px; }
  .filter-actions { gap: 8px; margin-top: 14px; }
  .filter-actions .primary, .filter-actions .secondary { min-height: 38px; padding-inline: 15px; }
  .result-count { width: auto; margin: 0 0 0 auto; white-space: nowrap; }

  .table-card { overflow: visible; border: 0; background: transparent; }
  #lead-list { display: grid; gap: 10px; }
  .lead-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "company company" "name name" "type date";
    gap: 8px 10px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
  }
  .lead-row > div:nth-child(1) { grid-area: company; }
  .lead-row > div:nth-child(2) { grid-area: name; }
  .lead-row > div:nth-child(3) { grid-area: type; }
  .lead-row > div:nth-child(4) { grid-area: date; align-self: center; text-align: right; }
  .company-cell { gap: 9px; font-size: 15px; }
  .company-mark { width: 30px; height: 30px; }
  .lead-row > div:nth-child(2) { font-size: 15px; }
  .badge { padding: 4px 7px; }
  .date-cell { font-size: 12px; }
  .row-opening-status { right: 14px; bottom: 14px; top: auto; transform: none; }
  .empty-state { min-height: 160px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
  .pagination { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }

  .login-view { padding: 20px 12px; }
  .login-brand, .login-form { padding: 24px 20px; }
  .contact-grid { grid-template-columns: 1fr; }
  .contact-grid > div { border-right: 0 !important; border-bottom: 1px solid var(--line); }
  .contact-grid > div:last-child { border-bottom: 0; }
  .modal { width: calc(100vw - 16px); max-height: 92vh; }
  .modal-header, .modal-body { padding: 16px; }
  .modal-body { max-height: calc(92vh - 82px); }
}

@media (max-width: 380px) {
  .logo-group h1 { font-size: 13px; }
  .member-copy strong { max-width: 74px; font-size: 12px; }
  #logout-button { font-size: 11px; padding-inline: 3px; }
  .main { padding-inline: 10px; }
  .filter-actions .primary, .filter-actions .secondary { padding-inline: 12px; }
}
