:root {
  color-scheme: light;
  --ink: #161b1a;
  --muted: #66706d;
  --line: #dde2df;
  --paper: #f4f5f1;
  --white: #ffffff;
  --green: #236653;
  --green-dark: #174b3d;
  --green-soft: #e1efe8;
  --amber: #ad6b24;
  --amber-soft: #fbeddc;
  --red: #a83a36;
  --red-soft: #f8e7e5;
  --shadow: 0 22px 60px rgba(22, 27, 26, 0.12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px; background: #101715; color: #f6f8f5; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 30px; letter-spacing: .08em; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: #ccf06c; color: #182018; font-weight: 900; font-size: 21px; }
.brand strong, .brand span { display: block; }
.brand span { margin-top: 2px; color: #89928f; font-size: 11px; letter-spacing: .2em; }
.nav-list { display: grid; gap: 7px; }
.nav-item { width: 100%; display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 12px 13px; border: 0; border-radius: 10px; color: #aeb7b4; background: transparent; text-align: left; }
.nav-item:hover { background: #1b2421; color: #fff; }
.nav-item.active { background: #f1f5ee; color: #151a18; }
.nav-item b { min-width: 26px; padding: 3px 7px; border-radius: 20px; background: rgba(128, 141, 137, .18); font-size: 11px; text-align: center; }
.sidebar-note { margin-top: auto; padding: 16px; border: 1px solid #2a3431; border-radius: 14px; color: #aeb7b4; font-size: 12px; line-height: 1.5; }
.sidebar-note p { margin: 8px 0 0; }
.eyebrow { margin: 0 0 7px; color: #77817e; font-size: 10px; font-weight: 800; letter-spacing: .17em; }
.main-content { padding: 34px 40px 60px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 3vw, 42px); letter-spacing: -.045em; }
.top-actions, .inline-actions { display: flex; gap: 10px; }
.button { border: 1px solid var(--line); border-radius: 10px; padding: 11px 15px; background: var(--white); color: var(--ink); font-weight: 750; }
.button:hover { transform: translateY(-1px); box-shadow: 0 7px 20px rgba(22,27,26,.08); }
.button.primary { border-color: var(--green); background: var(--green); color: #fff; }
.button.dark { border-color: #17211e; background: #17211e; color: #fff; }
.button.ghost { background: transparent; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 32px 0 20px; }
.stat-card { min-height: 118px; padding: 20px; display: flex; justify-content: space-between; border: 1px solid var(--line); border-radius: 16px; background: var(--white); }
.stat-card span { display: block; color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 14px; font-size: 32px; line-height: 1; }
.stat-card i { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #edf0ec; font-style: normal; font-weight: 900; }
.stat-card.urgent i { background: var(--amber-soft); color: var(--amber); }
.stat-card.success i { background: var(--green-soft); color: var(--green); }
.workspace-card { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--white); }
.toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) 190px 170px; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); }
.search-field { display: flex; gap: 10px; align-items: center; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbf9; }
.search-field input { width: 100%; padding: 11px 0; border: 0; outline: 0; background: transparent; }
select, input, textarea { border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); }
.toolbar select { padding: 0 11px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 18px; color: #7b8582; background: #fafbf9; font-size: 10px; letter-spacing: .1em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 16px 18px; border-top: 1px solid #edf0ed; vertical-align: middle; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: #fafcf9; }
.company-cell strong, .company-cell span { display: block; }
.company-cell strong { margin-bottom: 5px; }
.company-cell span { color: var(--muted); font-size: 12px; }
.status-badge, .package-badge, .action-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.status-badge { background: #edf0ed; }
.status-badge.waiting { background: var(--amber-soft); color: #895319; }
.status-badge.won { background: var(--green-soft); color: var(--green-dark); }
.status-badge.lost { background: var(--red-soft); color: var(--red); }
.package-badge { color: var(--green-dark); background: #edf5f0; }
.action-badge.overdue { color: var(--red); background: var(--red-soft); }
.action-badge.today { color: #815116; background: var(--amber-soft); }
.action-badge.upcoming { color: var(--green-dark); background: var(--green-soft); }
.row-button, .icon-button, .text-button { border: 0; background: transparent; color: inherit; }
.row-button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; font-weight: 800; }
.empty-state { padding: 70px 20px; text-align: center; }
.empty-state strong, .empty-state span { display: block; }
.empty-state span { margin-top: 8px; color: var(--muted); }
.drawer-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(6, 12, 10, .35); backdrop-filter: blur(2px); }
.lead-drawer { position: fixed; z-index: 30; top: 0; right: 0; width: min(620px, 100vw); height: 100vh; padding: 26px; overflow-y: auto; background: #fff; box-shadow: var(--shadow); transform: translateX(105%); transition: transform .25s ease; }
.lead-drawer.open { transform: translateX(0); }
.drawer-header { display: flex; justify-content: space-between; gap: 20px; }
.drawer-header h2 { margin-bottom: 7px; font-size: 30px; letter-spacing: -.035em; }
.drawer-header p:last-child { color: var(--muted); }
.icon-button { width: 38px; height: 38px; border-radius: 50%; font-size: 25px; }
.icon-button:hover { background: #f0f2ef; }
.drawer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 22px 0; }
.notice { padding: 14px 16px; border-left: 3px solid var(--amber); background: var(--amber-soft); border-radius: 8px; }
.notice strong, .notice span { display: block; }
.notice span { margin-top: 5px; color: #715531; font-size: 13px; }
.detail-section { padding: 23px 0; border-top: 1px solid var(--line); }
.detail-section h3 { margin-bottom: 14px; font-size: 16px; }
.section-title { display: flex; justify-content: space-between; }
.text-button { color: var(--green); font-weight: 800; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.detail-grid label, .detail-grid div { min-width: 0; }
.detail-grid label, .detail-grid span { color: var(--muted); font-size: 11px; font-weight: 700; }
.detail-grid select { width: 100%; margin-top: 5px; padding: 9px; color: var(--ink); }
.detail-grid strong { display: block; margin-top: 8px; font-size: 13px; }
.contact-list { display: grid; gap: 9px; }
.contact-list a { color: var(--green-dark); overflow-wrap: anywhere; }
textarea { width: 100%; padding: 12px; resize: vertical; line-height: 1.5; }
.inline-actions { margin-top: 10px; }
.save-note { margin-top: 8px; }
.timeline { margin: 0; padding: 0 0 0 19px; border-left: 1px solid var(--line); list-style: none; }
.timeline li { position: relative; padding: 0 0 18px 14px; }
.timeline li::before { content: ""; position: absolute; left: -24px; top: 4px; width: 8px; height: 8px; border: 3px solid white; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 1px var(--line); }
.timeline strong, .timeline time { display: block; }
.timeline time { margin-top: 4px; color: var(--muted); font-size: 11px; }
dialog { width: min(680px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 18px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(6, 12, 10, .48); backdrop-filter: blur(3px); }
#leadForm { padding: 26px; }
.dialog-head { display: flex; justify-content: space-between; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 20px; }
.form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.form-grid input, .form-grid select { width: 100%; padding: 11px; }
.form-grid .wide { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.toast { position: fixed; z-index: 60; bottom: 24px; left: 50%; padding: 11px 17px; border-radius: 999px; background: #17211e; color: #fff; box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, 20px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px; }
  .brand { padding-bottom: 14px; }
  .nav-list { grid-template-columns: repeat(5, minmax(88px, 1fr)); overflow-x: auto; }
  .nav-item { display: flex; justify-content: center; white-space: nowrap; }
  .nav-item span, .nav-item b { display: none; }
  .sidebar-note { display: none; }
  .main-content { padding: 24px 15px 50px; }
  .topbar { align-items: flex-start; }
  .top-actions .ghost { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .toolbar { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  th:nth-child(3), td:nth-child(3), th:nth-child(5), td:nth-child(5) { display: none; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar { display: block; }
  .top-actions { margin-top: 18px; }
  .top-actions .primary { width: 100%; }
  .drawer-actions { grid-template-columns: 1fr; }
  .lead-drawer { padding: 20px 16px; }
}
