:root {
    --bg: #f5f6f8;
    --card-bg: #ffffff;
    --text: #222222;
    --muted: #6b7280;
    --primary: #1f6feb;
    --primary-hover: #1859c9;
    --secondary: #4b5563;
    --secondary-hover: #374151;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --border: #e5e7eb;
    --table-head: #f9fafb;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.brand:hover {
    text-decoration: none;
}

.top-nav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.top-nav a {
    color: var(--muted);
    font-weight: 700;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none;
}

.top-nav a:hover {
    background: #f3f4f6;
    color: var(--text);
    text-decoration: none;
}

.top-nav a.active {
    background: #e8f0fe;
    color: var(--primary);
}

.app-main {
    flex: 1;
    padding: 24px;
}

.page {
    max-width: 1280px;
    margin: 0 auto;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.page-title {
    margin: 0 0 8px 0;
    font-size: 32px;
    font-weight: 700;
}

.muted {
    color: var(--muted);
}

.breadcrumb {
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 14px;
}

.breadcrumb a {
    color: var(--muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

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

.page-header-left {
    min-width: 0;
}

.page-header-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.actions {
    margin-bottom: 20px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.actions form {
    display: inline-block;
    margin: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    border: none;
    cursor: pointer;
    font-family: Arial, sans-serif;
    font-size: 16px;
    line-height: 1;
}

.btn:hover {
    background: var(--primary-hover);
    text-decoration: none;
}

.btn-secondary {
    background: var(--secondary);
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filters input,
.filters select {
    padding: 10px 12px;
    border: 1px solid #cfcfcf;
    border-radius: 8px;
    min-width: 180px;
    background: #ffffff;
    font-size: 15px;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.table th {
    background: var(--table-head);
}

.table td a {
    font-weight: 600;
}

.text-right {
    text-align: right;
}

.pagination {
    margin-top: 20px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.pagination a {
    padding: 8px 12px;
    border-radius: 8px;
    background: #e5e7eb;
    color: #111827;
    text-decoration: none;
}

.pagination a:hover {
    background: #d1d5db;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin: 24px 0;
}

.info-grid.three-cols {
    grid-template-columns: repeat(3, 1fr);
}

.info-box {
    background: #f9fafb;
    border-radius: 10px;
    padding: 14px;
}

.label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.value {
    font-size: 18px;
    font-weight: 700;
    word-break: break-word;
}

.totals {
    width: 360px;
    margin-left: auto;
    margin-top: 20px;
}

.totals td {
    border: none;
    padding: 6px 0;
}

.grand-total {
    font-weight: 700;
    font-size: 18px;
}

.alert {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 700;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
}

.notes {
    margin-top: 24px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 10px;
}

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

.link-actions a {
    font-weight: 700;
}

.badge {
    display: inline-block !important;
    padding: 6px 10px !important;
    border-radius: 999px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
}

.badge-draft {
    background: #e5e7eb !important;
    color: #374151 !important;
}

.badge-sent,
.badge-confirmed {
    background: #dbeafe !important;
    color: #1d4ed8 !important;
}
.badge-accepted,
.badge-active,
.badge-paid,
.badge-fulfilled {
    background: #dcfce7 !important;
    color: #166534 !important;
}

.badge-cancelled,
.badge-rejected,
.badge-overdue {
    background: #fee2e2 !important;
    color: #991b1b !important;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.kpi-label {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.1;
}

.kpi-subtext {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
}

.dashboard-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.section-title {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 700;
}

.panel {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 20px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.form-field label {
    font-weight: 700;
}

.form-field input,
.form-field select,
.form-field textarea {
    padding: 10px 12px;
    border: 1px solid #cfcfcf;
    border-radius: 8px;
    background: #ffffff;
    font-size: 15px;
    font-family: Arial, sans-serif;
}

.field-error {
    color: #991b1b;
    font-size: 13px;
    font-weight: 700;
}

.app-footer {
    border-top: 1px solid var(--border);
    background: #ffffff;
    padding: 16px 24px;
    margin-top: 24px;
}

.app-footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 14px;
}

@media (max-width: 1100px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .info-grid,
    .info-grid.three-cols {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .app-main {
        padding: 16px;
    }

    .card {
        padding: 16px;
    }

    .info-grid,
    .info-grid.three-cols,
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .totals {
        width: 100%;
    }

    .page-title {
        font-size: 28px;
    }

    .page-header {
        flex-direction: column;
    }

    .app-header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-icon {
        font-size: 14px;
        line-height: 1;
    }

    .top-nav a {
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .top-nav a.active {
        background: #e8f0fe;
        color: var(--primary);
    }

    .btn .btn-icon,
    .btn-icon {
        font-size: 14px;
        line-height: 1;
    }

    .page-header-right form {
        display: inline-block;
        margin: 0;
    }

    .page-header-right form .btn {
        height: 100%;
    }

    .badge-wrap {
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .top-nav a i {
        font-size: 15px;
        line-height: 1;
    }

    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .btn i {
        font-size: 14px;
        line-height: 1;
    }

    .link-actions a {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }
}

    @media (max-width: 1100px) {
        .app-header-inner {
            grid-template-columns: 1fr;
            justify-items: start;
        }

        .top-nav {
            justify-content: flex-start;
        }

        .header-user-area {
            justify-self: start;
        }
    }
:root {
    --header-bg: #111827;
    --header-text: #f9fafb;
    --header-muted: #cbd5e1;
    --header-active-bg: #1f3b63;
    --header-active-text: #93c5fd;

    --footer-bg: #111827;
    --footer-text: #cbd5e1;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--header-text);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(37, 99, 235, 0.18);
    color: #93c5fd;
    font-size: 18px;
    font-weight: 700;
}

.brand-text {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.app-header {
    background: var(--header-bg) !important;
    color: var(--header-text) !important;
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
}

.app-header .navbar-brand,
.app-header .navbar-brand span,
.app-header .navbar-nav > .nav-item > .nav-link,
.app-header .tenant-chip,
.app-header .btn-outline-light,
.app-header .btn-outline-light i,
.app-header .text-white,
.app-header .text-white span,
.app-header .text-white i {
    color: #f9fafb !important;
}
.btn-logout{
    color: #f9fafb !important;
}

.app-header .top-nav a {
    background: transparent !important;
}

.app-header .top-nav a:hover {
    background: rgba(255,255,255,0.08) !important;
    color: #ffffff !important;
    text-decoration: none;
}

.app-header .top-nav a.active {
    background: var(--header-active-bg) !important;
    color: var(--header-active-text) !important;
}

.app-header .tenant-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 999px;
    background: rgba(255,255,255,0.04);
    font-size: 14px;
    font-weight: 700;
    color: var(--header-text);
    white-space: nowrap;
}

.app-header .btn.btn-secondary {
    background: #374151;
    color: #f9fafb;
    border: 1px solid rgba(255,255,255,0.08);
}

.app-header .btn.btn-secondary:hover {
    background: #4b5563;
}

.app-footer {
    background: var(--footer-bg) !important;
    color: var(--footer-text) !important;
    border-top: 1px solid rgba(255,255,255,0.08) !important;
}

.app-footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    color: var(--footer-text) !important;
    font-size: 14px;
}

.app-footer a,
.app-footer span,
.app-footer div,
.app-footer p {
    color: var(--footer-text) !important;
}

.checkbox-field {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--muted);
}

@media (max-width: 1100px) {
    .app-header-inner {
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .top-nav {
        justify-content: flex-start;
    }

    .header-user-area {
        justify-self: right;
    }

    .app-header .navbar-brand,
    .app-header .navbar-brand span,
    .app-header .navbar-nav > .nav-item > .nav-link,
    .app-header .tenant-chip,
    .app-header .btn-outline-light,
    .app-header .btn-outline-light i,
    .app-header .text-white,
    .app-header .text-white span,
    .app-header .text-white i {
        color: #f9fafb !important;
    }

}
.lines-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.line-grid-header,
.line-grid-row {
    display: grid;
    grid-template-columns: 44px minmax(280px, 1.8fr) 90px 90px 90px 180px 90px 52px;
    gap: 12px;
    align-items: center;
}

.line-grid-header {
    font-weight: 700;
    padding: 0 0 10px 0;
    border-bottom: 1px solid var(--border);
}

.line-grid-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.line-grid-row input,
.line-grid-row select,
.line-grid-row textarea {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.line-grid-row input[type="number"] {
    text-align: right;
}

.line-col-num {
    text-align: center;
    font-weight: 700;
}

.line-col-actions {
    display: flex;
    justify-content: center;
}

.btn-icon-only {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.field-error-inline {
    margin-top: 6px;
    color: #991b1b;
    font-size: 12px;
    font-weight: 700;
}

@media (max-width: 1200px) {
    .line-grid-header,
    .line-grid-row {
        grid-template-columns: 44px minmax(220px, 1.6fr) 80px 80px 80px 150px 80px 52px;
        gap: 10px;
    }
}

@media (max-width: 900px) {
    .line-grid-header {
        display: none;
    }

    .line-grid-row {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: #fff;
    }

    .line-grid-row > div {
        min-width: 0;
    }

    .line-col-num,
    .line-col-description,
    .line-col-actions {
        grid-column: span 2;
    }
}
.lines-grid input[type="number"] {
    text-align: left !important;
}
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    margin-bottom: 20px;
}

.list-toolbar .toolbar-field {
    min-width: 120px;
}

.list-toolbar .toolbar-field.search-field {
    min-width: 180px;
    flex: 1 1 280px;
}

.list-summary {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-wrap .table {
    min-width: 900px;
}

.pagination-wrap {
    margin-top: 8px;
}

@media (max-width: 700px) {
    .list-toolbar .toolbar-field,
    .list-toolbar .toolbar-field.search-field {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .list-summary {
        align-items: stretch;
    }
}
.table .col-actions,
.table td.col-actions {
    white-space: nowrap;
    width: 1%;
}

.link-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    white-space: nowrap;
}
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    justify-content: flex-start;
}

.list-toolbar .toolbar-field {
    min-width: 180px;
    flex: 0 0 auto;
}

.list-toolbar .toolbar-field.search-field {
    min-width: 280px;
    flex: 0 0 280px;
}

.list-toolbar .toolbar-actions {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    justify-content: flex-start;
}
.list-toolbar > * {
    margin-left: 0 !important;
}
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    justify-content: flex-start;
    margin-bottom: 20px;
}

.list-toolbar > * {
    margin-left: 0 !important;
}

.list-toolbar .toolbar-field {
    min-width: 180px;
    flex: 0 0 auto;
}

.list-toolbar .toolbar-field.search-field {
    min-width: 280px;
    flex: 0 0 280px;
}

.list-toolbar .toolbar-actions {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    justify-content: flex-start;
}

.list-toolbar label,
.list-toolbar .form-label {
    display: block;
    text-align: left;
    margin-bottom: 6px;
}

.list-toolbar input,
.list-toolbar select {
    text-align: left;
}

.table th,
.table td {
    text-align: left;
}

@media (max-width: 900px) {
    .list-toolbar {
        gap: 10px;
    }

    .list-toolbar .toolbar-field,
    .list-toolbar .toolbar-field.search-field {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .list-toolbar .toolbar-actions {
        width: 100%;
    }
}
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    justify-content: flex-start;
    margin-bottom: 20px;
}

.list-toolbar .toolbar-field {
    min-width: 180px;
    flex: 0 0 auto;
}

.list-toolbar .toolbar-field.search-field {
    min-width: 280px;
    flex: 0 0 280px;
}

.list-toolbar .toolbar-actions {
    min-width: auto;
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    align-items: center;
    align-self: flex-end;
    margin-top: 0;
}

.list-toolbar .toolbar-actions .btn {
    white-space: nowrap;
}
.js-item-select + .ts-wrapper,
.ts-wrapper.single,
.ts-wrapper.form-select {
    width: 100% !important;
    font-family: Arial, sans-serif !important;
}

.ts-wrapper.single .ts-control,
.ts-wrapper.form-select .ts-control {
    min-height: 42px !important;
    padding: 10px 12px !important;
    border: 1px solid #cfcfcf !important;
    border-radius: 8px !important;
    background: #ffffff !important;
    color: #212529 !important;
    box-shadow: none !important;
    background-image: none !important;
}

.ts-wrapper.single .ts-control input {
    color: #212529 !important;
}

.ts-wrapper.single .ts-control .item {
    color: #212529 !important;
    background: transparent !important;
}

.ts-wrapper.focus .ts-control {
    border-color: #86b7fe !important;
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,.25) !important;
}

.ts-dropdown,
.ts-wrapper .ts-dropdown {
    background: #ffffff !important;
    color: #212529 !important;
    border: 1px solid #d1d5db !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,.12) !important;
    z-index: 3000 !important;
}

.ts-dropdown .option,
.ts-dropdown .active,
.ts-dropdown .selected,
.ts-dropdown [data-selectable] {
    color: #212529 !important;
    background: #ffffff !important;
}

.ts-dropdown .option:hover,
.ts-dropdown [data-selectable].active {
    background: #e8f0fe !important;
    color: #1f6feb !important;
}

.ts-dropdown .create {
    color: #212529 !important;
    background: #ffffff !important;
}
.select.js-item-select.tomselected.ts-hidden-accessible {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    pointer-events: none !important;
    left: -9999px !important;
    width: 0 !important;
    height: 0 !important;
}

.ts-wrapper {
    display: block !important;
    width: 100% !important;
}