:root {
  --ink: #16231c;
  --ink-soft: #425249;
  --night: #14231b;
  --night-2: #20352a;
  --paper: #f4f3ec;
  --surface: #fffef9;
  --line: #dcded5;
  --muted: #6c786f;
  --accent: #d8f45b;
  --accent-strong: #b9dc2e;
  --orange: #ff8a5b;
  --blue: #72a7ff;
  --red: #df665e;
  --shadow: 0 18px 50px rgba(22, 35, 28, 0.09);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
input, select, textarea { color: var(--ink); }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.035em; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.brand-lockup { display: inline-flex; align-items: center; gap: 11px; color: var(--night); }
.brand-lockup > span:last-child { display: grid; line-height: .9; }
.brand-lockup strong { font-size: 17px; letter-spacing: .16em; }
.brand-lockup small { margin-top: 5px; font-size: 9px; letter-spacing: .3em; color: var(--muted); }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: var(--accent); color: var(--night); font-size: 20px; font-weight: 900; transform: rotate(-4deg); }
.brand-lockup--light { color: white; }
.brand-lockup--light small { color: #9eb1a6; }

.eyebrow { margin-bottom: 8px; color: #708078; font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow--light { color: var(--accent); }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: 12px; font-weight: 750; transition: transform .16s ease, background .16s ease, border-color .16s ease; }
.button:hover { transform: translateY(-1px); }
.button--primary { background: var(--accent); color: var(--night); }
.button--primary:hover { background: var(--accent-strong); }
.button--secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.button--secondary:hover { border-color: #abb7ae; }
.button--dark { background: var(--night); color: white; }
.button--full { width: 100%; }
.text-button { border: 0; background: transparent; color: var(--ink); font-size: 13px; font-weight: 800; text-decoration: underline; text-underline-offset: 4px; }

.field { display: grid; gap: 8px; }
.field > span { font-size: 13px; font-weight: 750; }
.field input, .field textarea, .field select, .compact-select select, .search-field { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); outline: none; }
.field input, .field textarea, .field select, .compact-select select { padding: 0 14px; }
.field textarea { min-height: 124px; padding-top: 13px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus, .compact-select select:focus, .search-field:focus-within { border-color: #7b9184; box-shadow: 0 0 0 3px rgba(216, 244, 91, .35); }
.form-error { margin: 14px 0; padding: 11px 13px; border-radius: 10px; background: #fff0ee; color: #9d332c; font-size: 13px; }

/* Login */
.login-page { background: var(--surface); }
.login-shell { display: grid; grid-template-columns: minmax(440px, 1.05fr) minmax(480px, .95fr); min-height: 100vh; }
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: 58px clamp(46px, 6vw, 96px); overflow: hidden; background: var(--night); color: white; }
.login-brand::before { content: ""; position: absolute; right: -20%; bottom: 6%; width: 72%; aspect-ratio: 1; border: 1px solid rgba(216, 244, 91, .18); border-radius: 50%; box-shadow: 0 0 0 70px rgba(216, 244, 91, .025), 0 0 0 140px rgba(216, 244, 91, .018); }
.login-brand::after { content: ""; position: absolute; right: 9%; bottom: 20%; width: 140px; height: 140px; border-radius: 50%; background: var(--accent); filter: blur(1px); opacity: .92; }
.login-promise { position: relative; z-index: 1; max-width: 620px; margin: auto 0; padding: 70px 0; }
.login-promise h1 { max-width: 580px; margin-bottom: 26px; font-size: clamp(46px, 5.4vw, 78px); line-height: .96; }
.login-promise > p:last-child { max-width: 500px; color: #b5c3bb; font-size: 18px; line-height: 1.65; }
.login-proof { position: relative; z-index: 1; display: flex; gap: 26px; color: #aabbb1; font-size: 12px; }
.login-proof span::before { content: "●"; margin-right: 8px; color: var(--accent); }
.login-panel { display: grid; place-items: center; padding: 48px; background: var(--surface); }
.login-card { width: min(100%, 440px); }
.login-card h2 { margin-bottom: 8px; font-size: 40px; }
.login-card > .muted { margin-bottom: 34px; line-height: 1.55; }
.login-card form { display: grid; gap: 20px; }
.password-field { position: relative; }
.password-field input { padding-right: 82px; }
.input-action { position: absolute; right: 10px; top: 9px; min-height: 30px; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; }
.login-help { margin: 26px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.mobile-brand { display: none; margin-bottom: 55px; }

/* App shell */
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column; width: 250px; padding: 30px 20px 22px; background: var(--night); color: white; }
.sidebar-brand { margin: 0 10px 44px; }
.nav { display: grid; gap: 7px; }
.nav-link { display: flex; align-items: center; gap: 13px; min-height: 48px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; color: #9eb0a6; font-size: 14px; font-weight: 700; text-align: left; }
.nav-link:hover { background: rgba(255,255,255,.055); color: white; }
.nav-link.is-active { background: var(--accent); color: var(--night); }
.nav-icon { display: grid; place-items: center; width: 22px; font-size: 18px; }
.sidebar-bottom { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.09); }
.sidebar-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-user > span:last-child { display: grid; min-width: 0; }
.sidebar-user strong, .sidebar-user small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { font-size: 13px; }
.sidebar-user small { margin-top: 3px; color: #92a49a; font-size: 11px; }
.avatar { display: grid; flex: 0 0 auto; place-items: center; width: 37px; height: 37px; border-radius: 12px; background: var(--night-2); color: var(--accent); font-weight: 900; }
.logout-button { width: 100%; margin-top: 12px; padding: 8px; border: 0; background: transparent; color: #84968c; font-size: 12px; text-align: left; }
.logout-button:hover { color: white; }
.main-content { min-height: 100vh; margin-left: 250px; padding: 34px clamp(24px, 4vw, 58px) 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 34px; }
.topbar h1 { margin: 0; font-size: 34px; }
.topbar .eyebrow { margin-bottom: 5px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.compact-select select { min-width: 170px; min-height: 44px; background-position: right 12px center; }
.view[hidden] { display: none; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 18px; }
.stat-card { position: relative; min-height: 150px; padding: 23px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat-card::after { content: ""; position: absolute; right: -28px; bottom: -38px; width: 96px; height: 96px; border: 17px solid rgba(22,35,28,.035); border-radius: 50%; }
.stat-card--accent { border-color: var(--accent); background: var(--accent); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 750; }
.stat-card--accent .stat-label { color: #44501c; }
.stat-value { margin: 17px 0 4px; font-size: 38px; font-weight: 850; letter-spacing: -.05em; }
.stat-note { color: var(--muted); font-size: 11px; }
.stat-card--accent .stat-note { color: #596625; }

.content-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .7fr); gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 0 rgba(22,35,28,.02); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 24px 25px 16px; }
.panel-heading h2 { margin: 0; font-size: 21px; }
.attention-card { display: flex; flex-direction: column; align-items: flex-start; min-height: 330px; padding: 26px; background: #e9eeff; }
.attention-card h2 { margin-bottom: 12px; font-size: 26px; line-height: 1.08; }
.attention-card .muted { margin-bottom: 28px; font-size: 13px; line-height: 1.55; }
.attention-card .button { margin-top: auto; }
.attention-icon { display: grid; place-items: center; width: 47px; height: 47px; margin-bottom: 34px; border-radius: 50%; background: var(--night); color: var(--accent); font-size: 23px; }

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 12px 18px; border-top: 1px solid #e9eae3; border-bottom: 1px solid #e9eae3; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 16px 18px; border-bottom: 1px solid #ecece6; font-size: 13px; vertical-align: middle; }
.data-table tbody tr { transition: background .15s ease; }
.data-table tbody tr:hover { background: #fafaf5; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .lead-name { display: grid; gap: 3px; min-width: 170px; }
.data-table .lead-name strong { font-size: 13px; }
.data-table .lead-name small { color: var(--muted); }
.row-button { border: 0; background: transparent; color: var(--ink); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 999px; background: #eff0eb; color: #526057; font-size: 10px; font-weight: 850; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status--new { background: #edf1ff; color: #526fc0; }
.status--contacted { background: #fff2e7; color: #b15a29; }
.status--negotiation { background: #f5edff; color: #8053ae; }
.status--converted { background: #ecf6d9; color: #557424; }
.status--lost { background: #f5e9e7; color: #a4473f; }
.empty-state { display: grid; place-items: center; min-height: 260px; padding: 34px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 16px; }

.filters { display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 12px; padding: 20px; }
.search-field { display: flex; align-items: center; gap: 9px; padding: 0 14px; }
.search-field span { color: var(--muted); font-size: 20px; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; }
.pagination { display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 12px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pagination-buttons { display: flex; gap: 6px; }
.page-button { min-width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.page-button:disabled { opacity: .4; }

.section-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-actions p { margin: 0; }
.store-name-cell { display: flex; align-items: center; gap: 11px; min-width: 170px; }
.store-dot { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--night); color: var(--accent); font-weight: 850; }
.actions { display: flex; gap: 7px; }
.small-button { min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--ink); font-size: 11px; font-weight: 750; }
.small-button--danger { color: #a4473f; }

.dialog { width: min(720px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; overflow: auto; border: 0; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(9,18,13,.58); backdrop-filter: blur(3px); }
.dialog > form[method="dialog"] { position: sticky; top: 0; z-index: 2; height: 0; }
.dialog-close { position: absolute; top: 18px; right: 18px; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eff0eb; color: var(--ink); font-size: 22px; }
.lead-detail { padding: 32px; }
.lead-detail h2 { margin-bottom: 5px; font-size: 28px; }
.lead-contact { margin-bottom: 24px; color: var(--muted); font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-bottom: 24px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--line); }
.detail-item { padding: 15px; background: white; }
.detail-item small { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.detail-item strong, .detail-item a { color: var(--ink); font-size: 13px; word-break: break-word; }
.lead-edit { display: grid; gap: 15px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; padding-right: 50px; }
.dialog-heading h2 { margin: 0; font-size: 28px; }
.dialog--form > form { padding: 30px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; margin-top: 27px; }
.field--full { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.domain-input { display: flex; align-items: center; min-height: 48px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; }
.domain-input input { min-width: 0; border: 0; border-radius: 0; }
.domain-input span { padding-right: 12px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.dialog--compact { width: min(520px, calc(100vw - 28px)); padding: 34px; text-align: center; }
.dialog--compact h2 { margin-bottom: 10px; font-size: 28px; }
.success-mark { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 22px; border-radius: 50%; background: var(--accent); font-size: 25px; font-weight: 850; }
.copy-field { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 24px 0 12px; }
.copy-field code { padding: 13px; overflow: auto; border-radius: 10px; background: #eef0e9; color: var(--ink); font-size: 11px; text-align: left; white-space: nowrap; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 80; max-width: 360px; padding: 14px 18px; border-radius: 12px; background: var(--night); color: white; box-shadow: var(--shadow); font-size: 13px; transform: translateY(18px); opacity: 0; pointer-events: none; transition: .22s ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.app-loading { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 100vh; color: var(--muted); }
.spinner { width: 20px; height: 20px; border: 2px solid var(--line); border-top-color: var(--night); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.mobile-menu, .mobile-close, .sidebar-backdrop { display: none; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
  .attention-card { min-height: 260px; }
}

@media (max-width: 820px) {
  .login-shell { display: block; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; padding: 28px 22px; }
  .mobile-brand { display: inline-flex; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  body.menu-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 15; background: rgba(10,18,14,.45); }
  body.menu-open .sidebar-backdrop { display: block; }
  .mobile-close { display: block; position: absolute; top: 25px; right: 15px; border: 0; background: transparent; color: white; font-size: 25px; }
  .main-content { margin-left: 0; padding: 24px 18px 48px; }
  .mobile-menu { display: block; width: 42px; height: 42px; margin-right: 2px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
  .topbar { align-items: center; gap: 10px; }
  .topbar > div:nth-child(2) { margin-right: auto; }
  .topbar h1 { font-size: 26px; }
  .topbar-actions .button { padding: 0 12px; font-size: 12px; }
  .compact-select select { min-width: 140px; }
}

@media (max-width: 620px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { min-height: 132px; padding: 17px; }
  .stat-value { font-size: 31px; }
  .topbar { flex-wrap: wrap; }
  .topbar-actions { width: 100%; }
  .topbar-actions .compact-select { flex: 1; }
  .topbar-actions select { width: 100%; }
  .filters { grid-template-columns: 1fr; }
  .section-actions { align-items: flex-start; flex-direction: column; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .field--full { grid-column: auto; }
  .copy-field { grid-template-columns: 1fr; }
  .dialog--form > form, .lead-detail { padding: 24px 20px; }
  .login-card h2 { font-size: 34px; }
}
