:root {
  color-scheme: light;
  --canvas: #edf1f1;
  --paper: #ffffff;
  --paper-soft: #f7f9f8;
  --ink: #172d32;
  --muted: #536a70;
  --line: #d5dfdf;
  --line-strong: #aebfc1;
  --teal: #075d60;
  --teal-soft: #e4f1ef;
  --teal-ink: #06494c;
  --error: #a33e38;
  --error-soft: #fff0ed;
  --warning: #8c5a19;
  --warning-soft: #fbf2df;
  --success: #236e50;
  --success-soft: #e7f4ea;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; color: var(--ink); min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
::selection { color: white; background: var(--teal); }
:focus-visible { outline: 3px solid #33a9a1; outline-offset: 2px; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; }
a { color: var(--teal); text-underline-offset: .2em; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(440px, .92fr); background: var(--paper-soft); }
.login-intro { background: #0d393e; color: #f1fbf9; padding: clamp(40px, 7vw, 108px); display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.login-intro::before { content: ""; position: absolute; width: 420px; height: 420px; right: -120px; bottom: -190px; border: 1px solid rgba(199, 237, 231, .17); border-radius: 50%; box-shadow: 0 0 0 90px rgba(199, 237, 231, .045), 0 0 0 180px rgba(199, 237, 231, .025); pointer-events: none; }
.wordmark { position: absolute; top: 49px; left: clamp(40px, 7vw, 108px); display: inline-flex; padding: 10px 12px; background: #fff; border-radius: 7px; }
.wordmark img { display: block; width: 205px; height: auto; }
.brand-symbol span { color: #65c5b7; }
.login-overline { font-size: 12px; text-transform: uppercase; letter-spacing: .13em; font-weight: 700; color: #a6d8d0; margin: 70px 0 22px; }
.login-intro h1 { font-size: clamp(3rem, 5.4vw, 5.8rem); line-height: 1.04; letter-spacing: -.04em; font-weight: 640; margin: 0 0 28px; }
.login-description { color: #c6dfdb; font-size: 18px; line-height: 1.65; max-width: 48ch; margin: 0; }
.login-rule { display: flex; gap: 28px; margin-top: 76px; border-top: 1px solid #4d7173; padding-top: 22px; color: #afd0cb; font-size: 12px; white-space: nowrap; }
.login-card { width: min(448px, calc(100% - 52px)); align-self: center; justify-self: center; padding: 40px 0; }
.login-card-top { display: flex; align-items: center; justify-content: flex-end; color: var(--muted); font-size: 12px; font-weight: 650; }
.login-card h2 { font-size: 33px; letter-spacing: -.035em; margin: 49px 0 9px; }
.login-card p { line-height: 1.55; color: var(--muted); margin: 0 0 29px; }
.login-card form { display: grid; gap: 11px; }
.login-card label { font-size: 13px; font-weight: 700; }
.login-card input { height: 48px; }
#code-wrap { display: grid; gap: 11px; margin-top: 10px; }
.login-foot { border-top: 1px solid var(--line); margin-top: 45px; padding-top: 18px; color: var(--muted); font-size: 12px; }
.form-message { color: var(--error) !important; min-height: 20px; font-size: 13px; margin-top: 14px !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { background: var(--paper); border-right: 1px solid var(--line); padding: 24px 14px 14px; display: flex; flex-direction: column; min-width: 0; z-index: 5; }
.sidebar-close { display: none !important; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 5px 13px 46px; }
.brand-symbol { display: inline-grid; place-items: center; width: 36px; height: 36px; color: #fff; background: #0d393e; border-radius: 9px; font-size: 21px; letter-spacing: -.1em; font-weight: 800; }
.brand-text { font-weight: 750; font-size: 20px; letter-spacing: -.045em; line-height: 1.03; }
.brand-text small { display: block; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .005em; margin-top: 5px; }
.sidebar-section-label { padding: 0 13px 11px; color: #667f83; font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .12em; }
.nav-list { display: grid; gap: 3px; }
.nav-item { border: 0; background: transparent; width: 100%; min-height: 41px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border-radius: 8px; text-align: left; color: #344d53; font-size: 13px; font-weight: 600; transition: background .18s ease, color .18s ease; }
.nav-item:hover { background: #f1f5f4; }
.nav-item.active { color: var(--teal-ink); background: var(--teal-soft); font-weight: 720; }
.nav-icon { width: 18px; height: 18px; display: inline-grid; place-items: center; font-size: 17px; font-weight: 500; }
.nav-icon svg, .mobile-menu svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-bottom { margin-top: auto; }
.sidebar-context { display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding: 19px 10px 14px; }
.context-indicator { width: 8px; height: 8px; border-radius: 50%; background: #48a692; box-shadow: 0 0 0 4px #e7f4ef; flex: none; }
.sidebar-context strong, .sidebar-context small { display: block; }
.sidebar-context strong { font-size: 12px; line-height: 1.35; }
.sidebar-context small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.logout { color: var(--muted); }
.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 64px; flex: none; background: var(--paper); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(22px, 3vw, 50px); }
.breadcrumb { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 12px; }
.breadcrumb strong { color: var(--ink); font-weight: 680; }
.breadcrumb-slash { color: #9aafb2; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-email { color: var(--muted); font-size: 12px; }
.avatar { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; color: var(--teal-ink); background: var(--teal-soft); font-size: 12px; font-weight: 800; }
.mobile-menu { display: none !important; }
.main-content { width: min(1500px, 100%); margin: 0 auto; padding: 38px clamp(22px, 3vw, 50px) 70px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 25px; margin-bottom: 28px; }
.page-heading h1 { font-size: 29px; font-weight: 700; letter-spacing: -.035em; margin: 0 0 7px; }
.page-heading p { color: var(--muted); font-size: 13px; margin: 0; }
.page-actions { display: flex; align-items: center; gap: 9px; }

.button, .icon-button { border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); border-radius: 8px; padding: 9px 14px; min-height: 38px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; line-height: 1.3; }
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { background: var(--paper-soft); border-color: #869da0; }
.button.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.button.primary:hover:not(:disabled) { background: #064d50; border-color: #064d50; }
.button.danger { color: var(--error); border-color: #e8c5c1; background: #fff; }
.button.danger:hover { background: var(--error-soft); }
.button.full { width: 100%; margin-top: 13px; min-height: 46px; font-size: 13px; }
.text-button { border: 0; padding: 7px 0; background: none; color: var(--teal); font-weight: 700; font-size: 12px; }
.text-button:hover { text-decoration: underline; }
.icon-button { width: 38px; height: 38px; padding: 0; }

input, select, textarea { width: 100%; min-height: 38px; border: 1px solid #bccbcc; background: white; color: var(--ink); border-radius: 7px; padding: 9px 11px; outline: none; font-size: 13px; }
textarea { min-height: 90px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #778b8f; opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px #d6ece9; }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 16px; accent-color: var(--teal); padding: 0; box-shadow: none; }
.field { display: grid; gap: 7px; min-width: 0; }
.choice-fieldset { border: 0; padding: 0; margin: 0; }
.choice-fieldset legend { padding: 0 0 7px; }
.field label, .field-label { color: #365057; font-size: 11px; font-weight: 750; letter-spacing: .015em; }
.field small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.field.wide { grid-column: 1 / -1; }
.check-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.check-choice { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 7px; padding: 8px 11px; color: var(--ink); background: #fff; font-size: 12px; font-weight: 650; }
.check-choice:has(input:checked) { background: var(--teal-soft); border-color: #84b7b2; color: var(--teal-ink); }
.section-title { font-size: 15px; font-weight: 720; letter-spacing: -.015em; margin: 0 0 16px; }
.section-description { font-size: 12px; color: var(--muted); margin: -8px 0 17px; line-height: 1.5; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 27px 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 21px; }

.sheet { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.sheet-toolbar { padding: 16px 19px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.sheet-toolbar .toolbar-title { font-size: 13px; font-weight: 720; }
.sheet-toolbar small { color: var(--muted); font-size: 11px; }
.sheet-toolbar input { max-width: 280px; background: var(--paper-soft); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: 12px; }
th { color: #61777b; font-size: 10px; text-transform: uppercase; letter-spacing: .065em; font-weight: 750; background: #fbfcfb; padding: 13px 18px; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 15px 18px; border-bottom: 1px solid #e8eeee; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfa; }
.table-link { border: 0; padding: 0; background: none; color: var(--ink); font-weight: 700; text-align: left; font-size: 12px; }
.table-link:hover { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 680; }
.muted { color: var(--muted); }
.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 3px 9px; border-radius: 5px; background: #edf1f2; color: #355058; font-size: 10px; font-weight: 700; line-height: 1.3; }
.badge.active, .badge.owned { background: var(--success-soft); color: var(--success); }
.badge.archived { background: var(--warning-soft); color: var(--warning); }
.badge.removed, .badge.lost { background: var(--error-soft); color: var(--error); }
.badge.stage { background: var(--teal-soft); color: var(--teal-ink); }
.empty-state { padding: 58px 24px 66px; text-align: center; }
.empty-symbol { display: grid; place-items: center; width: 55px; height: 55px; margin: 0 auto 19px; border: 1px solid #a2bdba; border-radius: 12px; color: var(--teal); font-size: 27px; font-weight: 500; }
.empty-state h2 { font-size: 17px; margin: 0 0 7px; letter-spacing: -.02em; }
.empty-state p { color: var(--muted); max-width: 50ch; margin: 0 auto 17px; font-size: 12px; line-height: 1.55; }
.loading-row { height: 56px; background: linear-gradient(90deg, #f5f8f7 20%, #edf3f1 50%, #f5f8f7 80%); background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite; border-bottom: 1px solid var(--line); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(240px, .72fr); gap: 18px; align-items: start; }
.detail-main, .detail-aside { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.detail-main { padding: 25px; }
.detail-aside { padding: 22px; }
.detail-aside .section-title { margin-bottom: 13px; }
.detail-aside dl { margin: 0; }
.detail-aside dt { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 16px; }
.detail-aside dd { margin: 5px 0 0; font-size: 12px; overflow-wrap: anywhere; }
.detail-aside dt:first-child { margin-top: 0; }
.detail-block { border-top: 1px solid var(--line); padding-top: 26px; margin-top: 27px; }
.detail-block:first-child { border: 0; padding: 0; margin: 0; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.notice { padding: 12px 14px; background: #f2f6f5; border-radius: 8px; color: #31535a; font-size: 12px; line-height: 1.5; }
.notice.warning { background: var(--warning-soft); color: #72501f; }
.notice.error { background: var(--error-soft); color: var(--error); }
.event-list { display: grid; gap: 10px; padding: 0; list-style: none; margin: 0; }
.event-list li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.event-list li:first-child { border-top: 0; }
.event-list strong { color: var(--ink); font-weight: 680; }
.action-cell { display: flex; flex-wrap: wrap; gap: 6px; }
.action-cell .button { min-height: 29px; padding: 5px 9px; font-size: 10px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: min(420px, calc(100vw - 40px)); padding: 14px 17px; background: #173d40; color: white; border-radius: 9px; box-shadow: 0 12px 32px rgba(10, 44, 46, .22); font-size: 12px; line-height: 1.45; }
.toast.error { background: #803b35; }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-aside { order: -1; }
  .login-screen { grid-template-columns: minmax(0, .9fr) minmax(410px, 1.1fr); }
  .login-intro { padding: 50px; }
  .wordmark { left: 50px; }
  .login-rule { flex-wrap: wrap; gap: 12px 20px; }
}
@media (max-width: 720px) {
  .login-screen { display: block; background: var(--paper-soft); }
  .login-intro { min-height: 330px; padding: 38px 26px; justify-content: flex-end; }
  .wordmark { top: 24px; left: 26px; padding: 8px 10px; }
  .wordmark img { width: 170px; }
  .login-overline { margin: 40px 0 9px; }
  .login-intro h1 { font-size: 42px; margin-bottom: 11px; }
  .login-description { font-size: 13px; max-width: 45ch; }
  .login-rule { display: none; }
  .login-card { width: min(470px, calc(100% - 52px)); padding: 26px 0 45px; }
  .login-card h2 { margin-top: 25px; font-size: 27px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 252px; box-shadow: 12px 0 32px rgba(20, 42, 46, .12); transform: translateX(-110%); visibility: hidden; transition: transform .2s ease-out, visibility .2s; }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  .sidebar-close { display: inline-flex !important; position: absolute; top: 17px; right: 14px; }
  .mobile-menu { display: inline-flex !important; margin-right: 9px; }
  .topbar { height: 58px; padding: 0 18px; justify-content: flex-start; }
  .topbar-right { margin-left: auto; }
  .user-email { display: none; }
  .main-content { padding: 24px 16px 60px; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-main { padding: 20px 16px; }
  .page-actions .button { padding: 9px 10px; }
  .lead-table-wrap { overflow: visible; }
  .lead-table-wrap table, .lead-table-wrap tbody, .lead-table-wrap tr, .lead-table-wrap td { display: block; width: 100%; }
  .lead-table-wrap thead { display: none; }
  .lead-table-wrap tr { padding: 16px; border-top: 1px solid var(--line); }
  .lead-table-wrap td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0; border: 0; text-align: right; }
  .lead-table-wrap td::before { content: attr(data-label); color: var(--muted); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; text-align: left; flex: 0 0 92px; }
  .lead-table-wrap .table-link { text-align: right; }
  .lead-table-wrap .badge { white-space: normal; text-align: right; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
