:root {
    --brand-50: #f0fafb;
    --brand-100: #d7f3f6;
    --brand-200: #b0e4ea;
    --brand-300: #74d0db;
    --brand-400: #2eb8c4;
    --brand-500: #00a0b0;
    --brand-600: #00889a;
    --brand-700: #006d80;
    --brand-800: #003060;
}

[x-cloak] { display: none !important; }

html {
    -webkit-text-size-adjust: 100%;
    height: 100%;
    overflow: hidden;
}
html:has(body.chart-print) {
    height: auto;
    overflow: auto;
}

body.app-shell {
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background:
        radial-gradient(900px 420px at 8% -8%, rgba(176, 228, 234, 0.75), transparent 55%),
        radial-gradient(720px 360px at 100% 0%, rgba(46, 184, 196, 0.18), transparent 50%),
        #f7fcfd;
    color: #1f3348;
}

.logo-img {
    display: block;
    width: auto;
    height: 2.75rem;
    max-width: min(17rem, 58vw);
    object-fit: contain;
    object-position: left center;
    flex: none;
}
@media (min-width: 640px) {
    .logo-img { height: 3.25rem; max-width: 18rem; }
}
.logo-img.logo-hero {
    height: 3.75rem;
    max-width: min(20rem, 86vw);
    object-position: left center;
}
@media (min-width: 768px) {
    .logo-img.logo-hero { height: 4.5rem; max-width: 22rem; }
}
.logo-img.logo-auth {
    height: 4.25rem;
    max-width: min(20rem, 80vw);
    margin-inline: auto;
    object-position: center;
}
.logo-img.logo-footer {
    height: 2.35rem;
    max-width: 11rem;
    object-position: center;
}
.logo-img.logo-print {
    height: 11mm;
    max-width: 42mm;
    object-position: left center;
}

.site-header {
    position: relative;
    top: 0;
    z-index: 30;
    width: 100%;
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--brand-100);
}
.site-header-inner {
    max-width: 64rem;
    margin: 0 auto;
    padding: 0.6rem 0.85rem;
    padding-left: max(0.85rem, env(safe-area-inset-left));
    padding-right: max(0.85rem, env(safe-area-inset-right));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.site-brand {
    display: flex;
    align-items: center;
    flex: none;
    min-width: 8.5rem;
}
.site-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.3rem;
    flex: none;
}
.site-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.5rem;
    min-width: 2.5rem;
    padding: 0 0.65rem;
    border-radius: 0.85rem;
    color: #5b6b7a;
    font-size: 0.875rem;
    white-space: nowrap;
}
.site-nav-link:hover,
.site-nav-link.is-active {
    background: var(--brand-50);
    color: var(--brand-800);
}
.site-nav-cta {
    min-height: 2.5rem !important;
    padding: 0.45rem 0.85rem !important;
    font-size: 0.875rem;
    white-space: nowrap;
}
.site-nav-cta.is-active { filter: brightness(0.95); }
@media (max-width: 639px) {
    .site-nav-label { display: none; }
    .site-header .logo-img {
        height: 2.35rem;
        max-width: min(9.5rem, 42vw);
    }
}

.site-main {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1.25rem 0.85rem 2rem;
    padding-left: max(0.85rem, env(safe-area-inset-left));
    padding-right: max(0.85rem, env(safe-area-inset-right));
}
.site-main-inner {
    width: 100%;
    max-width: 64rem;
    margin: 0 auto;
}
@media (min-width: 640px) {
    .site-main { padding: 2rem 1rem 2.5rem; }
}
.site-main-auth {
    display: grid;
    place-items: center;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

.site-footer {
    flex: 0 0 auto;
    width: 100%;
    z-index: 20;
    background: #fff;
    border-top: 1px solid var(--brand-100);
    color: #7b8b96;
    font-size: 0.75rem;
}
.site-footer-inner {
    max-width: 64rem;
    margin: 0 auto;
    padding: 1.1rem 0.85rem max(1.15rem, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    text-align: center;
}
.site-footer-brand {
    display: flex;
    justify-content: center;
}
.site-footer-copy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin: 0;
    line-height: 1.45;
    flex-wrap: wrap;
}

@media (max-width: 767px) {
    body.page-register .site-footer {
        display: none !important;
    }
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .8rem;
    border-radius: .85rem;
    color: #5b6b7a;
    font-size: .875rem;
}
.nav-item:hover { background: var(--brand-50); color: var(--brand-700); }
.nav-item.active {
    background: var(--brand-100);
    color: var(--brand-800);
    font-weight: 600;
}
.nav-item svg, .nav-item i { width: 1rem; height: 1rem; flex: none; }

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    border-radius: .9rem;
    background: var(--brand-500);
    color: #fff;
    font-weight: 500;
    padding: .7rem 1.15rem;
    box-shadow: 0 8px 20px -12px rgba(0, 160, 176, 0.7);
}
.btn-primary:hover { background: var(--brand-600); }
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    border-radius: .9rem;
    border: 1px solid #d5e8ed;
    background: #fff;
    color: #1f3348;
    font-weight: 500;
    padding: .7rem 1.15rem;
}
.btn-ghost:hover { background: var(--brand-50); border-color: var(--brand-200); }

.card {
    background: #fff;
    border: 1px solid #e4eef1;
    border-radius: 1.15rem;
    box-shadow: 0 10px 30px -22px rgba(0, 48, 96, 0.28);
}

.label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .25rem; color: #334155; }
.input, select.input, textarea.input {
    width: 100%;
    border: 1px solid #d5e3e8;
    border-radius: .85rem;
    padding: .65rem .8rem;
    background: #fff;
}
.input:focus, select:focus, textarea:focus, input:focus {
    outline: none;
    border-color: var(--brand-300);
    box-shadow: 0 0 0 3px rgba(0, 160, 176, 0.18);
}
.input.is-invalid, select.is-invalid {
    border-color: #e11d48;
    box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.16);
}
.is-invalid-group {
    border: 1px solid #e11d48;
    border-radius: 0.9rem;
    padding: 0.5rem;
    background: #fff1f2;
}
.is-invalid-group label,
.is-invalid-group button {
    border-color: #e11d48 !important;
    background: #fff1f2;
}
.label.required::after {
    content: ' *';
    color: #e11d48;
}
.field-error { color: #e11d48; font-size: 0.75rem; margin-top: 0.25rem; }

.admin-frame {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
@media (min-width: 768px) {
    .admin-frame { flex-direction: row; }
}

.admin-topbar {
    width: 100%;
    flex: 0 0 auto;
    z-index: 30;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--brand-100);
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
@media (min-width: 768px) {
    .admin-topbar { display: none; }
}
.admin-topbar > a:last-of-type { margin-left: auto; }
.admin-drawer .logo-img {
    height: 2.75rem;
    max-width: 12.5rem;
}

.admin-content {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.admin-header {
    flex: 0 0 auto;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--brand-100);
    padding: 1rem 2rem;
}
@media (min-width: 768px) {
    .admin-header { display: flex; }
}
.admin-page-title {
    margin: 0 0 0.75rem;
}
@media (min-width: 768px) {
    .admin-page-title { display: none; }
}
.admin-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1rem;
}
@media (min-width: 768px) {
    .admin-main { padding: 2rem; }
}
.admin-content > .site-footer {
    flex: 0 0 auto;
}
.admin-content .site-footer-inner {
    padding-top: 0.75rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

#qr-reader {
    min-height: 240px;
}
#qr-reader video {
    width: 100%;
    display: block;
    border-radius: 0.9rem;
}
.admin-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(15, 23, 42, 0.4);
}
@media (min-width: 768px) {
    .admin-overlay { display: none !important; }
}

.tap-target {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.safe-bottom {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

.admin-drawer {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(18rem, 85vw);
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: none;
}
.admin-drawer.is-open {
    transform: translateX(0);
    box-shadow: 12px 0 40px -20px rgba(0, 48, 96, 0.45);
}
.admin-drawer nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.admin-drawer-brand,
.admin-drawer > form { flex: 0 0 auto; }
@media (min-width: 768px) {
    .admin-drawer {
        position: relative;
        inset: auto;
        z-index: 1;
        transform: none;
        width: 16rem;
        flex: 0 0 16rem;
        height: auto;
        max-height: none;
        align-self: stretch;
        box-shadow: none;
    }
}
@media (max-width: 767px) {
    body:has(.admin-drawer.is-open) { overflow: hidden; }
    .input, select, textarea,
    input[type="text"], input[type="password"], input[type="tel"],
    input[type="number"], input[type="search"] {
        font-size: 16px !important;
        min-height: 44px;
    }
    .btn-primary, .btn-ghost { min-height: 44px; }
    .overflow-x-auto { -webkit-overflow-scrolling: touch; }
}

@media print {
    @page {
        size: A4 portrait;
        margin: 8mm;
    }
    html, body, body.app-shell, body.chart-print {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        display: block !important;
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    header:not(.chart-head), footer, nav, aside, .no-print, .site-header, .site-footer, .admin-topbar, .admin-header, .admin-drawer { display: none !important; }
    .site-main, .admin-main, .admin-content, .admin-frame {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        display: block !important;
        padding: 0 !important;
        max-width: none !important;
    }
    .print-card { box-shadow: none !important; border: 1px solid #ddd !important; }
    .chart-toolbar, .chart-hint { display: none !important; }
    .chart-page {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        overflow: visible !important;
    }
    .chart-sheet {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        min-height: 0 !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: 0 !important;
        overflow: visible !important;
        font-size: 9.5pt !important;
        line-height: 1.28 !important;
    }
    .chart-table { break-inside: auto; page-break-inside: auto; }
    .chart-sign { break-inside: avoid; page-break-inside: avoid; }
}

.chart-print {
    background: #d7e4e8;
    min-height: 100dvh;
    height: auto;
    overflow: auto;
    margin: 0;
    color: #1f3348;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.chart-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: #fff;
    border-bottom: 1px solid var(--brand-100);
}
.chart-hint {
    margin: 0;
    font-size: 0.78rem;
    color: #5b6b7a;
    text-align: center;
    flex: 1;
}
.chart-page {
    box-sizing: border-box;
    width: 210mm;
    min-height: 297mm;
    margin: 12px auto 28px;
    background: #fff;
    box-shadow: 0 12px 40px -18px rgba(0, 48, 96, 0.45);
}
.chart-sheet {
    box-sizing: border-box;
    width: 210mm;
    min-height: 297mm;
    max-width: 210mm;
    margin: 0;
    background: #fff;
    color: #111;
    padding: 8mm 9mm 7mm;
    font-size: 10.5px;
    line-height: 1.3;
}
.chart-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px 8px;
    align-items: center;
    margin-bottom: 5px;
    padding-bottom: 4px;
    border-bottom: 1.5px solid #003060;
}
.chart-head-title { min-width: 0; }
.chart-head-title h1 {
    font-size: 13.5px;
    font-weight: 700;
    color: #003060;
    margin: 0;
    line-height: 1.2;
}
.chart-kicker, .chart-sub { margin: 0; color: #006d80; font-size: 9px; }
.chart-head-meta {
    display: flex;
    flex-direction: row;
    gap: 6px;
    align-items: center;
}
.chart-boxes {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 32mm;
}
.chart-box {
    border: 1px solid #003060;
    padding: 2px 6px;
    text-align: right;
    min-width: 32mm;
}
.chart-box span { display: block; font-size: 8px; color: #5b6b7a; line-height: 1.2; }
.chart-box strong { font-size: 11px; }
.chart-qr {
    width: 16mm;
    height: 16mm;
    object-fit: contain;
    border: 1px solid #d5e8ed;
    background: #fff;
}
.chart-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin: 0 0 4px;
}
.chart-table col.col-lbl { width: 32mm; }
.chart-table th, .chart-table td {
    border: 1px solid #334155;
    padding: 2.5px 5px;
    vertical-align: top;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.chart-table .sec {
    background: #d7f3f6;
    color: #003060;
    text-align: left;
    font-weight: 700;
    font-size: 10px;
    padding: 3px 5px;
}
.chart-table .lbl {
    width: 32mm;
    background: #f7fcfd;
    font-weight: 600;
    color: #334155;
    white-space: normal;
}
.chart-table .ctr { text-align: center; white-space: nowrap; }
.chart-table .pre { white-space: pre-wrap; }
.chart-table .alert-cell { color: #9f1239; font-weight: 600; }
.chart-sign td { width: 33.33%; text-align: center; height: auto; padding-top: 4px; padding-bottom: 4px; }
.sig-line {
    height: 10mm;
    border-bottom: 1px solid #334155;
    margin: 2px 8px 4px;
}
.chart-sign p { margin: 0; font-size: 9px; }
.chart-sign .muted { color: #64748b; margin-top: 1px; }
.chart-foot {
    margin: 2px 0 0;
    font-size: 8px;
    color: #64748b;
    text-align: right;
}
@media screen and (max-width: 860px) {
    .chart-print { overflow-x: auto; }
    .chart-page, .chart-sheet {
        width: 210mm;
        min-width: 210mm;
        max-width: 210mm;
    }
    .chart-hint { display: none; }
}
