:root {
    --ink: #111111;
    --ink-soft: #242424;
    --paper: #f4f1e9;
    --paper-deep: #eae5d9;
    --card: #ffffff;
    --muted: #6c6c68;
    --line: rgba(17, 17, 17, 0.13);
    --line-strong: rgba(17, 17, 17, 0.23);
    --accent: #d6ff37;
    --accent-dark: #9fc800;
    --blue: #3178f6;
    --danger: #c83b42;
    --warning: #e69824;
    --success: #2f8b57;
    --shadow: 0 18px 52px rgba(0, 0, 0, 0.09);
    --sidebar: 270px;
    --radius: 17px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: Arial, Helvetica, sans-serif; line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: #0b0b0b; color: #fff; padding: 26px 18px 20px; overflow-y: auto; z-index: 50; }
.sidebar-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 0 8px; }
.wordmark { display: inline-flex; flex-direction: column; text-decoration: none; font-weight: 900; line-height: .83; letter-spacing: .08em; font-size: 1.25rem; }
.wordmark span:last-child { color: var(--accent); }
.sidebar-wordmark { color: #fff; font-size: 1.35rem; }
.sidebar-label { color: rgba(255,255,255,.45); font-size: .68rem; font-weight: 800; letter-spacing: .22em; margin: 14px 8px 24px; }
.sidebar-nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 10px; border-radius: 11px; color: rgba(255,255,255,.72); text-decoration: none; font-size: .92rem; font-weight: 700; transition: .18s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); transform: translateX(2px); }
.nav-item.is-active { color: var(--ink); background: var(--accent); }
.nav-icon { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.16); border-radius: 8px; font-size: .58rem; font-weight: 900; letter-spacing: .04em; }
.nav-item.is-active .nav-icon { border-color: rgba(17,17,17,.18); }
.nav-divider { height: 1px; background: rgba(255,255,255,.1); margin: 18px 8px 14px; }
.nav-section { margin: 0 10px 5px; color: rgba(255,255,255,.4); font-size: .61rem; font-weight: 800; letter-spacing: .18em; }
.sidebar-footer { margin-top: auto; padding: 22px 8px 0; border-top: 1px solid rgba(255,255,255,.11); }
.sidebar-user { display: flex; align-items: center; gap: 11px; }
.sidebar-user strong, .sidebar-user small { display: block; }
.sidebar-user strong { font-size: .88rem; }
.sidebar-user small { color: rgba(255,255,255,.48); font-size: .71rem; }
.avatar, .topbar-avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--ink); font-weight: 900; text-decoration: none; flex: 0 0 auto; }
.sidebar-links { display: flex; gap: 13px; margin-top: 13px; }
.sidebar-links a { color: rgba(255,255,255,.56); font-size: .72rem; }
.sidebar-links a:hover { color: #fff; }
.sidebar-close { display: none; color: #fff; }
.sidebar-backdrop { display: none; }

.main-panel { min-width: 0; display: flex; min-height: 100vh; flex-direction: column; }
.topbar { min-height: 86px; padding: 18px clamp(20px, 4vw, 50px); display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); background: rgba(244,241,233,.93); backdrop-filter: blur(15px); position: sticky; top: 0; z-index: 30; }
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar h1 { font-size: clamp(1.45rem, 3vw, 2rem); line-height: 1; margin: 2px 0 0; }
.topbar-eyebrow { margin: 0; color: var(--muted); font-size: .64rem; font-weight: 900; letter-spacing: .18em; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.quick-add { padding: 11px 15px; background: var(--ink); color: #fff; border-radius: 10px; text-decoration: none; font-weight: 800; font-size: .86rem; }
.quick-add:hover { background: var(--accent); color: var(--ink); }
.icon-button { border: 0; background: transparent; cursor: pointer; font-size: 1.4rem; padding: 7px; }
.menu-toggle { display: none; }
.content-wrap { width: 100%; padding: clamp(24px, 4vw, 50px); flex: 1; }
.app-footer { display: flex; justify-content: space-between; gap: 20px; padding: 22px clamp(20px,4vw,50px); color: var(--muted); border-top: 1px solid var(--line); font-size: .78rem; }

.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 26px; }
.page-heading h2 { margin: 0 0 5px; font-size: clamp(1.8rem, 3.5vw, 2.8rem); line-height: .98; }
.page-heading p { margin: 0; color: var(--muted); max-width: 670px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.section-kicker, .eyebrow { margin: 0 0 8px; color: var(--accent-dark); font-size: .68rem; font-weight: 900; letter-spacing: .18em; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stack { display: grid; gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 7px 28px rgba(0,0,0,.035); }
.card-pad { padding: 24px; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 21px 24px; border-bottom: 1px solid var(--line); }
.card-header h3 { margin: 0; font-size: 1rem; }
.card-header p { margin: 3px 0 0; color: var(--muted); font-size: .8rem; }
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--line); }
.metric-card { position: relative; padding: 22px; overflow: hidden; }
.metric-card::after { content: ''; position: absolute; width: 90px; height: 90px; right: -47px; top: -47px; border: 18px solid var(--accent); border-radius: 50%; opacity: .7; }
.metric-label { display: block; color: var(--muted); font-size: .73rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.metric-value { display: block; margin: 9px 0 2px; font-size: clamp(1.65rem, 3vw, 2.25rem); font-weight: 900; line-height: 1; }
.metric-note { color: var(--muted); font-size: .76rem; }
.metric-link { position: absolute; inset: 0; text-indent: -9999px; }

.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 42px; padding: 10px 15px; border: 1px solid transparent; border-radius: 10px; text-decoration: none; font-weight: 900; font-size: .84rem; cursor: pointer; transition: .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--accent); color: var(--ink); }
.button-primary:hover { background: #c8f02e; }
.button-dark { background: var(--ink); color: #fff; }
.button-outline { border-color: var(--line-strong); background: transparent; color: var(--ink); }
.button-danger { background: #fff0f0; color: var(--danger); border-color: rgba(200,59,66,.2); }
.button-small { min-height: 34px; padding: 7px 11px; font-size: .73rem; }
.button-block { width: 100%; }
.link-button { border: 0; padding: 0; background: none; color: var(--blue); cursor: pointer; font-weight: 800; }

.alert { padding: 14px 17px; border-radius: 11px; margin-bottom: 18px; border: 1px solid transparent; font-size: .9rem; }
.alert.success { background: #ebf8ef; border-color: #cdebd7; color: #216a41; }
.alert.danger, .alert.error { background: #fff0f0; border-color: #f0c9cb; color: #9b2f35; }
.alert.warning { background: #fff6e6; border-color: #f2dfbb; color: #8b5b16; }
.alert.info { background: #eef5ff; border-color: #cbdfff; color: #24569d; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { min-width: 0; }
.field-full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 7px; font-size: .78rem; font-weight: 900; }
.field .hint { display: block; margin-top: 6px; color: var(--muted); font-size: .7rem; }
.field input, .field select, .field textarea { width: 100%; min-height: 45px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--ink); padding: 11px 13px; outline: none; }
.field textarea { min-height: 118px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(214,255,55,.45); }
.field input[type="checkbox"], .field input[type="radio"] { width: auto; min-height: 0; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(170px,1fr)); gap: 10px; }
.check-card { display: flex; gap: 9px; align-items: center; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.form-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 150px; }
.filter-bar { display: flex; align-items: flex-end; gap: 11px; flex-wrap: wrap; padding: 17px; margin-bottom: 18px; background: rgba(255,255,255,.65); border: 1px solid var(--line); border-radius: 14px; }
.filter-bar .field { flex: 1 1 150px; }
.filter-bar .field-search { flex: 2 1 260px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .09em; }
td { font-size: .84rem; }
tbody tr:hover { background: #faf9f5; }
tbody tr:last-child td { border-bottom: 0; }
.table-primary { color: var(--ink); font-weight: 900; text-decoration: none; }
.table-primary:hover { text-decoration: underline; }
.table-secondary { display: block; color: var(--muted); font-size: .73rem; margin-top: 3px; }
.row-actions { display: flex; gap: 8px; }
.empty-state { padding: 50px 26px; text-align: center; }
.empty-state strong { display: block; font-size: 1.4rem; margin-bottom: 7px; }
.empty-state p { color: var(--muted); max-width: 480px; margin: 0 auto 18px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; font-size: .66rem; font-weight: 900; white-space: nowrap; }
.badge.neutral { background: #ededeb; color: #555; }
.badge.success { background: #e3f5e9; color: #277248; }
.badge.danger { background: #fee8e8; color: #a02f35; }
.badge.warning { background: #fff0d3; color: #95601a; }
.badge.info { background: #e7f0ff; color: #2b60b0; }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; background: #aaa; }
.priority-dot.hot, .priority-dot.high { background: var(--danger); }
.priority-dot.normal { background: var(--blue); }
.priority-dot.low { background: #aaa; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(290px, .75fr); gap: 20px; align-items: start; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0; }
.detail-item { padding: 15px 0; border-bottom: 1px solid var(--line); }
.detail-item:nth-child(odd) { padding-right: 20px; }
.detail-item span { display: block; color: var(--muted); font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.detail-item strong, .detail-item a { display: block; margin-top: 4px; font-size: .88rem; word-break: break-word; }
.notes-block { white-space: pre-wrap; font-size: .9rem; }
.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; padding: 0 0 22px 28px; }
.timeline-item::before { content: ''; position: absolute; left: 7px; top: 8px; bottom: -5px; width: 1px; background: var(--line-strong); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { position: absolute; left: 1px; top: 4px; width: 13px; height: 13px; background: var(--accent); border: 3px solid var(--ink); border-radius: 50%; }
.timeline-item h4 { margin: 0 0 2px; font-size: .9rem; }
.timeline-item p { margin: 5px 0; color: #444; font-size: .84rem; white-space: pre-wrap; }
.timeline-meta { color: var(--muted); font-size: .7rem; }

.progress { height: 8px; background: #e9e8e3; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent-dark); border-radius: inherit; }
.pipeline { display: grid; grid-template-columns: repeat(7, minmax(130px,1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.pipeline-column { min-height: 230px; background: rgba(255,255,255,.62); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.pipeline-column h3 { margin: 2px 2px 12px; font-size: .78rem; }
.pipeline-card { display: block; margin-bottom: 10px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 11px; text-decoration: none; box-shadow: 0 3px 12px rgba(0,0,0,.03); }
.pipeline-card strong { display: block; font-size: .79rem; }
.pipeline-card span { color: var(--muted); font-size: .69rem; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(100px, 1fr)); border: 1px solid var(--line); border-radius: 15px; overflow-x: auto; background: var(--card); }
.calendar-head { padding: 11px; background: var(--ink); color: #fff; font-size: .66rem; font-weight: 900; text-align: center; }
.calendar-day { min-height: 125px; padding: 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day.is-muted { background: #f7f5ef; color: #aaa; }
.calendar-number { font-size: .72rem; font-weight: 900; }
.calendar-event { display: block; margin-top: 6px; padding: 5px 7px; border-radius: 7px; background: #eef5ff; color: #24569d; font-size: .62rem; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event.task { background: #fff2d8; color: #865916; }

.chart-bars { display: grid; gap: 13px; }
.chart-row { display: grid; grid-template-columns: minmax(110px, 180px) minmax(120px, 1fr) 90px; gap: 13px; align-items: center; }
.chart-label { font-size: .75rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; }
.chart-track { height: 13px; background: #e9e7e0; border-radius: 999px; overflow: hidden; }
.chart-fill { height: 100%; min-width: 2px; background: var(--accent-dark); border-radius: inherit; }
.chart-value { text-align: right; font-size: .73rem; font-weight: 900; }

.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 22px; }
.page-link, .page-gap { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; text-decoration: none; font-size: .78rem; }
.page-link { background: #fff; border: 1px solid var(--line); }
.page-link.is-current { background: var(--ink); color: #fff; }

.login-body { min-height: 100vh; background: #0b0b0b; color: #fff; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(400px, .7fr); }
.login-brand { display: flex; flex-direction: column; justify-content: center; padding: clamp(42px, 8vw, 110px); position: relative; overflow: hidden; }
.login-brand::after { content: ''; position: absolute; width: 520px; height: 520px; border: 85px solid var(--accent); border-radius: 50%; right: -290px; bottom: -290px; opacity: .85; }
.login-brand .wordmark { font-size: 1.7rem; margin-bottom: 72px; }
.login-brand h1 { margin: 8px 0 22px; font-size: clamp(2.7rem, 6.5vw, 6.4rem); line-height: .86; letter-spacing: -.06em; max-width: 900px; }
.login-brand h1 em { color: var(--accent); font-style: normal; }
.login-brand > p:last-child { max-width: 560px; color: rgba(255,255,255,.62); font-size: 1.02rem; }
.login-card { display: flex; flex-direction: column; justify-content: center; background: var(--paper); color: var(--ink); padding: clamp(38px, 6vw, 86px); }
.login-card h2 { font-size: clamp(2rem,4vw,3.3rem); line-height: 1; margin: 0 0 28px; }
.login-help { color: var(--muted); text-align: center; font-size: .78rem; margin-top: 18px; }

.stat-pair { display: flex; justify-content: space-between; align-items: baseline; gap: 15px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.stat-pair:last-child { border-bottom: 0; }
.stat-pair span { color: var(--muted); font-size: .78rem; }
.stat-pair strong { font-size: .93rem; }
.commission-total { padding: 25px; background: var(--ink); color: #fff; border-radius: var(--radius); }
.commission-total span { color: rgba(255,255,255,.55); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.commission-total strong { display: block; color: var(--accent); font-size: clamp(2rem,4vw,3.4rem); line-height: 1; margin-top: 9px; }

.billing-lines { margin-top: 22px; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: #fff; }
.billing-line-head, .billing-line-row { display: grid; grid-template-columns: minmax(220px, 1fr) 110px 150px 130px; gap: 10px; align-items: center; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.billing-line-head { background: #f8f7f2; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.billing-line-row:last-child { border-bottom: 0; }
.billing-line-row input { width: 100%; min-height: 40px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 9px 10px; }
.billing-line-row output { text-align: right; font-weight: 900; font-size: .82rem; }

@media (max-width: 1180px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; left: 0; top: 0; width: min(310px, 88vw); transform: translateX(-105%); transition: transform .22s ease; }
    .sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.55); }
    .sidebar-open .sidebar-backdrop { display: block; }
    .sidebar-close, .menu-toggle { display: inline-flex; }
    .topbar { min-height: 75px; }
    .topbar-avatar { display: none; }
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { min-height: 46vh; padding-bottom: 50px; }
    .login-brand .wordmark { margin-bottom: 35px; }
    .login-card { min-height: 54vh; }
}

@media (max-width: 700px) {
    .content-wrap { padding: 22px 15px 34px; }
    .topbar { padding: 14px 15px; }
    .topbar h1 { font-size: 1.25rem; }
    .quick-add { padding: 10px 12px; font-size: .76rem; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .field-full { grid-column: auto; }
    .detail-list { grid-template-columns: 1fr; }
    .detail-item:nth-child(odd) { padding-right: 0; }
    .card-header, .card-body, .card-pad { padding: 19px; }
    .table-wrap { margin-inline: -1px; }
    th, td { padding: 12px; }
    .app-footer { flex-direction: column; }
    .chart-row { grid-template-columns: 95px 1fr 72px; }
    .billing-line-head { display: none; }
    .billing-line-row { grid-template-columns: 1fr 90px; }
    .billing-line-row input:first-child { grid-column: 1 / -1; }
    .billing-line-row output { text-align: left; }
    .login-brand { min-height: auto; padding: 44px 25px; }
    .login-brand::after { width: 300px; height: 300px; border-width: 50px; right: -190px; bottom: -190px; }
    .login-brand h1 { font-size: 3rem; }
    .login-card { padding: 42px 24px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
