:root {
    --brand: #111111;
    --brand-dark: #000000;
    --brand-soft: #f5f5f5;
    --text-main: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
}

body {
    background: #fff;
    min-height: 100vh;
    color: var(--text-main);
    font-family: 'Public Sans', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.brand-text {
    color: var(--brand) !important;
}

.app-navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-color: #000 !important;
}

.navbar-brand {
    font-size: 1.05rem;
    letter-spacing: .2px;
}

.user-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid #000;
    background: #fff;
    color: #111;
    border-radius: 0;
}

.user-meta .meta-dot {
    margin: 0 4px;
    color: #555;
}

.auto-sync-wrap {
    position: relative;
    display: block;
    width: 100%;
}

.ps1583-grid input.autosync-field {
    padding-right: 18px !important;
}

.auto-sync-toggle {
    position: absolute;
    top: 2px;
    right: 0;
    border: 0;
    background: transparent;
    color: #c1121f;
    font-size: 11px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

.auto-sync-toggle:hover {
    color: #8f0e18;
}

.auto-sync-status {
    position: absolute;
    right: 16px;
    top: 1px;
    font-size: 10px;
    color: #c1121f;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

.auto-sync-status .dot {
    width: 6px;
    height: 6px;
    border: 1px solid #c1121f;
    border-top-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: autoSyncSpin .7s linear infinite;
}

@keyframes autoSyncSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.btn-primary {
    background-color: var(--brand);
    border-color: var(--brand);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--brand-dark);
    border-color: var(--brand-dark);
}

.btn-outline-brand {
    color: var(--brand);
    border: 1px solid var(--brand);
    background: #fff;
}

.btn-outline-brand:hover {
    background: var(--brand);
    color: #fff;
}

.badge-brand {
    background: var(--brand-soft);
    color: #111;
    border: 1px solid #111;
}

.page-hero,
.dashboard-hero {
    background: #fff;
    border: 1px solid #000;
    border-left: 1px solid #000;
    border-radius: 0;
    padding: 1rem 1.1rem;
    box-shadow: none;
}

.stat-card {
    border: 1px solid #000;
    border-left: 1px solid #000;
}

.stat-card-success {
    border-left-color: #000;
}

.stat-card-warning {
    border-left-color: #000;
}

.login-shell {
    margin-top: 3rem;
    margin-bottom: 2rem;
}

.login-visual {
    background: linear-gradient(160deg, #f36e23, #d95d18);
    border-radius: 16px 0 0 16px;
    padding: 2rem;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.login-visual img {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
}

.login-visual-copy h2 {
    font-size: 1.35rem;
    margin-bottom: .5rem;
}

.login-card {
    border-radius: 0;
    border: 1px solid #000;
    box-shadow: none !important;
    background: #fff;
}

.login-title {
    font-weight: 700;
    color: #111;
}

.login-card .form-control,
.login-card .input-group-text {
    border-color: #000;
    border-radius: 0;
    background: #fff;
    color: #111;
}

.login-card .form-control:focus {
    border-color: #000;
    box-shadow: none;
}

.login-card .btn-primary {
    background: #111;
    border-color: #111;
    border-radius: 0;
    font-weight: 600;
}

.login-card .btn-primary:hover,
.login-card .btn-primary:focus {
    background: #000;
    border-color: #000;
}

.login-card .text-muted {
    color: #444 !important;
}

.a4-sheet {
    background: #fff;
    border: 0;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.ps1583-wrap {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ps1583-page {
    background: #fff;
    border: 1px solid #c95b1e;
    color: #222;
    font-size: 14px;
}

.ps1583-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #c95b1e;
    padding: 8px 12px;
    background: linear-gradient(180deg, #fff8f4 0%, #fff 100%);
}

.ps1583-head h2 {
    margin: 0;
    font-size: 49px;
    font-weight: 700;
    line-height: 1.1;
    color: #b24d17;
}

.usps-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 11px;
}

.usps-icon {
    width: 34px;
    height: 34px;
    background: #f36e23;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ps1583-strip {
    background: #f36e23;
    color: #fff;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
}

.ps1583-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.ps1583-grid td {
    border: 1px solid #3a3a3a;
    vertical-align: top;
    padding: 5px 7px;
    font-size: 13px;
}

.ps1583-grid strong {
    font-weight: 700;
    font-size: 13px;
}

.ps1583-grid input[type="text"],
.ps1583-grid input[type="email"],
.ps1583-grid input[type="date"] {
    width: 100%;
    border: 0;
    border-bottom: 1px solid #777;
    border-radius: 0;
    background: transparent;
    font-size: 13px;
    padding: 3px 0 2px;
    margin-top: 3px;
    min-height: 18px;
}

.ps1583-grid input:focus {
    outline: none;
    box-shadow: none;
    border-bottom-color: #111;
}

.ps1583-grid input.is-invalid {
    border-bottom-color: var(--brand-dark);
}

.ps1583-grid .invalid-feedback {
    display: block;
    color: var(--brand-dark);
    font-size: 11px;
    margin-top: 4px;
    font-weight: 600;
}

.ps-checks {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px 14px;
    margin-top: 6px;
}

.ps-checks.is-invalid-group {
    border: 1px solid var(--brand-dark);
    background: #fff5ef;
    padding: 6px;
}

.field-group-error {
    color: var(--brand-dark);
    font-size: 11px;
    margin-top: 5px;
    font-weight: 600;
}

.ps-checks label,
.inline-radio label {
    font-size: 12px;
    font-weight: 500;
}

.inline-radio {
    display: flex;
    gap: 20px;
    margin-top: 6px;
}

.protected-inline {
    gap: 14px;
    margin-top: 4px;
    margin-bottom: 2px;
}

.triple,
.double,
.quad {
    display: grid;
    gap: 4px 8px;
}

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

.pmb-split {
    grid-template-columns: 3fr 1fr;
}

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

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

.ps1583-foot {
    border-top: 1px solid #c95b1e;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 8px;
    font-size: 13px;
}

.agreement-box {
    border-top: 1px solid #c95b1e;
    border-bottom: 1px solid #c95b1e;
    background: #fff8f2;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
}

.agreement-box.is-invalid-group {
    border: 1px solid var(--brand-dark);
    background: #fff1e8;
}

.agreement-box label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.ps1583-foot em {
    font-style: italic;
}

.block-title {
    font-size: 35px;
    font-weight: 700;
    margin: 8px 8px 6px;
    color: #b24d17;
}

.ps1583-list {
    width: calc(100% - 16px);
    margin: 0 8px 8px;
    border-collapse: collapse;
}

.ps1583-list td {
    border: 1px solid #2b2b2b;
    padding: 4px 8px;
    vertical-align: top;
}

.ps1583-list td:first-child {
    width: 40px;
    text-align: center;
}

.two-col-text {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 8px;
}

.two-col-text p {
    margin-bottom: 8px;
    line-height: 1.28;
}

.notary {
    margin: 8px;
    border: 1px solid #2b2b2b;
    display: grid;
    grid-template-columns: 3fr 1fr;
}

.notary-left,
.notary-right {
    padding: 8px;
    min-height: 120px;
}

.notary-left {
    border-right: 1px solid #2b2b2b;
}

.notary-sign {
    margin-top: 18px;
}

.ps1583-document {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ps-page {
    background: #ececec;
    border: 1px solid #313131;
    color: #111;
    font-size: 12px;
}

.ps-tophead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #222;
    background: #f6f6f6;
}

.ps-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-weight: 700;
    font-size: 11px;
}

.ps-brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 4px;
    background: #222;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ps-title {
    font-size: 38px;
    line-height: 1.1;
    font-weight: 700;
    padding-right: 10px;
}

.ps-blackbar {
    background: #1f1f1f;
    color: #fff;
    padding: 6px 10px;
    font-weight: 700;
    font-size: 12px;
}

.ps-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.ps-grid td {
    border: 1px solid #2c2c2c;
    vertical-align: top;
    padding: 4px 6px;
    background: #ececec;
}

.ps-grid td strong {
    display: block;
    font-size: 12px;
    margin-bottom: 3px;
}

.ps-grid td span {
    display: block;
    font-size: 11px;
    margin-bottom: 2px;
}

.ps-grid input[type="text"],
.ps-grid input[type="email"],
.ps-grid input[type="date"],
.ps-grid input[type="tel"] {
    width: 100%;
    border: 0;
    border-bottom: 1px solid #777;
    background: transparent;
    font-size: 12px;
    padding: 2px 0;
    border-radius: 0;
}

.ps-grid input:focus {
    outline: none;
    border-bottom-color: #000;
    box-shadow: none;
}

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

.chk-grid label,
.inline-check label {
    font-size: 11px;
    font-weight: 500;
}

.inline-check {
    display: flex;
    gap: 14px;
    margin-top: 4px;
}

.double,
.triple {
    display: grid;
    gap: 6px;
}

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

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

.ps-footline {
    border-top: 1px solid #222;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    font-size: 11px;
}

.ps-page-2 {
    padding: 8px;
}

.ps-note-title {
    font-size: 22px;
    font-weight: 700;
    margin: 4px 0 8px;
}

.ps-grid.compact td:first-child {
    width: 48px;
    text-align: center;
    font-weight: 700;
}

.ps-two-cols {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.ps-two-cols > div {
    border: 1px solid #2c2c2c;
    background: #ececec;
    padding: 8px;
}

.ps-two-cols h4 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

.notary-box {
    margin-top: 8px;
    border: 1px solid #2c2c2c;
    display: grid;
    grid-template-columns: 3fr 1fr;
}

.notary-main,
.notary-seal {
    padding: 8px;
    min-height: 110px;
}

.notary-main {
    border-right: 1px solid #2c2c2c;
}

.pro-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .8rem;
    padding: .7rem .9rem;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--brand-soft), #fff);
    border: 1px solid #f8d9c7;
    margin-bottom: 1rem;
}

.pro-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #b24912;
}

.header-badge {
    background: #fff;
    border: 1px solid #ffd9c4;
    color: #b24912;
    padding: .38rem .65rem;
    border-radius: 999px;
    font-size: .79rem;
    font-weight: 600;
}

.form-section {
    border: 1px solid #f4e6dd;
    border-radius: 10px;
    padding: 12px;
    margin-top: 10px;
    background: #fff;
}

.section-title {
    margin-top: 0;
    margin-bottom: .8rem;
    padding-bottom: .45rem;
    border-bottom: 1px solid #f6d6c3;
    font-size: 1rem;
    font-weight: 700;
    color: #b24912;
    display: flex;
    align-items: center;
    gap: .45rem;
}

.form-label {
    margin-bottom: .25rem;
    font-size: .85rem;
    font-weight: 700;
    color: #374151;
}

.form-control:focus,
.form-select:focus {
    border-color: #f2a77f;
    box-shadow: 0 0 0 .25rem rgba(243, 110, 35, 0.15);
}

.global-loader {
    position: fixed;
    inset: 0;
    background: rgba(30, 41, 59, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loader-card {
    width: 220px;
    background: #fff;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2);
}

/* PS1583 final visual overrides: black grid, tighter spacing, red errors */
.ps1583-page {
    border: 0 !important;
}

.ps1583-head {
    border-bottom-color: #000 !important;
    background: #fff !important;
}

.ps1583-head h2,
.block-title {
    color: #222 !important;
}

.usps-icon,
.ps1583-strip {
    background: #222 !important;
}

.ps1583-grid td,
.ps1583-list td,
.notary,
.notary-left,
.agreement-box,
.ps1583-foot {
    border-color: #000 !important;
}

.ps1583-grid td {
    padding: 4px 6px !important;
}

.ps1583-grid td > input[type="text"],
.ps1583-grid td > input[type="email"],
.ps1583-grid td > input[type="date"] {
    display: block;
    margin-top: 3px !important;
    height: 17px !important;
    line-height: 16px !important;
    font-size: 11px !important;
}

.ps1583-grid .split-lines > div {
    padding: 0 8px;
}

.ps1583-grid .split-lines > div:first-child {
    padding-left: 0;
}

.ps1583-grid .split-lines > div:last-child {
    padding-right: 0;
}

.ps1583-grid .split-lines > div:not(:last-child) {
    border-right: 1px solid #000;
}

.ps1583-grid .ps-checks {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
    row-gap: 4px !important;
    column-gap: 10px !important;
    align-items: start;
    align-content: start;
    grid-auto-rows: minmax(20px, auto);
}

.ps1583-grid .ps-checks label {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    line-height: 1.2;
    font-size: 11px;
    min-width: 0;
    margin: 0;
    padding: 1px 0;
    min-height: 20px;
}

.ps1583-grid .ps-checks label.wide-option {
    grid-column: 1 / -1;
}

.ps1583-grid .ps-checks input[type="checkbox"] {
    margin-top: 2px;
}

.ps1583-grid input.is-invalid {
    border-bottom-color: #dc2626 !important;
}

.ps1583-grid .invalid-feedback,
.field-group-error {
    color: #dc2626 !important;
    font-weight: 600;
    font-size: 10px;
    line-height: 1.2;
    margin-top: 3px;
}

.ps1583-grid td {
    position: relative;
}

.ps1583-grid input.is-invalid[data-error]::placeholder {
    color: #dc2626;
}

.ps-checks.is-invalid-group,
.agreement-box.is-invalid-group,
.inline-radio.is-invalid-group {
    border: 1px solid #dc2626 !important;
    background: #fff5f5 !important;
    padding: 6px !important;
}

.a4-sheet {
    border: 0 !important;
}

.container {
    max-width: 1420px !important;
}

@media print {
    .no-print,
    .navbar,
    .btn {
        display: none !important;
    }

    body,
    .print-body {
        background: #fff !important;
    }

    .container {
        width: 210mm;
        max-width: 210mm;
        margin: 0 auto;
        padding: 0;
    }

    .a4-sheet {
        width: 210mm;
        min-height: 297mm;
        border: 0;
        box-shadow: none;
        border-radius: 0;
        padding: 0;
        background: transparent;
    }

    .ps1583-page {
        page-break-after: always;
    }
}

@media (max-width: 991.98px) {
    .login-card {
        border-radius: 16px;
    }

    .ps1583-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .ps1583-head h2 {
        font-size: 26px;
    }

    .ps-checks {
        grid-template-columns: 1fr;
    }

    .double,
    .triple,
    .quad,
    .two-col-text,
    .notary,
    .ps1583-foot {
        grid-template-columns: 1fr;
    }
}

/* Keep original box size and only remove accidental extra inner spacing */
.ps1583-grid td {
    padding: 6px 8px !important;
    line-height: 1.2 !important;
    vertical-align: top !important;
}

.ps1583-grid td > input[type="text"],
.ps1583-grid td > input[type="email"],
.ps1583-grid td > input[type="date"] {
    margin-top: 4px !important;
    min-height: 20px !important;
    height: auto !important;
    line-height: 1.2 !important;
    padding: 3px 0 !important;
}

.ps1583-grid .split-lines > div,
.ps1583-grid .double > div,
.ps1583-grid .triple > div,
.ps1583-grid .quad > div,
.ps1583-grid .stack-tight > div {
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.ps1583-grid .double,
.ps1583-grid .triple,
.ps1583-grid .quad,
.ps1583-grid .stack-tight {
    margin: 0 !important;
}

.ps1583-grid .quad {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

.ps1583-grid .inline-radio,
.ps1583-grid .ps-checks {
    margin-bottom: 0 !important;
}

.ps1583-grid .protected-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.ps1583-grid .protected-inline {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    gap: 20px !important;
}
