:root {
    --primary: #0f9f8a;
    --primary-dark: #0b766c;
    --secondary: #3b82f6;
    --accent: #f97316;
    --pink: #ec4899;
    --violet: #8b5cf6;
    --danger: #e05252;
    --warning: #f4b740;
    --success: #22c55e;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fbff;
    --border: #d9e4ee;
    --text: #162033;
    --muted: #64748b;
    --shadow: 0 18px 45px rgba(26, 42, 68, .11);
    --shadow-soft: 0 10px 30px rgba(26, 42, 68, .08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(15, 159, 138, .08), transparent 34%),
        linear-gradient(225deg, rgba(249, 115, 22, .08), transparent 30%),
        var(--bg);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    line-height: 1.45;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(22, 32, 51, .04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(22, 32, 51, .04) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .75), transparent 72%);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}

button:hover {
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

.hidden {
    display: none !important;
}

.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 410px;
    max-width: 100%;
    overflow: hidden;
    background: rgba(255, 255, 255, .9);
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 16px;
    padding: 34px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.auth-card::before {
    content: "";
    display: block;
    height: 5px;
    margin: -34px -34px 28px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent), var(--pink));
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 26px;
    font-weight: 900;
}

.auth-mark,
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 0;
    box-shadow: 0 12px 24px rgba(15, 159, 138, .28);
}

.auth-title {
    margin-bottom: 22px;
    color: var(--muted);
    text-align: center;
}

.auth-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0 0 20px;
}

.auth-badges span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.auth-card input {
    width: 100%;
    margin-bottom: 12px;
}

.auth-error {
    min-height: 20px;
    margin-top: 12px;
    color: var(--danger);
    font-size: 14px;
    text-align: center;
}

.auth-hint {
    margin-top: 18px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

.app {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 28px;
    border-bottom: 1px solid rgba(217, 228, 238, .85);
    background: rgba(255, 255, 255, .86);
    box-shadow: 0 8px 26px rgba(26, 42, 68, .07);
    backdrop-filter: blur(16px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.brand-mark {
    flex: 0 0 auto;
}

.logo {
    color: var(--text);
    font-size: 22px;
    font-weight: 900;
    line-height: 1.1;
}

.logo-sub {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.topbar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

#userRoleBadge {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid rgba(15, 159, 138, .18);
    border-radius: 999px;
    background: #e9fbf6;
    color: #0d7466;
    font-size: 13px;
    font-weight: 900;
}

.tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 28px;
    border-bottom: 1px solid rgba(217, 228, 238, .88);
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(10px);
}

.tab-btn {
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 10px 16px;
    background: #eef5fb;
    color: #314156;
    cursor: pointer;
    font-size: 14px;
    font-weight: 900;
    white-space: nowrap;
}

.tab-btn:hover {
    border-color: rgba(59, 130, 246, .25);
    background: #e7f0fb;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    box-shadow: 0 12px 24px rgba(15, 159, 138, .22);
}

.content {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 26px 28px 42px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.card,
.dashboard-card,
.table-wrapper {
    border: 1px solid rgba(217, 228, 238, .9);
    background: rgba(255, 255, 255, .92);
    box-shadow: var(--shadow-soft);
}

.card {
    margin-bottom: 20px;
    padding: 20px;
    border-radius: 8px;
}

.card h3 {
    margin-bottom: 12px;
    font-size: 17px;
}

.muted {
    color: var(--muted);
    font-size: 14px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.dashboard-card {
    --card-accent: var(--primary);
    position: relative;
    overflow: hidden;
    min-height: 132px;
    padding: 20px;
    border-radius: 8px;
}

.dashboard-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: var(--card-accent);
}

.dashboard-card:nth-child(1) {
    --card-accent: var(--primary);
    background: linear-gradient(180deg, #ffffff, #f1fffb);
}

.dashboard-card:nth-child(2) {
    --card-accent: var(--secondary);
    background: linear-gradient(180deg, #ffffff, #f2f7ff);
}

.dashboard-card:nth-child(3) {
    --card-accent: var(--accent);
    background: linear-gradient(180deg, #ffffff, #fff7f0);
}

.dashboard-card:nth-child(4) {
    --card-accent: var(--pink);
    background: linear-gradient(180deg, #ffffff, #fff4fa);
}

.dashboard-title,
.dashboard-card h3 {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.dashboard-value {
    margin-top: 10px;
    color: var(--text);
    font-size: clamp(26px, 4vw, 34px);
    font-weight: 950;
    line-height: 1.05;
}

.dashboard-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
}

.alerts-block {
    min-height: 48px;
    margin-bottom: 18px;
    padding: 13px 16px;
    border: 1px solid rgba(244, 183, 64, .45);
    border-left: 5px solid var(--warning);
    border-radius: 8px;
    background: #fff9e8;
    color: #8a5d00;
    font-weight: 900;
}

.list-row {
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}

.list-row:last-child {
    border-bottom: none;
}

.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.toolbar input,
.toolbar select {
    min-width: 220px;
}

.table-wrapper {
    overflow: auto;
    border-radius: 8px;
}

table {
    width: 100%;
    min-width: 1500px;
    border-collapse: collapse;
}

#aoTable {
    min-width: 1160px;
}

#buhTable {
    min-width: 1500px;
}

#aoTable th,
#aoTable td {
    padding: 10px 8px;
}

#aoTable .link-btn {
    max-width: 180px;
}

#aoTable .inline-phone {
    min-width: 178px;
}

#aoTable .inline-paidPeriod {
    min-width: 230px;
}

#aoTable .tariff-dropdown {
    min-width: 190px;
}

#aoTable .inline-service-period {
    min-width: 220px;
}

#aoTable .inline-date-pair {
    grid-template-columns: repeat(2, minmax(102px, 1fr));
}

thead {
    background: #f2f6fb;
}

th,
td {
    padding: 14px 15px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
    font-size: 14px;
}

th {
    color: #526276;
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .02em;
    text-transform: uppercase;
}

tbody tr {
    transition: background .16s ease;
}

tbody tr:hover {
    background: #f8fbff;
}

.action-buttons {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.cell-stack {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.cell-actions {
    display: grid;
    gap: 8px;
    justify-items: start;
}

.icon-btn,
.link-btn {
    border: none;
    cursor: pointer;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    border-radius: 10px;
    background: #edf4fb;
    color: #314156;
}

.icon-btn:hover {
    background: #dcebf8;
}

.link-btn {
    max-width: 280px;
    background: none;
    color: #0f766e;
    font-weight: 900;
    text-align: left;
    text-decoration: none;
}

.link-btn:hover {
    color: #0b5f59;
    text-decoration: underline;
}

.inline-edit {
    width: 100%;
    min-width: 96px;
    min-height: 34px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 7px 8px;
    background: rgba(255, 255, 255, .42);
    color: #314156;
    font-size: 13px;
    font-weight: 850;
    line-height: 1.2;
}

td:hover .inline-edit {
    border-color: var(--border);
    background: #fff;
}

.inline-edit:focus {
    border-color: rgba(15, 159, 138, .65);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(15, 159, 138, .11);
}

.inline-edit.saving {
    border-color: rgba(244, 183, 64, .6);
    background: #fff9df;
}

.inline-number {
    min-width: 96px;
    max-width: 120px;
}

.inline-date {
    min-width: 138px;
}

.inline-phone {
    min-width: 210px;
}

.inline-paidPeriod {
    min-width: 260px;
}

.inline-payment {
    min-width: 132px;
}

.tariff-picker {
    width: 100%;
}

.tariff-picker select {
    width: 100%;
}

.tariff-dropdown {
    position: relative;
    min-width: 210px;
}

.tariff-summary {
    min-height: 36px;
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 34px 7px 10px;
    background: rgba(255, 255, 255, .72);
    color: #314156;
    cursor: pointer;
    font-size: 13px;
    font-weight: 900;
    list-style: none;
    white-space: normal;
}

.tariff-summary::-webkit-details-marker {
    display: none;
}

.tariff-summary::after {
    content: "⌄";
    position: absolute;
    right: 12px;
    color: var(--muted);
    font-size: 16px;
}

.tariff-dropdown[open] .tariff-summary {
    border-color: rgba(15, 159, 138, .65);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(15, 159, 138, .11);
}

.tariff-dropdown-menu {
    display: grid;
    gap: 4px;
    margin-top: 6px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.tariff-check {
    display: grid;
    grid-template-columns: 18px minmax(62px, 1fr) auto;
    gap: 8px;
    align-items: center;
    min-height: 30px;
    padding: 4px 6px;
    border-radius: 6px;
    color: #314156;
    font-size: 13px;
    font-weight: 850;
}

.tariff-check:hover {
    background: #f3f8fb;
}

.tariff-check input {
    width: 16px;
    height: 16px;
    padding: 0;
}

.tariff-check b {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.inline-service-period {
    display: grid;
    gap: 6px;
    min-width: 250px;
}

.inline-service-period .inline-edit {
    min-width: 0;
}

.inline-date-pair {
    display: grid;
    grid-template-columns: minmax(118px, 1fr) minmax(118px, 1fr);
    gap: 6px;
}

.inline-service-period small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 6px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 950;
    white-space: nowrap;
}

.status-active {
    background: #dff9ef;
    color: #0f766e;
}

.status-wait {
    background: #fff3c7;
    color: #8a5d00;
}

.status-paid {
    background: #dcfce7;
    color: #157f3b;
}

.status-debt {
    background: #ffe4e1;
    color: #c2372b;
}

.status-refusal {
    background: #edf1f5;
    color: #5c6875;
}

input,
select,
textarea {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 13px;
    outline: none;
    background: #fff;
    color: var(--text);
    font-size: 14px;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(15, 159, 138, .65);
    box-shadow: 0 0 0 4px rgba(15, 159, 138, .12);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-note {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    border: none;
    border-radius: 10px;
    padding: 11px 17px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 950;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 12px 22px rgba(15, 159, 138, .22);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary), #2563eb);
    color: #fff;
    box-shadow: 0 12px 22px rgba(37, 99, 235, .18);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #c93c3c);
    color: #fff;
}

.btn-note {
    border: 1px solid rgba(249, 115, 22, .2);
    background: #fff4ed;
    color: #9a4b0f;
}

.btn-note:hover {
    background: #ffe8d8;
}

.notes-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 950;
}

.buttons-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.section-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.section-title h3 {
    font-size: 18px;
}

.section-title span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 850;
}

.profit-board {
    margin-bottom: 20px;
    padding: 20px;
    border: 1px solid rgba(217, 228, 238, .9);
    border-radius: 8px;
    background: rgba(255, 255, 255, .92);
    box-shadow: var(--shadow-soft);
}

.profit-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.profit-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fbff;
}

.profit-card h4 {
    font-size: 15px;
    font-weight: 950;
}

.profit-total {
    color: var(--text);
    font-size: 26px;
    font-weight: 950;
    line-height: 1.1;
}

.profit-lines {
    display: grid;
    gap: 8px;
}

.profit-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    color: #3f5067;
    font-size: 13px;
    font-weight: 850;
}

.profit-line strong {
    color: var(--text);
    font-weight: 950;
}

.reports-grid {
    display: grid;
    grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr);
    gap: 18px;
}

.import-panel {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(11, 18, 32, .52);
    backdrop-filter: blur(8px);
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 920px;
    max-width: 100%;
    max-height: 90vh;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 30px 70px rgba(11, 18, 32, .28);
    padding: 24px;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 22px;
}

.modal-header h2 {
    font-size: 22px;
    line-height: 1.2;
}

.modal-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: #eef4fa;
    color: #334155;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
}

.close-btn:hover {
    background: #e0ebf5;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 7px;
    color: #3f5067;
    font-size: 13px;
    font-weight: 950;
}

.form-group.full {
    grid-column: 1 / -1;
}

.tariff-multi {
    min-height: 148px;
}

.tariff-hint {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

.modal-footer {
    margin-top: 22px;
    text-align: right;
}

.section-block {
    margin-bottom: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.section-block h3 {
    margin-bottom: 10px;
}

.notes-content {
    width: 820px;
}

.notes-layout {
    display: grid;
    grid-template-columns: minmax(260px, 330px) 1fr;
    gap: 18px;
    align-items: start;
}

.notes-form {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid rgba(15, 159, 138, .16);
    border-radius: 8px;
    background: linear-gradient(180deg, #f2fffb, #ffffff);
}

.notes-form textarea {
    min-height: 190px;
}

.note-tools {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.note-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.notes-list {
    display: grid;
    max-height: 520px;
    overflow: auto;
    gap: 12px;
    padding-right: 4px;
}

.note-card {
    --note-accent: var(--primary);
    padding: 14px;
    border: 1px solid var(--border);
    border-left: 5px solid var(--note-accent);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(26, 42, 68, .06);
}

.note-card.note-blue {
    --note-accent: var(--secondary);
}

.note-card.note-orange {
    --note-accent: var(--accent);
}

.note-card.note-pink {
    --note-accent: var(--pink);
}

.note-card.note-violet {
    --note-accent: var(--violet);
}

.note-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.note-card-title {
    font-weight: 950;
    overflow-wrap: anywhere;
}

.note-date {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.note-text {
    color: #384860;
    font-size: 14px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.note-card-actions {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

.notes-empty {
    display: grid;
    place-items: center;
    min-height: 210px;
    padding: 26px;
    border: 1px dashed rgba(100, 116, 139, .38);
    border-radius: 8px;
    background: #f8fbff;
    color: var(--muted);
    text-align: center;
    font-weight: 800;
}

.locked-panel {
    display: grid;
    place-items: center;
    min-height: 320px;
    padding: 34px;
    border: 1px dashed rgba(100, 116, 139, .35);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(15, 159, 138, .07), transparent),
        #fff;
    text-align: center;
    box-shadow: var(--shadow-soft);
}

.locked-panel h3 {
    margin-bottom: 8px;
    font-size: 22px;
}

.locked-panel p {
    max-width: 520px;
    color: var(--muted);
    font-weight: 800;
}

.tab-btn.locked {
    color: #7b8796;
}

.tab-btn.locked::after {
    content: "закрыто";
    margin-left: 8px;
    padding: 3px 7px;
    border-radius: 999px;
    background: #e3eaf2;
    color: #64748b;
    font-size: 10px;
    font-weight: 950;
    text-transform: uppercase;
}

.drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: none;
    justify-content: flex-end;
    background: rgba(11, 18, 32, .32);
    backdrop-filter: blur(5px);
}

.drawer-overlay.active {
    display: flex;
}

.clients-drawer {
    width: min(430px, 100%);
    height: 100%;
    overflow: auto;
    padding: 22px;
    border-left: 1px solid rgba(217, 228, 238, .9);
    background: rgba(255, 255, 255, .97);
    box-shadow: -20px 0 55px rgba(11, 18, 32, .18);
    animation: drawerIn .2s ease-out;
}

@keyframes drawerIn {
    from {
        transform: translateX(28px);
        opacity: .6;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.drawer-header h2 {
    font-size: 24px;
    line-height: 1.1;
}

#clientsDrawerSearch {
    width: 100%;
    margin-bottom: 14px;
}

.clients-drawer-list {
    display: grid;
    gap: 10px;
}

.client-list-item {
    display: grid;
    width: 100%;
    gap: 7px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    box-shadow: 0 8px 18px rgba(26, 42, 68, .05);
}

.client-list-item:hover {
    border-color: rgba(15, 159, 138, .38);
    background: #f5fffb;
}

.client-list-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    font-weight: 950;
}

.client-list-meta {
    display: grid;
    gap: 3px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.type-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eaf2ff;
    color: #2563eb;
    font-size: 11px;
    font-weight: 950;
    white-space: nowrap;
}

.type-badge.buh {
    background: #e9fbf6;
    color: #0d7466;
}

.type-badge.ao {
    background: #fff1e7;
    color: #b35311;
}

.client-empty {
    padding: 22px;
    border: 1px dashed rgba(100, 116, 139, .35);
    border-radius: 8px;
    background: #f8fbff;
    color: var(--muted);
    text-align: center;
    font-weight: 850;
}

.note-client {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    margin: 0 0 9px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef7ff;
    color: #2563eb;
    font-size: 12px;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.workbench-grid,
.analytics-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.metric-danger {
    --card-accent: var(--danger);
    background: linear-gradient(180deg, #ffffff, #fff5f5);
}

.metric-warning {
    --card-accent: var(--warning);
    background: linear-gradient(180deg, #ffffff, #fff9e8);
}

.metric-secondary {
    --card-accent: var(--secondary);
    background: linear-gradient(180deg, #ffffff, #f2f7ff);
}

.metric-accent {
    --card-accent: var(--accent);
    background: linear-gradient(180deg, #ffffff, #fff7f0);
}

.metric-pink {
    --card-accent: var(--pink);
    background: linear-gradient(180deg, #ffffff, #fff4fa);
}

.work-item {
    display: grid;
    width: 100%;
    gap: 7px;
    margin-bottom: 10px;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.work-item:hover {
    border-color: rgba(15, 159, 138, .35);
    background: #f5fffb;
}

.work-item span {
    display: grid;
    gap: 3px;
}

.work-item b {
    font-weight: 950;
}

.work-item em,
.work-item small {
    color: var(--muted);
    font-style: normal;
    font-weight: 800;
}

.quick-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: -4px 0 18px;
}

.quick-filter {
    min-height: 36px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
    background: #fff;
    color: #41536a;
    cursor: pointer;
    font-size: 13px;
    font-weight: 900;
}

.quick-filter.active {
    border-color: rgba(15, 159, 138, .25);
    background: #e9fbf6;
    color: #0d7466;
}

.service-period,
.next-action {
    display: grid;
    gap: 3px;
    min-width: 150px;
}

.service-period b,
.next-action b {
    font-size: 13px;
    font-weight: 950;
}

.service-period small,
.next-action small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.next-action.late small {
    color: var(--danger);
}

.call-date {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef7f5;
    color: #0b766c;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.call-date.today {
    background: #dcfce7;
    color: #157f3b;
}

.payment-active,
.payment-invoiced {
    background: #eaf2ff;
    color: #2563eb;
}

.payment-wait {
    background: #fff3c7;
    color: #8a5d00;
}

.payment-overdue {
    background: #ffe4e1;
    color: #c2372b;
}

.payment-debt {
    background: #ffe4e1;
    color: #c2372b;
}

.payment-paid {
    background: #dcfce7;
    color: #157f3b;
}

.payment-refusal {
    background: #edf1f5;
    color: #5c6875;
}

.quality-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    min-height: 28px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 950;
}

.quality-badge.good {
    background: #dcfce7;
    color: #157f3b;
}

.quality-badge.mid {
    background: #fff3c7;
    color: #8a5d00;
}

.quality-badge.bad {
    background: #ffe4e1;
    color: #c2372b;
}

.funnel-row,
.aging-row,
.forecast-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 5px 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}

.funnel-row:last-child,
.aging-row:last-child,
.forecast-row:last-child {
    border-bottom: none;
}

.funnel-row strong,
.aging-row strong,
.forecast-row strong {
    font-weight: 950;
}

.funnel-row em,
.aging-row em,
.forecast-row em {
    grid-column: 1 / -1;
    color: var(--muted);
    font-style: normal;
    font-size: 13px;
    font-weight: 800;
}

.client-center {
    display: grid;
    grid-template-columns: minmax(260px, 340px) 1fr;
    gap: 18px;
    margin-top: 18px;
}

.quality-panel,
.history-panel {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fbff;
}

.quality-panel h3,
.history-panel h3 {
    margin-bottom: 6px;
}

.quality-meter {
    overflow: hidden;
    height: 12px;
    margin-top: 14px;
    border-radius: 999px;
    background: #dbe7f1;
}

.quality-meter span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--danger), var(--warning), var(--primary));
    transition: width .18s ease;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.touch-form {
    display: grid;
    grid-template-columns: 160px 170px 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.touch-history-list {
    display: grid;
    gap: 10px;
    max-height: 260px;
    overflow: auto;
}

.touch-item,
.history-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.touch-item span,
.history-line span {
    display: block;
    margin: 3px 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.touch-item p,
.history-line p {
    color: #384860;
    font-size: 14px;
}

.notes-empty.compact {
    min-height: 96px;
    padding: 16px;
}

.client-profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.section-block a {
    color: var(--secondary);
    font-weight: 900;
}

@media (max-width: 900px) {
    .topbar {
        align-items: stretch;
        padding: 14px;
    }

    .topbar,
    .dashboard-row,
    .notes-layout,
    .workbench-grid,
    .analytics-row,
    .profit-grid,
    .reports-grid,
    .client-center,
    .client-profile-grid {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .topbar-right {
        justify-content: flex-start;
    }

    .tabs {
        padding: 12px 14px;
    }

    .tab-btn {
        flex: 1 1 180px;
    }

    .content {
        padding: 16px 14px 32px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar input,
    .toolbar select,
    .toolbar button,
    .btn-primary,
    .btn-secondary,
    .btn-danger,
    .btn-note {
        width: 100%;
    }

    .modal {
        padding: 12px;
    }

    .modal-content {
        max-height: 94vh;
        padding: 18px;
    }

    .note-tools {
        grid-template-columns: 1fr;
    }

    .touch-form {
        grid-template-columns: 1fr;
    }

    .import-panel {
        grid-template-columns: 1fr;
    }

    .clients-drawer {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .auth-card {
        padding: 26px 20px;
    }

    .auth-card::before {
        margin: -26px -20px 24px;
    }

    .brand {
        align-items: flex-start;
    }

    .logo {
        font-size: 20px;
    }

    .dashboard-value {
        font-size: 26px;
    }

    th,
    td {
        padding: 12px;
    }
}

.danger-icon { background: #ffe7e5; color: #c2372b; }
.danger-icon:hover { background: #ffd4cf; }
