:root {
    --navy-950: #0b1725;
    --navy-900: #10243a;
    --navy-800: #173a59;
    --blue-700: #176b9f;
    --cyan-500: #1cb4d9;
    --cyan-100: #dff7fc;
    --ink: #172331;
    --muted: #66788a;
    --line: #dce5ec;
    --surface: #ffffff;
    --page: #f4f7fa;
    --yellow: #fff4cf;
    --green: #167c54;
    --green-bg: #e1f5ec;
    --red: #b33b42;
    --red-bg: #fee9eb;
    --orange: #9b5b08;
    --orange-bg: #fff1d6;
    --shadow: 0 12px 36px rgba(16, 36, 58, .09);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--page); }
a { color: var(--blue-700); text-decoration: none; }
a:hover { color: var(--navy-900); }
button, input, select, textarea { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 20px 22px; background: linear-gradient(180deg, var(--navy-950), var(--navy-900)); color: #fff; display: flex; flex-direction: column; }
.brand { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; color: #fff; padding: 0 10px; }
.brand:hover { color: #fff; }
.brand-logo-crop { position: relative; display: block; width: 178px; height: 75px; overflow: hidden; }
.brand-logo { position: absolute; top: -33px; left: -42px; width: 262px; max-width: none; height: auto; display: block; }
.brand small { display: block; padding-left: 2px; color: #a9bdce; font-size: 11px; }
.nav-menu { display: grid; gap: 6px; margin-top: 24px; }
.nav-menu a { padding: 12px 14px; border-radius: 9px; color: #bdd0df; font-weight: 650; }
.nav-menu a:hover, .nav-menu a.active { color: #fff; background: rgba(28, 180, 217, .16); }
.nav-menu a.active { box-shadow: inset 3px 0 0 var(--cyan-500); }
.sidebar-user { margin-top: auto; border-top: 1px solid rgba(255,255,255,.13); padding: 18px 10px 0; }
.sidebar-user strong, .sidebar-user span { display: block; }
.sidebar-user span { margin: 3px 0 10px; color: #9fb5c6; font-size: 12px; }
.link-button { border: 0; padding: 0; color: var(--cyan-500); background: transparent; cursor: pointer; }

.main-content { min-width: 0; padding: 32px 38px 60px; }
.topbar { display: flex; gap: 24px; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.topbar h1 { margin: 3px 0 0; font-size: clamp(25px, 3vw, 35px); line-height: 1.15; color: var(--navy-900); }
.eyebrow { margin: 0; color: var(--blue-700); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 20px; }
.panel-header { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.panel-header h2, .panel-header h3 { margin: 0; color: var(--navy-900); }
.panel-body { padding: 22px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 20px; }
.metric-card { padding: 19px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.metric-card small { display: block; color: var(--muted); font-weight: 650; }
.metric-card strong { display: block; margin-top: 8px; color: var(--navy-900); font-size: 25px; }
.metric-card.accent { border-top: 4px solid var(--cyan-500); }
.metric-card.success { border-top: 4px solid #27a875; }
.metric-card.warning { border-top: 4px solid #e8a72e; }
.metric-card.danger { border-top: 4px solid #db6268; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; cursor: pointer; }
.btn-primary { color: #fff; background: var(--blue-700); }
.btn-primary:hover { color: #fff; background: var(--navy-800); }
.btn-secondary { color: var(--navy-900); background: #fff; border-color: var(--line); }
.btn-secondary:hover { background: #f5f8fa; }
.btn-danger { color: var(--red); background: #fff; border-color: #efb8bc; }
.btn-small { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.alert { margin-bottom: 18px; padding: 13px 16px; border: 1px solid; border-radius: 10px; }
.alert ul { margin: 8px 0 0; padding-left: 20px; }
.alert-success { color: var(--green); background: var(--green-bg); border-color: #b4e4d2; }
.alert-error { color: var(--red); background: var(--red-bg); border-color: #f0bdc1; }
.alert-info { color: var(--blue-700); background: #e8f5fb; border-color: #b9ddeb; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #496173; background: #f7fafc; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
td { font-size: 13px; }
tbody tr:hover { background: #fbfdfe; }
tbody tr:last-child td { border-bottom: 0; }
.money { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.client-cell strong, .client-cell span { display: block; }
.client-cell span { margin-top: 3px; color: var(--muted); font-size: 12px; }

.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.badge-follow { color: var(--blue-700); background: #e2f2fa; }
.badge-promise { color: var(--orange); background: var(--orange-bg); }
.badge-renewed, .badge-active { color: var(--green); background: var(--green-bg); }
.badge-noanswer { color: #6c547e; background: #f0eafa; }
.badge-lost { color: var(--red); background: var(--red-bg); }
.badge-pending { color: var(--orange); background: var(--orange-bg); }
.badge-closed { color: #52616d; background: #e9eef2; }

.form-stack { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-grid .span-2 { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: #344d60; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cbd8e1; border-radius: 8px; color: var(--ink); background: #fff; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(28,180,217,.15); border-color: var(--cyan-500); }
textarea { min-height: 105px; resize: vertical; }
.check-row { display: flex; align-items: center; gap: 9px; }
.check-row input { width: 17px; min-height: 17px; }
.field-help { margin: -2px 0 0; color: var(--muted); font-size: 11px; font-weight: 400; }
.filter-bar { display: grid; grid-template-columns: 2fr repeat(3, minmax(140px, .8fr)) auto; gap: 10px; align-items: end; padding: 16px; }
.filter-bar label { font-size: 11px; }

.tabs { display: flex; gap: 8px; overflow-x: auto; margin: 0 0 14px; padding-bottom: 4px; }
.tab { flex: 0 0 auto; padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; color: #526a7c; background: #fff; font-size: 12px; font-weight: 700; }
.tab.active { color: #fff; border-color: var(--blue-700); background: var(--blue-700); }

.progress-track { height: 12px; overflow: hidden; border-radius: 999px; background: #e5edf2; }
.progress-bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan-500), #2388bd); }
.progress-meta { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 12px; }
.definition-list { display: grid; grid-template-columns: 160px 1fr; margin: 0; }
.definition-list dt, .definition-list dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line); }
.definition-list dt { color: var(--muted); font-size: 12px; }
.definition-list dd { font-weight: 650; }
.empty-state { padding: 46px 24px; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--navy-900); }
.notice { padding: 13px 15px; border-left: 4px solid var(--cyan-500); background: #eef9fc; color: #315a70; }
.warning-box { border-left-color: #e8a72e; background: #fff7e6; color: #70531f; }
.danger-box { border-left-color: #db6268; background: #fff0f1; color: #7f3338; }
.list-clean { margin: 0; padding-left: 18px; }
.list-clean li + li { margin-top: 6px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; padding: 18px; color: var(--muted); font-size: 12px; }
.pagination a, .pagination .disabled { padding: 7px 11px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.pagination .disabled { opacity: .55; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #173d5c, var(--navy-950) 55%); }
.login-card { width: min(430px, 100%); padding: 34px; overflow: hidden; border-radius: 18px; background: #fff; box-shadow: 0 25px 70px rgba(0,0,0,.3); }
.login-card h1 { margin: 8px 0 3px; color: var(--navy-900); }
.login-brand { display: flex; align-items: center; justify-content: center; margin: -4px 0 24px; }
.login-logo-crop { position: relative; display: block; width: 210px; height: 88px; overflow: hidden; }
.login-logo { position: absolute; top: -39px; left: -50px; width: 309px; max-width: none; height: auto; display: block; }

@media (max-width: 1100px) {
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: auto; height: auto; padding: 16px; }
    .nav-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 18px; }
    .sidebar-user { margin-top: 16px; }
    .main-content { padding: 24px 16px 50px; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .cards, .grid-2, .grid-3, .form-grid, .filter-bar { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .definition-list { grid-template-columns: 1fr; }
    .definition-list dt { padding-bottom: 0; border-bottom: 0; }
    .definition-list dd { padding-top: 4px; }
}
