/* LegalNet customer theme. Tokens and .ln-* components.
   Do not import docs/design-reference/rabit-reference.css. */

:root {
    --ln-green: #014F2D;
    --ln-green-dark: #073D2C;
    --ln-green-soft: #EAF4EF;
    --ln-orange: #EF4B24;
    --ln-orange-soft: #FFF1EC;
    --ln-text: #24282B;
    --ln-muted: #66716B;
    --ln-background: #F6F8F7;
    --ln-surface: #FFFFFF;
    --ln-border: #E2E8E4;
    --ln-radius-sm: 12px;
    --ln-radius-md: 18px;
    --ln-radius-lg: 24px;
    --ln-shadow-sm: 0 4px 14px rgba(36, 40, 43, 0.05);
    --ln-shadow-md: 0 10px 28px rgba(7, 61, 44, 0.08);
    --ln-shadow: var(--ln-shadow-sm);
    --ln-touch: 44px;
    --ln-control: 48px;
    --ln-content: 1240px;
    --ln-content-narrow: 440px;
    --ln-ease: 180ms ease;
}

html,
body {
    background: var(--ln-background);
    color: var(--ln-text);
}

body {
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

body.ln-public .app-header,
body.ln-portal .app-header,
body.ln-admin .app-header {
    background: var(--ln-surface);
    border-bottom: 1px solid var(--ln-border);
}

body.ln-public .site-footer,
body.ln-portal .site-footer,
body.ln-admin .site-footer {
    background: var(--ln-surface);
    color: var(--ln-muted);
    border-top: 1px solid var(--ln-border);
}

body.ln-public .site-footer a,
body.ln-portal .site-footer a,
body.ln-admin .site-footer a {
    color: var(--ln-green);
}

/* Customer portal keeps light tokens even if legacy aliases are remapped. */
body.ln-portal {
    --accent: var(--ln-orange);
    --bg-dark: var(--ln-background);
    --card-bg: var(--ln-surface);
    --text-light: var(--ln-text);
    --border: var(--ln-border);
    background: var(--ln-background);
    color: var(--ln-text);
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

body.ln-portal .app-header {
    background: var(--ln-surface);
    border-bottom: 1px solid var(--ln-border);
}

body.ln-portal .menu-btn,
body.ln-portal .close-btn,
body.ln-portal .nav-item.active {
    color: var(--ln-green);
}

body.ln-portal .nav-item {
    color: var(--ln-text);
    min-height: var(--ln-touch);
}

body.ln-portal .side-menu form {
    margin: 0;
}

body.ln-portal .nav-item--action {
    background: none;
    border: none;
    padding: 0;
    width: 100%;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

body.ln-portal .nav-item:hover,
body.ln-portal .drop-item:hover {
    color: var(--ln-green);
}

body.ln-portal .site-footer {
    background: var(--ln-surface);
    color: var(--ln-muted);
    border-top: 1px solid var(--ln-border);
}

body.ln-portal .site-footer a {
    color: var(--ln-green);
}

body.ln-portal .dropdown-box {
    background: var(--ln-surface);
    border: 1px solid var(--ln-border);
    box-shadow: var(--ln-shadow);
}

body.ln-portal .drop-item {
    color: var(--ln-text);
    min-height: var(--ln-touch);
}

.header-side {
    width: 38px;
    height: 38px;
    display: block;
}

.ln-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 88px 1rem 2rem;
}

body.ln-portal .ln-page {
    max-width: 1120px;
    margin: 0;
    padding: 5.5rem 1rem 2rem;
}

body.ln-portal .ln-page--dashboard {
    max-width: 1120px;
}

body.ln-portal .ln-page--bills {
    max-width: 1240px;
}

body.ln-portal .ln-page--profile {
    max-width: 1080px;
}

body.ln-portal .ln-page--reports {
    max-width: 1140px;
}

body.ln-portal .ln-page--details {
    max-width: 1180px;
}

.ln-back {
    display: inline-flex;
    align-items: center;
    min-height: var(--ln-touch);
    margin: 0 0 0.75rem;
    color: var(--ln-green);
    font-weight: 600;
    text-decoration: none;
}

.ln-back:hover {
    text-decoration: underline;
}

.ln-page-header {
    margin: 0 0 1.25rem;
}

.ln-page-header h1,
.ln-page-header h2 {
    margin: 0 0 0.35rem;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--ln-green);
}

.ln-page-header p {
    margin: 0;
    color: var(--ln-muted);
    font-size: 0.95rem;
}

.ln-card {
    background: var(--ln-surface);
    border: 1px solid var(--ln-border);
    border-radius: var(--ln-radius-md);
    box-shadow: var(--ln-shadow);
    padding: 1.15rem 1.2rem;
    margin: 0 0 1rem;
}

.ln-card h3 {
    margin: 0 0 0.85rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ln-muted);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.ln-metrics {
    display: grid;
    gap: 1rem;
}

.ln-metric .label {
    display: block;
    font-size: 0.82rem;
    color: var(--ln-muted);
    margin-bottom: 0.2rem;
}

.ln-metric .value {
    display: block;
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--ln-text);
    line-height: 1.2;
}

.ln-metric .currency {
    font-size: 0.75rem;
    color: var(--ln-muted);
}

.ln-metric.ln-metric--total .value {
    color: var(--ln-green);
    font-size: 1.9rem;
}

.ln-actions--row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.ln-actions--row .ln-button {
    width: auto;
    min-width: 9.5rem;
}

.ln-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.6rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--ln-green-soft);
    color: var(--ln-green);
    font-size: 0.75rem;
    font-weight: 600;
}

.ln-badge--tv {
    background: var(--ln-orange-soft);
    color: #9B2C0F;
}

.ln-badge--public {
    background: var(--ln-green-soft);
    color: var(--ln-green);
}

.ln-badge--hidden {
    background: #EEF1F0;
    color: var(--ln-muted);
}

.ln-next-due {
    display: block;
    margin-top: 0.9rem;
    font-size: 0.95rem;
    color: var(--ln-text);
}

.ln-package-line {
    margin: 0.2rem 0;
    font-size: 1.05rem;
    color: var(--ln-text);
}

.ln-actions {
    display: grid;
    gap: 0.75rem;
    margin: 0.25rem 0 0;
}

.ln-button,
a.ln-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--ln-touch);
    padding: 0.7rem 1rem;
    border-radius: var(--ln-radius-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.ln-button--primary,
a.ln-button--primary {
    background: var(--ln-orange);
    color: #fff;
}

.ln-button--secondary,
a.ln-button--secondary {
    background: var(--ln-surface);
    color: var(--ln-green);
    border-color: var(--ln-green);
}

.ln-button--quiet,
a.ln-button--quiet {
    background: transparent;
    color: var(--ln-green);
    border-color: transparent;
    min-height: var(--ln-touch);
}

.ln-button--danger,
a.ln-button--danger,
button.ln-button--danger {
    background: var(--ln-surface);
    color: #9B1C1C;
    border-color: #9B1C1C;
}

.ln-button[disabled],
.ln-button.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.ln-button--block,
button.ln-button--block {
    width: 100%;
}

.ln-actions form {
    margin: 0;
}

.ln-empty-state {
    margin: 0;
    padding: 0.35rem 0;
    color: var(--ln-muted);
    font-size: 0.98rem;
}

.ln-status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0.15rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.ln-status--paid {
    background: #E7F3EC;
    color: var(--ln-green);
}

.ln-status--unpaid {
    background: #FFF1EC;
    color: var(--ln-orange);
}

.ln-status--overdue {
    background: #FDECEC;
    color: #9B1C1C;
}

.ln-status--active,
.ln-status--new {
    background: #E7F3EC;
    color: var(--ln-green);
}

.ln-status--resolved {
    background: #E7F3EC;
    color: var(--ln-green);
}

.ln-status--inactive,
.ln-status--other {
    background: #EEF1F3;
    color: var(--ln-muted);
}

.ln-alert {
    margin: 0 0 1rem;
    padding: 0.9rem 1rem;
    border-radius: var(--ln-radius-sm);
    border: 1px solid transparent;
    font-size: 0.95rem;
    font-weight: 600;
}

.ln-alert--success {
    background: #E7F3EC;
    color: var(--ln-green);
    border-color: #CDE6D7;
}

.ln-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0 0 1rem;
}

.ln-field label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ln-text);
}

.ln-input,
textarea.ln-input {
    width: 100%;
    min-height: var(--ln-touch);
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--ln-border);
    border-radius: var(--ln-radius-sm);
    background: var(--ln-surface);
    color: var(--ln-text);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.4;
}

textarea.ln-input {
    min-height: 8.5rem;
    resize: vertical;
}

.ln-input:focus,
textarea.ln-input:focus {
    outline: 2px solid var(--ln-green);
    outline-offset: 1px;
}

.ln-field-error {
    color: #9B1C1C;
    font-size: 0.88rem;
    min-height: 1.1em;
}

.ln-report-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.ln-report-list .ln-card {
    margin-bottom: 0;
}

.ln-report-body {
    margin: 0;
    color: var(--ln-text);
    font-size: 0.98rem;
    font-weight: 400;
    white-space: pre-wrap;
    word-break: break-word;
}

.ln-dl {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin: 0;
}

.ln-dl div dt {
    font-size: 0.78rem;
    color: var(--ln-muted);
    margin: 0 0 0.15rem;
}

.ln-dl div dd {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ln-text);
}

.ln-payment .ln-qr {
    display: block;
    width: 196px;
    height: 196px;
    margin: 1rem 0 0.75rem;
    background: #fff;
    border: 1px solid var(--ln-border);
    border-radius: var(--ln-radius-sm);
}

.ln-payment {
    border: 2px solid var(--ln-green);
}

.ln-payment h2 {
    margin: 0 0 0.65rem;
    font-size: 1.25rem;
}

.ln-payment h3,
.ln-payment h4 {
    margin: 1.25rem 0 0.4rem;
    font-size: 1.05rem;
}

.ln-pay-method + .ln-pay-method,
.ln-payment .card-soon {
    margin-top: 1.15rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ln-border);
}

.ln-doc-actions {
    margin-top: 1rem;
}

.card-soon {
    margin-top: 1.15rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ln-border);
}

.card-soon .ln-button[disabled] {
    cursor: not-allowed;
    opacity: 0.7;
}

@media (max-width: 767px) {
    .bill-detail-grid {
        display: flex;
        flex-direction: column;
    }

    .ln-payment .ln-qr {
        max-width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }
}

.ln-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.ln-bill-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.ln-bill-period {
    margin: 0;
    font-weight: 700;
    font-size: 1.05rem;
    text-transform: capitalize;
}

.ln-bill-amount {
    margin: 0.15rem 0 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ln-green);
}

.ln-bill-meta {
    margin: 0 0 0.85rem;
    color: var(--ln-muted);
    font-size: 0.9rem;
}

.ln-bill-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ln-bill-actions .ln-button {
    flex: 1 1 9.5rem;
    min-height: 44px;
}

.ln-table-wrap {
    display: none;
    overflow-x: auto;
}

.ln-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--ln-surface);
    border: 1px solid var(--ln-border);
    border-radius: var(--ln-radius-md);
}

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

.ln-table th {
    font-size: 0.78rem;
    text-transform: uppercase;
    color: var(--ln-muted);
    font-weight: 600;
}

.ln-table tr:last-child td {
    border-bottom: none;
}

.ln-table .ln-button {
    min-height: 40px;
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
}

@media (min-width: 560px) {
    .ln-metrics {
        grid-template-columns: repeat(3, 1fr);
    }

    .ln-actions {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 768px) {
    .ln-mobile-list {
        display: none;
    }

    .ln-table-wrap {
        display: block;
    }
}

/* ----- Shared content shell (P6R.1). Portal/Admin pages keep their own max-width. ----- */
.page-shell {
    box-sizing: border-box;
    max-width: 100%;
}

.ln-shell {
    flex: 1 1 auto;
    width: auto;
    max-width: 100%;
    min-width: 0;
}

.ln-content {
    width: 100%;
    margin-inline: auto;
    padding-inline: 16px;
}

.ln-content--wide {
    max-width: var(--ln-content);
}

.ln-content--narrow {
    max-width: var(--ln-content-narrow);
}

.ln-content--article {
    padding-block: 2rem;
}

@media (min-width: 600px) {
    .ln-content {
        padding-inline: 24px;
    }
}

body.ln-public .app-header.public-header {
    position: sticky;
    top: 0;
    height: auto;
    min-height: 4.25rem;
    display: block;
    padding: 0;
    background: var(--ln-surface);
    border-bottom: 1px solid var(--ln-border);
    z-index: 300;
}

body.ln-public .public-header__inner {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.75rem;
    min-height: 4.25rem;
}

body.ln-public .public-header .logo-link {
    display: flex;
    align-items: center;
}

body.ln-public .ln-brand-logo {
    display: block;
    height: 32px;
    width: auto;
    max-width: min(148px, 42vw);
}

body.ln-public .public-nav {
    display: none;
}

body.ln-public .public-header__actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.35rem;
}

body.ln-public .public-header__register {
    display: none;
}

body.ln-public .public-nav__link {
    color: var(--ln-text);
    text-decoration: none;
    font-weight: 600;
    min-height: var(--ln-touch);
    display: inline-flex;
    align-items: center;
    padding: 0 0.35rem;
}

body.ln-public .public-nav__link:hover {
    color: var(--ln-green);
}

@media (min-width: 900px) {
    body.ln-public .public-header__inner {
        grid-template-columns: auto 1fr auto;
        min-height: 4.75rem;
    }

    body.ln-public .ln-brand-logo {
        height: 40px;
        max-width: 172px;
    }

    body.ln-public .public-nav {
        display: flex;
        justify-content: center;
        gap: 1.75rem;
    }

    body.ln-public .public-header__register {
        display: inline-flex;
    }
}

body.ln-public a:focus-visible,
body.ln-public button:focus-visible,
body.ln-public input:focus-visible,
body.ln-public .ln-button:focus-visible {
    outline: 2px solid var(--ln-green);
    outline-offset: 2px;
}

body.ln-public .ln-button {
    transition: background-color var(--ln-ease), color var(--ln-ease), border-color var(--ln-ease), box-shadow var(--ln-ease);
}

body.ln-public .site-footer {
    padding: 1.25rem 0;
}

body.ln-public .site-footer__inner {
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    body.ln-public *,
    body.ln-public *::before,
    body.ln-public *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ----- Customer adaptive shell ----- */
body.ln-portal .customer-header {
    height: 66px;
}

body.ln-portal .menu-btn,
body.ln-portal .profile-btn {
    color: var(--ln-green);
}

body.ln-portal .customer-header__logo {
    height: 28px;
    width: auto;
    max-width: 105px;
}

.customer-rail {
    display: none;
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(36, 40, 43, 0.35);
    z-index: 240;
}

.drawer-backdrop.is-visible {
    display: block;
}

body.ln-portal .side-menu {
    width: min(84vw, 320px);
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1rem 0.85rem 1.25rem;
    display: flex;
    flex-direction: column;
    background: var(--ln-surface);
    border-right: 1px solid var(--ln-border);
}

body.ln-portal .customer-drawer__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding: 0 0.35rem;
}

body.ln-portal .customer-drawer__top .ln-brand-logo {
    height: 28px;
    width: auto;
    max-width: 110px;
}

body.ln-portal .side-menu nav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
}

body.ln-portal .nav-item {
    min-height: 48px;
    padding: 0 0.8rem;
    border-radius: 10px;
    color: var(--ln-text);
    font-weight: 600;
}

body.ln-portal .nav-item.active {
    background: var(--ln-green-soft);
    color: var(--ln-green);
}

body.ln-portal .nav-item--action {
    margin-top: auto;
    color: var(--ln-muted);
}

.dash-grid,
.profile-grid,
.reports-split,
.bill-detail-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 1100px) {
    body.ln-portal .customer-header,
    body.ln-portal .side-menu,
    body.ln-portal .drawer-backdrop {
        display: none !important;
    }

    .customer-rail {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 240px;
        padding: 1.25rem 0.9rem 1rem;
        background: var(--ln-surface);
        border-right: 1px solid var(--ln-border);
        z-index: 210;
    }

    .customer-rail__brand {
        display: flex;
        align-items: center;
        min-height: 48px;
        margin-bottom: 1.25rem;
        padding: 0 0.45rem;
    }

    .customer-rail__brand .ln-brand-logo {
        height: 32px;
        width: auto;
        max-width: 148px;
    }

    .customer-rail__nav {
        display: flex;
        flex-direction: column;
        gap: 0.2rem;
        flex: 1;
    }

    .customer-rail__logout {
        margin: 0;
    }

    body.ln-portal .page-shell {
        padding-left: 240px;
    }

    body.ln-portal .ln-page {
        padding: 2rem 2.25rem 2.5rem;
    }

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

    .dash-grid .dash-actions {
        grid-column: 1 / -1;
    }

    .profile-grid,
    .bill-detail-grid {
        grid-template-columns: 1.15fr 0.85fr;
    }

    .reports-split {
        grid-template-columns: 2fr 3fr;
        align-items: start;
    }
}

/* ----- Admin adaptive shell ----- */
.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 0 1rem;
    background: var(--ln-surface);
    border-bottom: 1px solid var(--ln-border);
}

.admin-topbar .ln-brand-logo {
    height: 28px;
    width: auto;
    max-width: 120px;
}

.admin-topbar__label {
    font-weight: 700;
    color: var(--ln-green);
}

.admin-topbar__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-topbar__actions form {
    margin: 0;
}

.admin-topbar__logout {
    padding: 0.5rem;
    white-space: nowrap;
}

.admin-topbar__logout:focus-visible {
    outline: 2px solid var(--ln-green);
    outline-offset: 2px;
}

.admin-rail {
    display: none;
}

body.ln-admin .app-header {
    display: none;
}

@media (min-width: 1100px) {
    .admin-topbar {
        display: none;
    }

    .admin-rail {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 240px;
        padding: 1.2rem 0.85rem 1rem;
        background: var(--ln-surface);
        border-right: 1px solid var(--ln-border);
        z-index: 210;
    }

    .admin-rail__brand {
        display: flex;
        align-items: center;
        min-height: 48px;
        margin-bottom: 1rem;
        padding: 0 0.4rem;
    }

    .admin-rail__brand .ln-brand-logo {
        height: 32px;
        width: auto;
        max-width: 148px;
    }

    .admin-rail__nav {
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
        flex: 1;
    }

    .admin-rail__link {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 0 0.75rem;
        border-radius: 10px;
        color: var(--ln-text);
        text-decoration: none;
        font-weight: 600;
        background: none;
        border: 0;
        width: 100%;
        text-align: left;
        font-family: inherit;
        cursor: pointer;
    }

    .admin-rail__link:hover {
        color: var(--ln-green);
    }

    .admin-rail__link.is-active {
        background: var(--ln-green-soft);
        color: var(--ln-green);
    }

    .admin-rail__foot {
        display: grid;
        gap: 0.15rem;
        margin: 0;
    }

    .admin-rail__foot form {
        margin: 0;
    }

    body.ln-admin .page-shell {
        padding-left: 240px;
    }

    body.ln-admin .admin-nav {
        display: none;
    }
}
