:root {
  --navy-950: #071522;
  --navy-900: #0b1d2d;
  --navy-800: #123047;
  --ink: #152332;
  --muted: #6f7b87;
  --line: #dfe5e8;
  --surface: #ffffff;
  --canvas: #f3f6f7;
  --teal: #148c88;
  --teal-dark: #0d6d69;
  --teal-soft: #e4f4f3;
  --orange: #e97731;
  --orange-soft: #fff0e6;
  --green: #23835f;
  --green-soft: #e7f5ee;
  --red: #c84343;
  --red-soft: #fae9e9;
  --yellow: #9b6a00;
  --yellow-soft: #fff6d9;
  --shadow: 0 10px 30px rgba(20, 42, 61, .07);
  --radius: 16px;
  --sidebar: 258px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column; padding: 24px 18px; color: #dbe8ef; background: linear-gradient(180deg, var(--navy-950), var(--navy-900)); z-index: 30; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 28px; color: #fff; }
.brand-mark { display: inline-grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 13px; color: #fff; background: linear-gradient(135deg, var(--teal), #20b7ae); font-weight: 800; letter-spacing: -.04em; box-shadow: 0 7px 18px rgba(20, 140, 136, .28); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .01em; }
.brand small { margin-top: 1px; color: #93a8b6; font-size: 10px; }
.main-nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #aebeca; font-weight: 650; transition: .16s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: rgba(20, 140, 136, .22); box-shadow: inset 3px 0 var(--teal); }
.nav-icon { width: 22px; color: #78bebb; text-align: center; font-size: 17px; }
.sidebar-footer { margin-top: auto; padding: 18px 8px 0; border-top: 1px solid rgba(255,255,255,.09); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip strong, .user-chip small { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { color: #fff; font-size: 13px; }
.user-chip small { color: #8299a8; font-size: 10px; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark); font-weight: 800; }
.sidebar-footer .avatar { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-footer .link-button { margin-top: 11px; color: #8fa5b3; }

.main-content { min-height: 100vh; margin-left: var(--sidebar); padding: 38px clamp(24px, 4vw, 58px) 60px; }
.mobile-header { display: none; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 27px; }
.page-heading h1, .company-hero h1 { margin: 1px 0 4px; font-size: clamp(27px, 3vw, 38px); line-height: 1.15; letter-spacing: -.035em; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { margin: 0 0 4px !important; color: var(--teal-dark) !important; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
h3 { letter-spacing: -.015em; }
.muted { color: var(--muted); }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 750; line-height: 1; transition: .16s ease; }
.button:hover { transform: translateY(-1px); box-shadow: 0 7px 16px rgba(20,42,61,.1); }
.button.primary { color: #fff; background: var(--teal); }
.button.primary:hover { background: var(--teal-dark); }
.button.success { color: #fff; background: var(--green); }
.button.secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.button.ghost { color: var(--muted); background: transparent; }
.button.small { min-height: 34px; padding: 7px 11px; font-size: 13px; }
.button.tiny { min-height: 29px; padding: 6px 9px; font-size: 11px; }
.button.wide { width: 100%; }
.button-row, .form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.link-button { padding: 0; border: 0; color: var(--teal-dark); background: transparent; font-weight: 700; font-size: 12px; }
.icon-button { border: 0; background: transparent; font-size: 21px; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-bottom: 20px; }
.metric-card { position: relative; min-height: 142px; padding: 21px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: #c5d0d5; }
.metric-card.accent::before { background: var(--teal); }
.metric-card.danger::before { background: var(--red); }
.metric-card > span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-card > strong { display: block; margin: 9px 0 8px; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
.metric-card small, .metric-card a { color: var(--muted); font-size: 11px; }
.metric-card a { color: var(--teal-dark); font-weight: 750; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); gap: 20px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.dashboard-grid > .panel, .detail-panel, .form-panel, .settings-grid > .panel { padding: 22px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.panel-header a { color: var(--teal-dark); font-size: 12px; font-weight: 750; }
.compact-list { display: grid; }
.compact-row { display: flex; align-items: center; gap: 13px; padding: 13px 0; border-top: 1px solid #edf0f2; }
.compact-row:first-child { border-top: 0; }
.date-tile { display: grid; place-items: center; width: 43px; height: 48px; flex: 0 0 auto; border-radius: 9px; color: var(--teal-dark); background: var(--teal-soft); }
.date-tile.overdue { color: var(--red); background: var(--red-soft); }
.date-tile small { font-size: 9px; font-weight: 800; text-transform: uppercase; }
.date-tile strong { font-size: 17px; line-height: 1; }
.compact-main { min-width: 0; flex: 1; }
.compact-main strong, .compact-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-main small { color: var(--muted); font-size: 11px; }

.flash { max-width: 920px; margin: 0 0 20px; padding: 12px 15px; border-radius: 10px; font-weight: 650; }
.flash-success { color: #185e46; background: var(--green-soft); border: 1px solid #bfe2d2; }
.flash-error { color: #982f2f; background: var(--red-soft); border: 1px solid #edc3c3; }

.filter-bar { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.filter-bar select, .filter-bar input { min-height: 40px; }
.search-field { display: flex; align-items: center; min-width: min(380px, 42vw); padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; }
.view-switcher { display: flex; margin-left: auto; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.view-switcher a { padding: 5px 10px; border-radius: 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.view-switcher a.active { color: var(--ink); background: var(--canvas); }

.table-panel { overflow: hidden; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 13px 17px; color: var(--muted); background: #f8fafb; border-bottom: 1px solid var(--line); font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 15px 17px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcfc; }
.company-link { display: flex; align-items: center; gap: 11px; min-width: 230px; }
.company-link strong, .company-link small { display: block; }
.company-link small, .cell-subtext { color: var(--muted); font-size: 10px; }
.company-avatar { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 11px; color: var(--navy-800); background: #e6ecef; font-size: 12px; font-weight: 850; }
.company-avatar.large { width: 62px; height: 62px; border-radius: 17px; font-size: 18px; }
.cell-subtext { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.row-action { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 8px; color: var(--teal-dark); background: var(--teal-soft); font-weight: 800; }
.text-link { color: var(--teal-dark); font-weight: 700; }
.client-charge-link { display: block; }
.text-danger { color: var(--red); font-weight: 700; }
.attention-row { background: rgba(239, 158, 48, .08); }

.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; width: fit-content; padding: 4px 8px; border-radius: 99px; color: #50606d; background: #edf1f3; font-size: 9px; font-weight: 850; letter-spacing: .035em; text-transform: uppercase; white-space: nowrap; }
.badge-high, .badge-overdue, .badge-lost { color: var(--red); background: var(--red-soft); }
.badge-interested, .badge-active, .badge-active_client, .badge-won, .badge-completed { color: var(--green); background: var(--green-soft); }
.badge-proposal_sent, .badge-follow_up, .badge-medium, .badge-paused, .badge-paused_client { color: var(--yellow); background: var(--yellow-soft); }
.badge-not_contacted, .badge-contacted, .badge-prospect { color: var(--teal-dark); background: var(--teal-soft); }
.badge-do_not_contact, .badge-former_client, .badge-cancelled, .badge-declined { color: #5e6871; background: #e8ebed; }

.pipeline-board { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.pipeline-column { min-height: 520px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #eaf0f2; }
.pipeline-column > header { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 12px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.pipeline-column > header strong { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #d8e1e5; }
.pipeline-stack { display: grid; gap: 9px; }
.pipeline-card { padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: 0 4px 12px rgba(20,42,61,.05); }
.pipeline-card:hover { border-color: #abc9c7; transform: translateY(-1px); }
.pipeline-card h3 { margin: 10px 0 2px; font-size: 14px; }
.pipeline-card p, .pipeline-card small { display: block; margin: 0; color: var(--muted); font-size: 10px; }
.pipeline-empty { padding: 24px 8px; color: #99a4ad; text-align: center; font-size: 11px; }

.company-hero { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-bottom: 24px; }
.company-title { display: flex; align-items: center; gap: 16px; }
.company-title h1 { font-size: 31px; }
.hero-actions { display: flex; gap: 9px; }
.company-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 18px; align-items: start; }
.company-main { display: grid; gap: 18px; }
.company-main > .panel { padding: 22px; }
.company-side { display: grid; gap: 15px; }
.contact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.contact-card { display: flex; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: #fbfcfc; }
.contact-card strong, .contact-card small, .contact-card a { display: block; }
.contact-card small, .contact-card a { color: var(--muted); font-size: 11px; }
.contact-card a:hover { color: var(--teal-dark); }
.primary-label { color: var(--teal-dark); font-size: 8px; letter-spacing: .04em; text-transform: uppercase; }
.card-list { display: grid; }
.engagement-row, .charge-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 13px 0; border-top: 1px solid #edf0f2; }
.engagement-row:first-child, .charge-row:first-of-type { border-top: 0; }
.engagement-row small, .charge-row small { display: block; color: var(--muted); font-size: 10px; }
.engagement-value { display: flex; align-items: center; gap: 10px; text-align: right; }
.engagement-value > strong { font-size: 17px; }
.engagement-value > strong small, .charge-row > strong small { display: inline; }
.timeline { display: grid; }
.timeline-item { position: relative; display: flex; gap: 13px; padding: 0 0 20px; }
.timeline-item::before { content: ""; position: absolute; top: 10px; bottom: -2px; left: 4px; width: 1px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { position: relative; z-index: 1; width: 9px; height: 9px; margin-top: 7px; flex: 0 0 auto; border: 2px solid #fff; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 2px #a9d3d1; }
.timeline-item strong, .timeline-item small { display: block; }
.timeline-item p { margin: 3px 0; color: #485765; font-size: 12px; }
.timeline-item small { color: var(--muted); font-size: 10px; }
.timeline.compact .timeline-item { padding-bottom: 15px; }
.detail-list { margin: 0; }
.detail-list > div { display: grid; grid-template-columns: 88px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid #edf0f2; }
.detail-list > div:first-child { border-top: 0; }
.detail-list dt { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.detail-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.note-block { margin-top: 15px; padding: 13px; border-radius: 10px; background: #f7f9fa; }
.note-block strong { font-size: 11px; }
.note-block p { margin: 5px 0 0; color: #52606b; font-size: 12px; }
.side-followup { padding: 11px 0; border-top: 1px solid #edf0f2; }
.side-followup:first-of-type { border-top: 0; }
.side-followup.overdue { margin: 0 -10px; padding: 10px; border: 0; border-radius: 8px; background: var(--red-soft); }
.side-followup strong, .side-followup small { display: block; }
.side-followup small { color: var(--muted); font-size: 10px; }

.stack-form { display: grid; gap: 14px; }
.form-grid { display: grid; gap: 13px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack-form label { display: grid; gap: 5px; color: #394956; font-size: 11px; font-weight: 750; }
input, select, textarea { width: 100%; border: 1px solid #cfd8dd; border-radius: 8px; color: var(--ink); background: #fff; outline: none; }
input, select { min-height: 42px; padding: 9px 11px; }
textarea { padding: 10px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(20,140,136,.11); }
.stack-form h3 { margin: 8px 0 -2px; font-size: 15px; }
.checkbox-row { display: flex !important; align-items: center; gap: 8px !important; }
.checkbox-row input { width: 17px; min-height: 17px; }
.form-panel { max-width: 950px; }

.modal { width: min(560px, calc(100vw - 28px)); max-height: calc(100vh - 34px); padding: 26px; border: 0; border-radius: 16px; color: var(--ink); box-shadow: 0 24px 90px rgba(5,18,29,.28); overflow-y: auto; }
.wide-modal { width: min(880px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(7,21,34,.67); backdrop-filter: blur(3px); }
.modal h2 { margin: 0 0 5px; font-size: 23px; }
.modal > p { margin-top: 0; color: var(--muted); }
.modal-close { position: sticky; z-index: 2; top: -18px; display: flex; justify-content: flex-end; height: 0; }
.modal-close button { display: grid; place-items: center; width: 33px; height: 33px; border: 1px solid var(--line); border-radius: 50%; background: #fff; font-size: 20px; }
.company-edit-form { margin-top: 22px; }

.tabs { display: flex; gap: 6px; margin-bottom: 15px; }
.tabs a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 750; }
.tabs a.active { color: var(--teal-dark); background: var(--teal-soft); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-grid p { color: var(--muted); }
.check-list { display: grid; gap: 8px; padding: 0; list-style: none; }
.check-list li::before { content: "✓"; margin-right: 8px; color: var(--green); font-weight: 900; }
.empty-state { padding: 28px 14px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); }
.empty-state p { margin: 3px 0 0; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top right, rgba(20,140,136,.22), transparent 33%), linear-gradient(145deg, var(--navy-950), var(--navy-800)); }
.login-card { width: min(430px, 100%); padding: 36px; border: 1px solid rgba(255,255,255,.2); border-radius: 20px; background: rgba(255,255,255,.97); box-shadow: 0 28px 80px rgba(0,0,0,.28); }
.login-brand { margin-bottom: 20px; }
.login-card h1 { margin: 2px 0 4px; font-size: 32px; letter-spacing: -.04em; }
.login-card > .muted { margin: 0 0 22px; }
.login-security { margin: 18px 0 0; color: var(--muted); font-size: 10px; text-align: center; }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .company-layout { grid-template-columns: 1fr; }
  .company-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 20px 0 60px rgba(0,0,0,.25); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 0 17px 44px; }
  .mobile-header { display: flex; align-items: center; gap: 12px; margin: 0 -17px 24px; padding: 14px 17px; border-bottom: 1px solid var(--line); background: #fff; }
  .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-wrap: wrap; }
  .search-field { width: 100%; min-width: 100%; }
  .view-switcher { margin-left: 0; }
  .company-side { grid-template-columns: 1fr; }
}

@media (max-width: 590px) {
  .page-heading, .company-hero { align-items: stretch; flex-direction: column; }
  .page-heading .button, .hero-actions .button { flex: 1; }
  .metric-grid, .contact-grid, .form-grid.two { grid-template-columns: 1fr; }
  .metric-card { min-height: 125px; }
  .company-title { align-items: flex-start; }
  .company-avatar.large { width: 50px; height: 50px; }
  .hero-actions { width: 100%; }
  .data-table th, .data-table td { padding: 12px; }
  .modal { padding: 22px 17px; }
  .login-card { padding: 28px 23px; }
}
