:root {
    --navy-900: #0f1e4f;
    --navy-800: #152861;
    --navy-700: #223874;
    --red-600: #e33b2e;
    --red-500: #f04d3f;
    --sand-100: #f4f0e8;
    --slate-100: #eef2f8;
    --slate-200: #d8dfeb;
    --slate-400: #6d778c;
    --slate-700: #263044;
    --white: #ffffff;
    --shadow-lg: 0 22px 60px rgba(15, 30, 79, 0.18);
    --shadow-md: 0 14px 32px rgba(19, 39, 93, 0.12);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Libre Franklin", sans-serif;
    color: var(--slate-700);
    background:
        radial-gradient(circle at top left, rgba(240, 77, 63, 0.16), transparent 32%),
        radial-gradient(circle at right center, rgba(21, 40, 97, 0.18), transparent 28%),
        linear-gradient(180deg, #f8fafc 0%, #eef3fb 100%);
}

body.modal-open {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

.guest-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
}

.login-hero {
    width: 100%;
    max-width: 1240px;
}

.login-panel {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 28px;
    align-items: stretch;
}

.login-brand,
.auth-card,
.sidebar,
.panel,
.stat-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.65);
}

.login-brand {
    padding: 42px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.login-brand::before {
    content: "";
    position: absolute;
    inset: auto -40px -100px auto;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(227, 59, 46, 0.2), rgba(15, 30, 79, 0.2));
}

.login-brand img {
    width: min(480px, 100%);
    margin-bottom: 26px;
}

.eyebrow {
    margin: 0 0 10px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--red-600);
}

.login-brand h1,
.auth-card h2,
.panel h2,
.topbar h1 {
    font-family: "Barlow", sans-serif;
    margin: 0;
    color: var(--navy-900);
}

.login-brand h1 {
    font-size: clamp(2.25rem, 4vw, 4.4rem);
    line-height: 0.98;
    max-width: 720px;
}

.support-copy {
    margin: 18px 0 0;
    max-width: 620px;
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--slate-400);
}

.auth-card {
    padding: 34px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
}

.auth-card-header p {
    margin: 10px 0 0;
    color: var(--slate-400);
    line-height: 1.6;
}

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

.field span {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--navy-800);
}

.field input {
    width: 100%;
    border: 1px solid var(--slate-200);
    border-radius: 14px;
    padding: 14px 16px;
    font: inherit;
    color: var(--slate-700);
    background: var(--white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus {
    outline: none;
    border-color: rgba(227, 59, 46, 0.55);
    box-shadow: 0 0 0 4px rgba(227, 59, 46, 0.12);
}

.button {
    appearance: none;
    border: 0;
    border-radius: 14px;
    padding: 14px 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    color: var(--white);
    background: linear-gradient(135deg, var(--red-600), #d62f22);
    box-shadow: 0 16px 30px rgba(227, 59, 46, 0.22);
}

.button-secondary {
    color: var(--navy-900);
    background: linear-gradient(180deg, #ffffff, #edf2fa);
}

.button-block {
    width: 100%;
}

.auth-card-footer {
    display: grid;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(15, 30, 79, 0.04), rgba(15, 30, 79, 0.08));
    color: var(--slate-400);
    font-size: 0.92rem;
}

.auth-card-footer code {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(15, 30, 79, 0.08);
    color: var(--navy-900);
    font-family: "Barlow", sans-serif;
    font-size: 0.9rem;
}

.flash {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    max-width: 560px;
    width: calc(100% - 24px);
    border-radius: 14px;
    padding: 14px 18px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    opacity: 1;
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.flash.is-hiding {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
}

.flash-success {
    background: #e7f7ea;
    color: #17603a;
}

.flash-error {
    background: #ffebea;
    color: #8a2118;
}

.app-shell {
    padding: 20px;
}

.app-frame {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    gap: 20px;
    min-height: calc(100vh - 40px);
}

.sidebar {
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand img {
    width: 82px;
}

.brand strong {
    display: block;
    font-family: "Barlow", sans-serif;
    font-size: 1.18rem;
    color: var(--navy-900);
}

.brand span {
    color: var(--slate-400);
    font-size: 0.92rem;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    font-weight: 700;
    color: var(--navy-900);
    background: rgba(15, 30, 79, 0.04);
}

.nav-link.is-active {
    color: var(--white);
    background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
}

.nav-link:hover {
    background: rgba(15, 30, 79, 0.08);
}

.is-disabled {
    opacity: 0.55;
    pointer-events: none;
}

.sidebar-logout {
    margin-top: auto;
}

.main-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.topbar,
.panel {
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    background: linear-gradient(135deg, rgba(15, 30, 79, 0.95), rgba(34, 56, 116, 0.92));
    color: var(--white);
}

.topbar h1 {
    color: var(--white);
    font-size: clamp(1.65rem, 3vw, 2.4rem);
}

.topbar .eyebrow {
    color: rgba(255, 255, 255, 0.75);
}

.topbar-user {
    display: grid;
    justify-items: end;
    gap: 4px;
    text-align: right;
}

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

.topbar-user small {
    color: rgba(255, 255, 255, 0.72);
}

.topbar-user-link {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.content-grid {
    display: grid;
    gap: 20px;
}

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

.stat-card {
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.stat-label {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--slate-400);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
}

.stat-card strong {
    display: block;
    font-family: "Barlow", sans-serif;
    font-size: 2.4rem;
    color: var(--navy-900);
}

.stat-card p {
    margin: 10px 0 0;
    color: var(--slate-400);
    line-height: 1.6;
}

.content-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
}

.panel {
    padding: 24px;
}

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

.action-grid,
.roadmap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.action-card,
.roadmap-card {
    border-radius: 18px;
    padding: 18px;
    background: linear-gradient(180deg, rgba(15, 30, 79, 0.04), rgba(15, 30, 79, 0.07));
    border: 1px solid rgba(21, 40, 97, 0.08);
}

.action-card strong,
.roadmap-card strong {
    display: block;
    margin-bottom: 8px;
    font-family: "Barlow", sans-serif;
    font-size: 1.2rem;
    color: var(--navy-900);
}

.action-card span,
.roadmap-card p {
    color: var(--slate-400);
    line-height: 1.65;
    margin: 0;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--slate-200);
    text-align: left;
    font-size: 0.95rem;
}

.data-table th {
    color: var(--navy-900);
    font-family: "Barlow", sans-serif;
    font-size: 0.96rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(227, 59, 46, 0.1);
    color: var(--red-600);
    font-size: 0.84rem;
    font-weight: 700;
}

.empty-state {
    text-align: center;
    color: var(--slate-400);
}

.header-actions,
.table-actions,
.filter-actions,
.inline-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inline-form {
    margin: 0;
}

.filter-bar {
    display: grid;
    grid-template-columns: 2fr repeat(2, minmax(180px, 1fr)) auto;
    gap: 14px;
    margin-bottom: 18px;
}

.table-subtext {
    margin-top: 4px;
    color: var(--slate-400);
    font-size: 0.84rem;
}

.button-small {
    min-height: 38px;
    padding: 10px 14px;
    font-size: 0.88rem;
}

.button,
.nav-link,
.modal-close {
    touch-action: manipulation;
}

.status-pill-muted {
    background: rgba(109, 119, 140, 0.12);
    color: var(--slate-400);
}

.form-panel {
    display: grid;
    gap: 24px;
}

.form-grid {
    display: grid;
    gap: 16px;
}

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

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

.compact-grid {
    align-items: end;
}

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

.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--slate-200);
    border-radius: 14px;
    padding: 14px 16px;
    font: inherit;
    color: var(--slate-700);
    background: var(--white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.inline-field-action {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.field textarea {
    resize: vertical;
}

.field-help {
    min-height: 52px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(15, 30, 79, 0.05);
    color: var(--slate-400);
    line-height: 1.6;
}

.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: rgba(227, 59, 46, 0.55);
    box-shadow: 0 0 0 4px rgba(227, 59, 46, 0.12);
}

.field-checkbox {
    justify-content: center;
}

.field-checkbox input {
    width: 22px;
    height: 22px;
    margin: 0;
}

.work-type-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--slate-200);
    border-radius: 16px;
    background: rgba(15, 30, 79, 0.03);
}

.work-type-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.work-type-option {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid rgba(15, 30, 79, 0.14);
    border-radius: 999px;
    background: #ffffff;
    color: var(--navy-900);
    font-weight: 700;
}

.work-type-option input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.document-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
}

.document-panel {
    overflow: hidden;
}

.panel-section {
    display: grid;
    gap: 16px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.section-head h3 {
    margin: 0;
    font-family: "Barlow", sans-serif;
    color: var(--navy-900);
    font-size: 1.35rem;
}

.line-items-table .table-input,
.line-items-table select {
    width: 100%;
    min-width: 100px;
    padding: 10px 12px;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    font: inherit;
    color: var(--slate-700);
    background: var(--white);
}

.line-total {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    font-weight: 700;
    color: var(--navy-900);
}

.totals-layout {
    align-items: start;
}

.total-card,
.side-note {
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(15, 30, 79, 0.04), rgba(15, 30, 79, 0.07));
    border: 1px solid rgba(21, 40, 97, 0.08);
    padding: 18px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(21, 40, 97, 0.08);
}

.summary-row strong {
    font-family: "Barlow", sans-serif;
    font-size: 1.12rem;
    color: var(--navy-900);
}

.summary-total {
    border-bottom: 0;
}

.summary-total strong {
    font-size: 1.8rem;
}

.side-panel {
    display: grid;
    align-content: start;
    gap: 18px;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.side-note p {
    margin: 8px 0 0;
    color: var(--slate-400);
    line-height: 1.6;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 30, 79, 0.52);
    backdrop-filter: blur(6px);
}

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

.modal-card {
    width: min(860px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    border-radius: 24px;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    padding: 24px;
}

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

.modal-header h3 {
    margin: 0;
    font-family: "Barlow", sans-serif;
    color: var(--navy-900);
    font-size: 1.5rem;
}

.modal-close {
    border: 0;
    background: transparent;
    color: var(--slate-400);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-feedback {
    border-radius: 14px;
    padding: 12px 14px;
    font-weight: 600;
}

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

.modal-feedback.is-error {
    background: #ffebea;
    color: #8a2118;
}

.modal-feedback.is-success {
    background: #e7f7ea;
    color: #17603a;
}

.print-body {
    padding: 16px;
    background: #dde5f1;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.print-shell {
    max-width: 8.5in;
    margin: 0 auto;
}

.print-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 18px;
}

.template-page {
    width: 7.9in;
    min-height: 11in;
    padding: 0.46in 0.5in 0.42in;
    background: #ffffff;
    box-shadow: var(--shadow-lg);
    font-family: Arial, Helvetica, sans-serif;
    color: #111111;
    position: relative;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    break-after: page;
    page-break-after: always;
}

.template-page:last-child {
    break-after: auto;
    page-break-after: auto;
}

.template-page + .template-page {
    margin-top: 18px;
}

.template-top {
    display: grid;
    grid-template-columns: 27% 45% 18%;
    gap: 0.12in;
    align-items: start;
    margin-bottom: 0.08in;
}

.template-logo {
    width: 1.72in;
    max-width: 100%;
}

.template-company-info {
    display: grid;
    gap: 0.045in;
    padding-top: 0.04in;
    font-size: 9pt;
    line-height: 1.15;
    font-family: "Libre Franklin", Arial, Helvetica, sans-serif;
}

.template-company-name {
    font-family: "Barlow", Arial, Helvetica, sans-serif;
    font-size: 11.4pt;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #121a33;
}

.template-company-line {
    display: grid;
    grid-template-columns: 0.18in 1fr;
    align-items: center;
    gap: 0.06in;
    color: #111111;
}

.template-company-line strong {
    font-weight: 700;
}

.template-company-icon {
    width: 0.15in;
    height: 0.15in;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #111111;
}

.template-company-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.template-doc-header {
    display: grid;
    justify-items: end;
    gap: 0.12in;
    padding-top: 0.06in;
}

.template-doc-label {
    font-family: Arial, Helvetica, sans-serif;
    font-style: italic;
    font-weight: 700;
    font-size: 13pt;
}

.template-doc-number {
    width: 1.15in;
    min-height: 0.38in;
    border: 2px dashed #444444;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.template-doc-page {
    font-size: 8.6pt;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.template-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0.3in;
    background: #243f74;
    color: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
    font-style: italic;
    font-weight: 700;
    font-size: 15pt;
    margin-bottom: 0.08in;
}

.template-fields {
    display: grid;
    gap: 0.055in;
    margin-bottom: 0.06in;
}

.template-row {
    display: grid;
    gap: 0.12in;
}

.template-row.two {
    grid-template-columns: 55% 41%;
}

.template-field {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: stretch;
}

.template-field.large {
    grid-template-columns: 0.72in 1fr;
}

.template-field.medium {
    grid-template-columns: 1.18in 1.2in;
}

.template-field.small {
    grid-template-columns: 0.82in 1.12in;
    justify-content: start;
}

.template-field-other {
    grid-template-columns: 0.82in 1fr;
}

.template-field-label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0.24in;
    padding: 0 0.08in;
    background: #243f74;
    color: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 700;
    font-size: 8.6pt;
}

.template-field-value {
    min-height: 0.24in;
    padding: 0.04in 0.09in;
    border: 2px dashed #444444;
    font-size: 8.9pt;
    line-height: 1.1;
}

.template-row-options {
    align-items: center;
}

.template-option-group {
    display: flex;
    align-items: center;
    gap: 0.06in;
    min-height: 0.24in;
    font-size: 8.8pt;
}

.template-check {
    width: 0.2in;
    height: 0.2in;
    border: 2px dashed #444444;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10pt;
    line-height: 1;
}

.template-check.is-checked {
    font-weight: 700;
}

.template-table-wrap {
    margin-top: 0.05in;
}

.template-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    border-left: 2px dashed #444444;
    border-right: 2px dashed #444444;
}

.template-table th {
    background: #243f74;
    color: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 700;
    font-size: 8.8pt;
    padding: 0.05in 0.06in;
    border-right: 2px solid #132447;
}

.template-table th:last-child {
    border-right: 0;
}

.template-table td {
    height: 0.255in;
    padding: 0.03in 0.06in;
    border-right: 2px dashed #444444;
    border-bottom: 2px dashed #444444;
    font-size: 9pt;
    vertical-align: middle;
}

.template-table td:last-child {
    border-right: 0;
}

.template-table .col-code {
    width: 8%;
}

.template-table .col-description {
    width: 52%;
}

.template-table .col-unit {
    width: 10%;
}

.template-table .col-price {
    width: 14%;
}

.template-table .col-total {
    width: 16%;
}

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

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

.total-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.currency-mark {
    margin-right: 0.04in;
}

.template-note-area {
    display: grid;
    grid-template-columns: 1fr 2.34in;
    gap: 0.16in;
    margin-top: 0.06in;
    border: 2px dashed #444444;
    border-top: 0;
    padding: 0.07in 0.1in 0.08in;
    min-height: 0.98in;
}

.template-note-box {
    display: grid;
    grid-template-rows: auto 1fr;
}

.template-note-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0.92in;
    min-height: 0.3in;
    padding: 0 0.1in;
    background: #243f74;
    color: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 700;
    font-size: 10pt;
    margin-bottom: 0.04in;
}

.template-note-content {
    min-height: 0.54in;
    border: 2px dashed #444444;
    padding: 0.08in;
    font-size: 9pt;
    line-height: 1.25;
    white-space: pre-wrap;
}

.template-note-side {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: start;
    gap: 0;
    padding-top: 0.3in;
}

.template-side-cell {
    min-height: 0.28in;
    border: 2px dashed #444444;
    border-right: 0;
}

.template-side-cell:last-child {
    border-right: 2px dashed #444444;
}

.template-total-bar {
    display: grid;
    grid-template-columns: minmax(1.02in, auto) 1.32in;
    justify-content: end;
    margin-top: 0.1in;
    width: 2.36in;
    margin-left: auto;
    break-inside: avoid;
}

.template-total-label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 0.34in;
    padding: 0 0.12in;
    background: #243f74;
    color: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 700;
    font-size: 9.5pt;
    white-space: nowrap;
}

.template-total-value {
    min-height: 0.34in;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.1in;
    border: 2px dashed #444444;
    border-left: 0;
    white-space: nowrap;
}

.template-total-value strong {
    font-size: 9.5pt;
}

.template-footer {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.42in;
    padding: 0 0.62in;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.5in;
}

.template-signature {
    border-top: 3px double #1d1d1d;
    text-align: center;
    padding-top: 0.02in;
    font-size: 10pt;
}

@media (max-width: 1280px) {
    .data-table {
        min-width: 680px;
    }

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

@media (max-width: 1080px) {
    .login-panel,
    .app-frame,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        gap: 20px;
    }

    .document-shell,
    .two-columns,
    .three-columns,
    .filter-bar,
    .inline-field-action,
    .print-summary-grid,
    .print-bottom-grid,
    .document-print-header,
    .template-top,
    .template-row.two,
    .template-note-area,
    .template-footer {
        grid-template-columns: 1fr;
    }

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

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

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

    .filter-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

@media (max-width: 720px) {
    .guest-shell,
    .app-shell {
        padding: 14px;
    }

    .login-brand,
    .auth-card,
    .topbar,
    .panel,
    .sidebar,
    .stat-card {
        border-radius: 20px;
    }

    .login-brand,
    .auth-card,
    .panel,
    .sidebar,
    .stat-card {
        padding: 20px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 20px;
    }

    .topbar-user {
        width: 100%;
        justify-items: start;
        text-align: left;
    }

    .brand {
        align-items: flex-start;
    }

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

    .nav-link {
        justify-content: center;
        text-align: center;
    }

    .panel-header,
    .section-head,
    .modal-header,
    .modal-actions,
    .header-actions,
    .table-actions,
    .filter-actions,
    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions .button,
    .table-actions .button,
    .filter-actions .button,
    .inline-form .button,
    .modal-actions .button {
        width: 100%;
    }

    .header-actions,
    .table-actions {
        flex-wrap: wrap;
    }

    .panel-header {
        margin-bottom: 16px;
    }

    .filter-bar,
    .inline-field-action {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        gap: 12px;
    }

    .form-grid,
    .content-grid,
    .main-panel,
    .content-columns {
        gap: 16px;
    }

    .field input,
    .field select,
    .field textarea {
        font-size: 16px;
    }

    .work-type-options {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .work-type-option {
        width: 100%;
        justify-content: center;
    }

    .table-wrap {
        margin: 0 -20px;
        padding: 0 20px 6px;
    }

    .data-table {
        min-width: 640px;
    }

    .line-items-table {
        min-width: 960px;
    }

    .data-table th,
    .data-table td {
        padding: 12px 12px;
        white-space: nowrap;
    }

    .modal-backdrop {
        padding: 10px;
        align-items: flex-end;
    }

    .modal-card {
        width: 100%;
        max-height: min(88vh, 100%);
        border-radius: 22px 22px 0 0;
        padding: 20px;
    }

    .print-body {
        padding: 12px;
    }

    .template-page {
        width: auto;
        min-height: auto;
        padding: 20px;
    }

    .document-company {
        flex-direction: column;
    }

    .document-print-title-block {
        text-align: left;
    }

    .template-total-bar {
        grid-template-columns: 1fr;
    }

    .template-note-side {
        padding-top: 0;
    }
}

@media (max-width: 560px) {
    .guest-shell,
    .app-shell {
        padding: 10px;
    }

    .app-frame {
        gap: 12px;
        min-height: auto;
    }

    .sidebar,
    .panel,
    .topbar,
    .stat-card,
    .login-brand,
    .auth-card {
        padding: 16px;
        border-radius: 18px;
    }

    .brand {
        gap: 10px;
    }

    .brand img {
        width: 62px;
    }

    .brand strong {
        font-size: 1rem;
    }

    .topbar h1 {
        font-size: 1.95rem;
        line-height: 1;
    }

    .eyebrow {
        font-size: 0.72rem;
        letter-spacing: 0.14em;
    }

    .stats-grid,
    .action-grid,
    .roadmap-grid,
    .work-type-options {
        grid-template-columns: 1fr;
    }

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

    .nav-link,
    .button {
        min-height: 46px;
    }

    .button {
        padding: 13px 16px;
    }

    .table-wrap {
        margin: 0 -16px;
        padding: 0 16px 6px;
    }

    .data-table {
        min-width: 580px;
    }

    .line-items-table {
        min-width: 920px;
    }

    .modal-card {
        padding: 16px;
    }

    .flash {
        top: 10px;
        width: calc(100% - 16px);
    }
}

@media print {
    @page {
        size: Letter;
        margin: 0;
    }

    body,
    .print-body {
        background: #ffffff;
        padding: 0;
        zoom: 1;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .print-toolbar {
        display: none;
    }

    .print-shell {
        max-width: none;
        width: 100%;
    }

    .template-page {
        width: 100%;
        min-height: 10.5in;
        box-sizing: border-box;
        padding: 0.38in 0.42in 0.32in;
        box-shadow: none;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        margin-top: 0;
    }

    .template-top {
        grid-template-columns: 27% 45% 18%;
    }

    .template-row.two {
        grid-template-columns: 55% 41%;
    }

    .template-note-area {
        grid-template-columns: 1fr 2.34in;
    }

    .template-total-bar {
        display: grid !important;
        grid-template-columns: minmax(1.02in, auto) 1.32in !important;
        width: 2.36in;
        margin-left: auto;
    }

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

    .template-banner,
    .template-field-label,
    .template-note-label,
    .template-total-label,
    .template-table th {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
