:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #eef3f8;
    --line: #d9e3ef;
    --text: #172033;
    --muted: #5d6b82;
    --primary: #0f5bd8;
    --primary-strong: #0b3f97;
    --success: #198754;
    --warning: #c78600;
    --danger: #c64747;
    --radius: 18px;
    --shadow: 0 20px 50px rgba(23, 32, 51, 0.08);
    --sidebar-width: 280px;
    --content-width: 1480px;
    --font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: linear-gradient(180deg, #f8fbff 0%, #f1f5fb 100%);
    color: var(--text);
    font-family: var(--font);
}

body {
    line-height: 1.55;
}

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

a:hover {
    text-decoration: underline;
}

breadcrumbs {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--muted);
    font-size: 0.92rem;
}

h1 {
    margin: 0 0 0.65rem;
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    line-height: 1.15;
}

hr {
    border: 0;
    height: 1px;
    background: var(--line);
    margin: 0 0 1.5rem;
}

p {
    margin: 0 0 1rem;
}

.eyebrow {
    margin: 0 0 0.2rem;
    color: var(--muted);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 42px;
    padding: 0.7rem 1rem;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 600;
    text-decoration: none;
}

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

.btn-primary {
    background: var(--primary);
    color: #fff;
}

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

.btn-ghost {
    background: #fff;
    border-color: var(--line);
    color: var(--text);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-soft {
    background: #e8f0ff;
    color: var(--primary-strong);
}

.badge-success {
    background: #e5f6ee;
    color: #0c6a3a;
}

.badge-warning {
    background: #fff4dc;
    color: #9a6300;
}

.badge-danger {
    background: #fde8e8;
    color: #a63434;
}

.flash-stack {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.flash {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
}

.flash-warning {
    background: #fff8e8;
    border-color: #f0d48b;
}

.flash-danger {
    background: #fce9e9;
    border-color: #e6afaf;
}

.flash-success {
    background: #eaf7ef;
    border-color: #9ed1b2;
}

.public-frame,
.panel-frame {
    min-height: 100vh;
}

.public-frame {
    max-width: 1320px;
    margin: 0 auto;
    padding: 1.25rem;
}

.public-header,
.public-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(217, 227, 239, 0.8);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.public-header {
    margin-bottom: 1.25rem;
}

.public-main {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.public-nav,
.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.brand {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
}

.brand-subtitle,
.sidebar-note {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.public-hero,
.content-card,
.panel-block,
.metric-card,
.table-card,
.chart-card,
.placeholder-card,
.form-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(217, 227, 239, 0.95);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.public-hero,
.content-card,
.panel-block,
.table-card,
.chart-card,
.placeholder-card,
.form-card {
    padding: 1.35rem;
}

.hero-grid,
.cards-grid,
.placeholder-grid,
.two-column,
.dashboard-grid,
.metrics-grid,
.limit-grid,
.tables-grid {
    display: grid;
    gap: 1rem;
}

.hero-grid,
.two-column,
.dashboard-grid,
.tables-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.limit-grid,
.cards-grid,
.placeholder-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
    padding: 1rem;
}

.metric-card strong {
    display: block;
    font-size: 2rem;
    line-height: 1.1;
    margin-bottom: 0.25rem;
}

.metric-card small,
.card-caption,
.muted {
    color: var(--muted);
}

.progress {
    width: 100%;
    height: 10px;
    background: #edf1f7;
    border-radius: 999px;
    overflow: hidden;
    margin: 0.75rem 0;
}

.progress-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary) 0%, #4a8fff 100%);
}

.progress-bar.warning {
    background: linear-gradient(90deg, #f3c14c 0%, #dc9200 100%);
}

.progress-bar.danger {
    background: linear-gradient(90deg, #ec7a7a 0%, #c64747 100%);
}

.panel-frame {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.panel-sidebar {
    position: sticky;
    top: 0;
    min-height: 100vh;
    padding: 1.5rem 1.2rem;
    background: #11203a;
    color: #e6eefb;
}

.sidebar-brand {
    color: #fff;
    font-weight: 800;
    font-size: 1.35rem;
}

.sidebar-nav {
    display: grid;
    gap: 0.35rem;
    margin-top: 1.5rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0.7rem 0.85rem;
    border-radius: 12px;
    color: #dce7fb;
}

.sidebar-nav a:hover,
.sidebar-nav a.is-active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-decoration: none;
}

.panel-content {
    min-width: 0;
}

.panel-topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 1.2rem 1.5rem;
    background: rgba(255, 255, 255, 0.75);
    border-bottom: 1px solid rgba(217, 227, 239, 0.8);
    backdrop-filter: blur(18px);
}

.topbar-actions,
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-user-name {
    font-weight: 700;
}

.panel-main {
    max-width: var(--content-width);
    padding: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.table-wrap {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.table th {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.check-list {
    display: grid;
    gap: 0.6rem;
    margin: 0;
    padding-left: 1.2rem;
}

.kpi-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
    color: var(--muted);
    font-size: 0.9rem;
}

.chart-placeholder {
    min-height: 220px;
    border: 1px dashed #aac2ea;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(15, 91, 216, 0.06) 0%, rgba(15, 91, 216, 0.01) 100%);
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 600;
}

.list-meta {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

@media (max-width: 1200px) {
    .hero-grid,
    .two-column,
    .dashboard-grid,
    .tables-grid,
    .metrics-grid,
    .limit-grid,
    .cards-grid,
    .placeholder-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .panel-sidebar {
        position: static;
        min-height: auto;
    }

    .public-header,
    .public-footer,
    .panel-topbar,
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 680px) {
    .hero-grid,
    .two-column,
    .dashboard-grid,
    .tables-grid,
    .metrics-grid,
    .limit-grid,
    .cards-grid,
    .placeholder-grid {
        grid-template-columns: 1fr;
    }

    .public-frame,
    .panel-main,
    .panel-topbar {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

.form-field {
    display: grid;
    gap: 0.45rem;
    margin-bottom: 1rem;
}

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

.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
    min-height: 46px;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: 0;
    border-color: #8cb0ef;
    box-shadow: 0 0 0 4px rgba(15, 91, 216, 0.08);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 1.1rem;
}

.form-check {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.form-check input {
    margin-right: 0.55rem;
}

.field-error {
    margin: 0;
    color: var(--danger);
    font-size: 0.88rem;
    font-weight: 600;
}

.form-alert {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid transparent;
}

.form-alert-success {
    background: #eaf7ef;
    border-color: #9ed1b2;
    color: #0c6a3a;
}

.form-alert-danger {
    background: #fce9e9;
    border-color: #e6afaf;
    color: #a63434;
}

.form-alert-warning {
    background: #fff8e8;
    border-color: #f0d48b;
    color: #9a6300;
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #a63434;
}

.btn-sm {
    min-height: 36px;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    font-size: 0.9rem;
}

.section-header-page {
    margin-bottom: 1.25rem;
}

.page-actions,
.inline-actions,
.entity-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.summary-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 1.25rem;
}

.summary-card strong,
.entity-title {
    display: block;
    font-size: 1.8rem;
    line-height: 1.12;
    margin-bottom: 0.25rem;
}

.empty-state {
    display: grid;
    gap: 0.85rem;
}

.data-table-shell {
    padding-top: 0.25rem;
}

.crm-table tfoot input,
.crm-table tfoot select {
    width: 100%;
    min-height: 38px;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.crm-table tfoot input:focus,
.crm-table tfoot select:focus {
    outline: 0;
    border-color: #8cb0ef;
    box-shadow: 0 0 0 4px rgba(15, 91, 216, 0.08);
}

.table-title {
    font-weight: 700;
}

.table-subtitle {
    color: var(--muted);
    font-size: 0.9rem;
}

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

.form-layout-grid {
    align-items: start;
}

.form-grid {
    display: grid;
    gap: 1rem;
}

.two-col-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-col-form {
    grid-template-columns: 1fr 1.4fr 120px;
}

.detail-grid {
    margin-bottom: 1.25rem;
}

.key-value-list {
    display: grid;
    gap: 0.9rem;
}

.key-value-list div {
    display: grid;
    gap: 0.2rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--line);
}

.key-value-list div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.key-value-list strong {
    font-size: 0.9rem;
}

.is-hidden {
    display: none !important;
}

.auth-section {
    max-width: 640px;
    margin-inline: auto;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1040;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.modal[data-account-modal] {
    display: none;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 1055;
}

.modal[data-account-modal].show {
    display: block;
}

.modal[data-account-modal] .modal-dialog {
    margin: 0.5rem auto;
    min-height: calc(100% - 1rem);
}

.modal-backdrop.fade {
    position: fixed;
}

.modal.is-hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 32, 58, 0.58);
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: min(560px, 100%);
}

.modal-content {
    background: #fff;
    border: 1px solid rgba(217, 227, 239, 0.95);
    border-radius: 18px;
    box-shadow: 0 30px 70px rgba(23, 32, 51, 0.25);
    overflow: hidden;
}

.modal-header,
.modal-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.2rem;
}

.modal-header {
    border-bottom: 1px solid var(--line);
}

.modal-body {
    padding: 1.1rem 1.2rem;
}

.modal-footer {
    border-top: 1px solid var(--line);
    justify-content: flex-end;
    flex-wrap: wrap;
}

.modal-close {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

body.body-modal-open {
    overflow: hidden;
}

@media (max-width: 1200px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .text-end {
        text-align: left;
    }
}

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

    .modal-header,
    .modal-footer,
    .page-actions,
    .inline-actions,
    .entity-meta {
        align-items: flex-start;
    }
}
.filter-pills,
.flag-list,
.checkbox-grid {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-pills {
    margin-bottom: 1.25rem;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    font-weight: 600;
}

.filter-pill.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.filter-pill:hover {
    text-decoration: none;
}

.checkbox-grid {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.card-check {
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
}
.attachment-list {
    display: grid;
    gap: 0.9rem;
    margin-top: 1rem;
}

.attachment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.95rem 1rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
}

.attachment-name {
    display: block;
    color: var(--text);
}

.attachment-meta,
.inline-note {
    margin-top: 0.3rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.attachment-actions {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    align-items: center;
}

@media (max-width: 900px) {
    .attachment-item {
        flex-direction: column;
        align-items: flex-start;
    }
}
.document-builder-grid {
    align-items: start;
}

.document-inline-card {
    margin-top: 1rem;
}

.document-summary-stack {
    display: grid;
    gap: 1rem;
}

.document-summary-card {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
}

.document-items-card .table-wrap {
    margin-top: 1rem;
}

.document-items-table {
    min-width: 980px;
}

.document-items-table textarea {
    min-height: 72px;
    resize: vertical;
}

.document-items-table input,
.document-items-table select,
.document-items-table textarea {
    min-width: 110px;
}

.document-item-remove {
    white-space: nowrap;
}

.document-total-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--line);
}

.document-total-row:last-child {
    border-bottom: 0;
}

.document-html-preview {
    overflow: hidden;
}

.document-preview-sheet {
    display: grid;
    gap: 1rem;
    padding: 1.35rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.document-preview-header,
.document-preview-meta,
.document-preview-parties,
.document-preview-totals {
    display: grid;
    gap: 1rem;
}

.document-preview-header,
.document-preview-totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}

.document-preview-header span,
.document-preview-meta span,
.document-preview-party span,
.document-preview-note span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    margin-bottom: 0.25rem;
}

.document-preview-header strong,
.document-preview-meta strong,
.document-preview-totals strong {
    display: block;
}

.document-preview-header small,
.document-preview-party small {
    display: block;
    color: var(--muted);
    margin-top: 0.2rem;
}

.document-preview-meta {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(246, 248, 252, 0.92);
}

.document-preview-parties {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.document-preview-party {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.94);
}

.document-preview-party strong {
    display: block;
    margin-bottom: 0.35rem;
}

.document-preview-table-wrap {
    overflow-x: auto;
}

.document-preview-table {
    margin-bottom: 0;
}

.document-preview-note,
.document-preview-footer {
    padding-top: 0.5rem;
    border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
    .document-preview-header,
    .document-preview-meta,
    .document-preview-parties,
    .document-preview-totals {
        grid-template-columns: 1fr;
    }
}
.legal-document-card {
    padding: 1.5rem;
}

.legal-document-content {
    display: grid;
    gap: 1rem;
    line-height: 1.7;
}

.legal-document-content h2,
.legal-document-content h3 {
    margin: 0;
}

.legal-document-content p,
.legal-document-content ul,
.legal-document-content ol {
    margin: 0;
}

.legal-document-content ul,
.legal-document-content ol {
    padding-left: 1.4rem;
}

.legal-admin-focus .form-card,
.legal-admin-focus .table-card {
    border-color: rgba(15, 91, 216, 0.32);
}
