/* =========================================================
   1) VARIABLES
========================================================= */
:root {
    --brand-1: #3B82F6;
    --brand-2: #1D4ED8;
    --brand-3: #1E40AF;

    --brand-grad: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 52%, var(--brand-3) 100%);

    /* hover — чуть светлее и “сочнее”, но в той же гамме */
    --brand-grad-hover: linear-gradient(135deg, #4B8BFF 0%, #2458E6 52%, #243FBA 100%);

    /* active — чуть темнее, чтобы чувствовалось нажатие */
    --brand-grad-active: linear-gradient(135deg, #2F6FE0 0%, #173FBE 52%, #17379A 100%);
}


/* =========================================================
   2) RESET / BASE
========================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f9;
    color: #333;
}

/* NOTE: в исходнике было body.auth и .auth (разные контексты) — оставляем оба */
body.auth {
    background: var(--brand-grad);
    height: 100%;
}
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}
.form-grid-3 textarea{
    width: 100%;
    padding: 10px;
}
/* =========================================================
   3) LAYOUT
========================================================= */
.layout {
    display: flex;
    min-height: 100vh;
}

.content {
    flex: 1;
    padding: 40px;
    background: #f4f6f9;
    transition: 0.3s ease;
}


/* =========================================================
   4) SIDEBAR
========================================================= */
.sidebar {
    width: 240px;
    background: var(--brand-grad);
    color: white;
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    position: relative;
}

.sidebar.collapsed {
    width: 83px;
}

.sidebar h2 {
    font-size: 18px;
    margin-bottom: 30px;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed h2 {
    opacity: 0;
    pointer-events: none;
}

.sidebar a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.sidebar a:hover {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar a.active {
    background: rgba(255, 255, 255, 0.25);
}

.sidebar.collapsed a span {
    display: none;
}

/* Collapse button */
.sidebar-toggle {
    position: absolute;
    top: 20px;
    right: -15px;
    width: 30px;
    height: 30px;
    background: white;
    color: #01d49f;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    font-weight: bold;
    transition: 0.2s ease;
}
.sidebar-toggle:hover {
    transform: scale(1.1);
}
.sb-title{
    padding: 5px;
    margin-bottom: 5px;
    border-radius: 8px;
    font-size: 14px;
}

/* =========================================================
   5) CONTAINER / HEADER (legacy)
========================================================= */
.container {
    width: 1100px;
    margin: 40px auto;
}

.header {
    background: linear-gradient(320deg, #01d49f, #0962f3);
    color: white;
    padding: 20px 30px;
}

.header h1 {
    font-size: 20px;
    margin-bottom: 8px;
}

.nav a {
    color: #ecf0f1;
    text-decoration: none;
    margin-right: 20px;
    font-size: 14px;
}

.nav a:hover {
    text-decoration: underline;
}


/* =========================================================
   6) CARDS
========================================================= */
.card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
    transition: 0.2s ease;
}


/* =========================================================
   7) BUTTONS
========================================================= */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: var(--brand-grad);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    height: 38px;
    white-space: nowrap;
    text-align: center;
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    filter: brightness(1.02);
}

button.button-danger {
    background: #fc5031;
}

.button.button-small {
    font-size: 12px;
    padding: 5px 10px;
    height: auto;
}

/* Ripple элемент */
.button .hover-ripple {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle,
            rgba(255, 255, 255, 0.6) 0%,
            rgba(255, 255, 255, 0.4) 30%,
            rgba(255, 255, 255, 0.2) 50%,
            transparent 70%);
    opacity: 0.7;
    animation: rippleFade 0.6s ease-out forwards;
}

@keyframes rippleFade {
    0% {
        transform: scale(0.2);
        opacity: 0.7;
    }

    100% {
        transform: scale(3);
        opacity: 0;
    }
}


/* =========================================================
   8) FORMS (base)
========================================================= */
label {
    font-size: 14px;
    font-weight: bold;
}

input,
select {
    width: 100%;
    padding: 8px 10px;
    margin-top: 5px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* global tweak for form inputs */
form input {
    margin-top: 0;
    height: 38px;
}


/* =========================================================
   9) TABLES (base)
========================================================= */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

th {
    color: white;
    padding: 10px;
    font-size: 14px;
    text-align: left;
}

td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    font-size: 14px;
}

tr:hover {
    background: #f2f2f2;
}

/* THEAD gradient */
tr.thead,
thead > tr {
    background: var(--brand-grad);
}

thead > tr:hover {
    background: var(--brand-grad);
}

/* Sorting links */
.thead th a.sortable {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    cursor: pointer;
    transition: all .4s ease;
    border-bottom: 1px solid transparent;
}

.thead th a.sortable:hover {
    color: #fff;
    border-bottom: 1px solid #fff;
}

.thead th a.sorted {
    font-weight: 700;
    color: #fff;
}

.sort-arrow {
    font-size: 10px;
    line-height: 1;
}


/* =========================================================
   10) ALERTS
========================================================= */
.alert {
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.alert-error {
    background: #fdecea;
    color: #c0392b;
    padding: 10px;
    text-align: center;
    border-radius: 5px;
}

.alert-success {
    background: #eafaf1;
    color: #27ae60;
    padding: 10px;
    text-align: center;
    border-radius: 5px;
}


/* =========================================================
   11) DASHBOARD (cards/charts)
========================================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 25px;
    margin-top: 30px;
}

.dashboard-card {
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.dashboard-card h3 {
    font-size: 14px;
    color: #777;
    margin-bottom: 0px;
    text-transform: uppercase;
}

.dashboard-card .value {
    font-size: 24px;
    font-weight: bold;
}

.dashboard-card.blue {
    border-top: 4px solid #5a8c8c;
}

.dashboard-card.green {
    border-top: 4px solid #2ecc71;
}

.dashboard-card.orange {
    border-top: 4px solid #f39c12;
}

.dashboard-card.red {
    border-top: 4px solid #e74c3c;
}

.chart-container {
    margin-top: 40px;
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 40px;
}

.chart-card {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-top: 30px;
}

.chart-card canvas {
    max-height: 300px;
}

.year-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.year-filter select {
    padding: 6px 10px;
}

/* client analytics filter row (unified) */
.client-filter {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
    margin-bottom: 8px;
}

.client-filter #clientSearchInput {
    flex: 1 1 auto;
    min-width: 320px;
    height: 34px;
    padding: 6px 10px;
    box-sizing: border-box;
}

.client-filter input[type="date"] {
    flex: 0 0 160px;
    height: 34px;
    padding: 6px 10px;
    box-sizing: border-box;
}

@media (max-width: 900px) {
    .client-filter {
        flex-wrap: wrap;
    }

    .client-filter input[type="date"] {
        flex: 1 1 160px;
    }

    .client-filter #clientSearchInput {
        min-width: 100%;
    }
}


/* =========================================================
   12) MODAL
========================================================= */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 720px;
    max-width: 90%;
    position: relative;
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.25s ease;
}

.modal.show .modal-content {
    transform: scale(1);
    opacity: 1;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 15px;
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
    transition: 0.2s;
}

.modal-close:hover {
    color: #e74c3c;
    transform: scale(1.1);
}


/* =========================================================
   13) TOAST
========================================================= */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-150px);
    min-width: 300px;
    max-width: 500px;
    padding: 15px 25px;
    border-radius: 10px;
    color: white;
    font-weight: 500;
    font-size: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    opacity: 0;
    overflow: hidden;
    transition: opacity 0.4s ease;
    text-align: center;
}

.toast.show {
    animation: toastBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 1;
}

.toast.hide {
    animation: toastFadeOut 0.4s ease forwards;
}

@keyframes toastBounceIn {
    0% {
        transform: translateX(-50%) translateY(-150px);
        opacity: 0;
    }

    60% {
        transform: translateX(-50%) translateY(10px);
        opacity: 1;
    }

    80% {
        transform: translateX(-50%) translateY(-5px);
    }

    100% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes toastFadeOut {
    0% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateX(-50%) translateY(-50px);
        opacity: 0;
    }
}

.toast.success {
    background: linear-gradient(320deg, #2ecc71, #27ae60);
}

.toast.error {
    background: linear-gradient(320deg, #e74c3c, #c0392b);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    width: 100%;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 0 0 10px 10px;
    transform-origin: left;
    animation: toastProgress 3s linear forwards;
}

@keyframes toastProgress {
    0% {
        transform: scaleX(1);
    }

    100% {
        transform: scaleX(0);
    }
}


/* =========================================================
   14) CHECKBOX
========================================================= */
.checkbox-wrapper {
    position: relative;
    display: inline-block;
}

.checkbox-wrapper input[type="checkbox"] {
    appearance: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    margin: 0;
}

.checkbox-wrapper input[type="checkbox"]:hover {
    border-color: #01d49f;
}

.checkbox-wrapper input[type="checkbox"]:checked {
    background: linear-gradient(320deg, #01d49f, #0962f3);
    border-color: #01d49f;
}

.checkbox-wrapper input[type="checkbox"]:checked::after {
    content: "✓";
    position: absolute;
    left: 5px;
    top: 0px;
    color: #ffffff;
    font-size: 13px;
}


/* =========================================================
   15) STATUS BADGES (base)
========================================================= */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: white;
}

.status-draft {
    background: linear-gradient(320deg, #6c757d, #495057);
}

.status-sent {
    background: linear-gradient(320deg, #f39c12, #e67e22);
}

.status-paid {
    background: linear-gradient(320deg, #2ecc71, #27ae60);
}


/* =========================================================
   16) INVOICE CREATE/EDIT
========================================================= */
#draftIndicator {
    position: fixed;
    top: 0;
    right: 0;
    margin: 0 auto;
    background: #f4f6f9;
    width: 100%;
    text-align: center;
    padding: 10px 4px;
}

.invoice-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 20px;
}

.invoice-party {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.invoice-party h4 {
    margin-bottom: 10px;
    font-size: 14px;
    text-transform: uppercase;
    color: #666;
}

.invoice-meta {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    align-items: center;
}

.invoice-meta input,
.invoice-meta select {
    width: 160px;
}

#itemsTable input {
    margin-bottom: 0;
}

/* parties collapse */
.invoice-party-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.party-toggle-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.party-toggle-icon {
    transition: transform 0.2s ease;
}

.party-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.party-details.open {
    max-height: 670px;
    margin-top: 8px;
}

.party-toggle-btn.open .party-toggle-icon {
    transform: rotate(180deg);
}

/* counterparty combobox */
.counterparty-combobox {
    position: relative;
    margin-bottom: 8px;
}

#counterpartyInput {
    width: 100%;
    padding: 8px 10px;
    box-sizing: border-box;
}

.counterparty-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
}

.counterparty-item {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
}

.counterparty-item:hover {
    background: #f2f6ff;
}

/* invalid rows */
.row-warning td {
    background: #fff6f6;
}

.row-warning input {
    border-color: #f5b7b1;
}


/* =========================================================
   17) AUTOCOMPLETE (products)
========================================================= */
.autocomplete-dropdown {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 250px;
    overflow-y: auto;
    z-index: 9999;
}

.autocomplete-item {
    padding: 8px 10px;
    cursor: pointer;
    font-size: 14px;
}

.autocomplete-item:hover {
    background: #f2f6ff;
}


/* =========================================================
   18) INVOICES LIST (actions, details, status dropdown, toolbar)
========================================================= */
.actions-cell {
    position: relative;
}

a.invoice-number {
    font-weight: bold;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid;
}

/* row buttons */
.row-menu-toggle,
.row-expand-toggle {
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 5px;
    display: inline-block;
    background: none;
    border-radius: 8px;
    color: var(--text);
    text-align: center;
    height: auto;
    width: 30px;
    height: 30px;
}

/* actions menu */
.actions-menu {
    position: absolute;
    top: 60%;
    left: -57px;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 6px;
    display: none;
    z-index: 1000;
    min-width: 160px;
}

.actions-menu .button {
    display: block;
    width: 100%;
    margin-bottom: 4px;
    text-align: left;
    font-size: 12px;
    padding: 6px 10px;
}

.actions-menu .button:last-child {
    margin-bottom: 0;
}

/* details row preview */
.invoice-details-row td {
    background: #f8f9fa;
    padding: 0;
}

.invoice-details-wrapper {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.invoice-details-wrapper.open {
    max-height: 1000px;
    padding: 10px 8px;
}

.invoice-block table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.invoice-block table th,
.invoice-block table td {
    border: 1px solid #ddd;
    padding: 4px 6px;
}

.invoice-block.text-right {
    margin-top: 8px;
}

/* expand arrow */
.row-expand-toggle {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.row-expand-icon {
    transition: transform 0.2s ease;
}

.row-expand-toggle.open .row-expand-icon {
    transform: rotate(180deg);
}

/* status dropdown */
.status-cell {
    position: relative;
}

.status-dropdown {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.status-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px;
    display: none;
    z-index: 1000;
    min-width: 140px;
}

.status-option {
    padding: 3px 4px;
}

.status-option .status-badge {
    display: inline-block;
    width: 100%;
    text-align: left;
}

.status-option:hover {
    background: #f2f6ff;
}

/* toolbar */
.invoices-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
    flex-wrap: wrap;
    white-space: nowrap;
}

.invoices-limit-form {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #444;
}

.invoices-limit-form select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 13px;
}

.invoices-limit-form label {
    margin-bottom: 10px;
}

.invoices-summary {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 28px;
}

#deleteSelectedBtn {
    margin-bottom: 10px;
}

#filterBody {
    transition: 0.2s ease;
}


/* =========================================================
   19) LANDING / HERO
========================================================= */
.hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #3498db, #2ecc71);
    color: #fff;
    text-align: center;
    padding: 120px 20px;
}

.hero canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero p {
    margin-top: 20px;
    font-size: 18px;
}

.hero .button {
    background: #007fd2;
    color: #fff;
    text-transform: uppercase;
    font-size: 15px;
    padding: 20px;
}

.section {
    padding: 60px 20px;
    max-width: 1100px;
    margin: 0 auto;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.feature-card {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.footer {
    background: #222;
    color: #ccc;
    text-align: center;
    padding: 30px 20px;
    font-size: 14px;
}

.footer a {
    color: #ccc;
    text-decoration: none;
}

.hero-button {
    margin-top: 25px;
    padding: 12px 28px;
    font-size: 16px;
    background: #ffffff;
    color: #3498db;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.25s ease;
}

.hero-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.hero-button:active {
    transform: translateY(0);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.15);
    background: var(--brand-grad-active);
    transform: translateY(1px);
}


/* =========================================================
   20) LOGIN PAGE
========================================================= */
.auth {
    background: linear-gradient(135deg, #3498db, #2ecc71);
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#loginParticles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.login-logo {
    position: absolute;
    top: 20px;
    left: 30px;
    z-index: 2;
}

.login-logo img {
    width: 180px;
}

.login-card {
    width: 400px;
    margin: 15vh auto;
    position: relative;
    z-index: 2;
    padding: 40px 30px;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.login-button {
    width: 100%;
    margin-top: 10px;
}


/* =========================================================
   21) HELPERS
========================================================= */
.muted {
    color: #7f8c8d;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
}

/* placeholder selector from original */
a.logo {}

.purchase-flag {
    margin-left: 6px;
    font-weight: 700;
    font-size: 16px;
    position: relative;
    top: -3px;
    cursor: pointer;
}

.purchase-flag.ok {
    color: #27ae60;
}

.purchase-flag.bad {
    color: #f39c12;
}
.collapsible-content{
    display: none;
}
.collapsible-content.collapsed{
    display: block;
}