:root {
    --brand: #1565c0;
    --brand-dark: #0d47a1;
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --border: #dde3ec;
    --text: #222;
    --text-muted: #666;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--brand);
    padding: 0.9rem 1.5rem;
    position: relative;
}

.navbar-brand a {
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
}

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    padding: 0.25rem 0.4rem;
    cursor: pointer;
}

.navbar-links {
    list-style: none;
    display: flex;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.navbar-links a {
    display: block;
    color: #e3f0ff;
    text-decoration: none;
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    font-size: 0.95rem;
}

.navbar-links a:hover {
    background: rgba(255,255,255,0.15);
}

.navbar-links a.active {
    background: #fff;
    color: var(--brand-dark);
    font-weight: 600;
}

@media (max-width: 720px) {
    .navbar-toggle {
        display: block;
    }

    .navbar-links {
        display: none;
        flex-direction: column;
        gap: 0.15rem;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--brand);
        padding: 0.5rem 1rem 1rem;
        box-shadow: 0 6px 10px rgba(0,0,0,0.15);
        z-index: 20;
    }

    .navbar-links.open {
        display: flex;
    }

    .navbar-links a {
        padding: 0.65rem 0.9rem;
    }
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 1.25rem;
}

.site-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0.75rem 0 1rem;
}

h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.page-subtitle { color: var(--text-muted); margin-top: 0; margin-bottom: 1.5rem; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-tile {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
    min-width: 0;
}

.stat-tile .stat-value { font-size: 1.8rem; font-weight: 700; color: var(--brand-dark); word-break: break-word; }
.stat-tile .stat-label { color: var(--text-muted); font-size: 0.85rem; }

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1.5rem;
    padding: 0 1.5rem;
}

.table-responsive table { min-width: 480px; }

@media (max-width: 480px) {
    .container { padding-left: 0.85rem; padding-right: 0.85rem; }
    .card { padding: 1.1rem; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    .stat-tile { padding: 0.9rem; }
    .stat-tile .stat-value { font-size: 1.4rem; }
    .table-responsive { margin: 0 -1.1rem; padding: 0 1.1rem; }
}

form .form-row {
    margin-bottom: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

form label { font-weight: 600; font-size: 0.9rem; }

form input[type="text"],
form input[type="number"],
form select {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    width: 100%;
}

form input:focus, form select:focus {
    outline: none;
    border-color: var(--brand);
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.25rem;
}

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

.btn {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #6c757d; }
.btn.secondary:hover { background: #565e64; }
.btn.danger { background: #b3362b; }
.btn.danger:hover { background: #8f2b22; }
.btn.green { background: #2e7d32; }
.btn.green:hover { background: #1b5e20; }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }

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

th, td {
    text-align: left;
    padding: 0.65rem 0.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}

th { color: var(--text-muted); font-weight: 600; }

.doc-detail-table td:first-child { color: var(--text-muted); width: 40%; }
.doc-detail-table td:last-child { font-weight: 600; }
.doc-detail-table th {
    color: var(--text);
    font-weight: 700;
    border-bottom: 2px solid var(--border);
}

.doc-detail-table.plain td:first-child { color: var(--text); font-weight: 600; }
.doc-detail-table.plain td:last-child { font-weight: 400; }
.doc-detail-table.plain td, .doc-detail-table.plain th { padding: 0.9rem 0.4rem; }

.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.75rem 0;
}

.doc-heading {
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.3;
}

@media (max-width: 480px) {
    .doc-heading { font-size: 1.5rem; }
}

.badge {
    display: inline-block;
    background: #e3f0ff;
    color: var(--brand-dark);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.alert {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-size: 0.92rem;
}

.alert.success { background: #e6f6ea; color: #1e5f34; border: 1px solid #bfe6cb; }
.alert.error { background: #fdecea; color: #8a2b22; border: 1px solid #f6c7c1; }

.qr-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    background: #fff;
}

.qr-box canvas, .qr-box img { image-rendering: pixelated; }

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

.scanner-frame {
    max-width: 420px;
    margin: 0 auto;
}

#reader { border-radius: 10px; overflow: hidden; }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2.5rem 1rem;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 0.5rem;
    padding-left: 0.75rem;
    border-left: 1px solid rgba(255,255,255,0.25);
}

.navbar-device {
    color: #e3f0ff;
    font-size: 0.82rem;
    white-space: nowrap;
}

@media (max-width: 720px) {
    .navbar-user {
        margin-left: 0;
        padding-left: 0.9rem;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.25);
        margin-top: 0.35rem;
        padding-top: 0.6rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }
}

.login-shell {
    min-height: 100vh;
    display: flex;
}

.login-visual {
    flex: 1 1 46%;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 3.5rem;
    color: #fff;
    background: radial-gradient(circle at 15% 15%, rgba(255,255,255,0.14), transparent 45%),
                linear-gradient(155deg, var(--brand-dark) 0%, var(--brand) 60%, #2f8fe0 100%);
    overflow: hidden;
}

.login-visual::before,
.login-visual::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
}

.login-visual::before { width: 320px; height: 320px; top: -120px; right: -100px; }
.login-visual::after { width: 220px; height: 220px; bottom: -80px; left: -60px; background: rgba(255,255,255,0.05); }

.login-visual-inner { position: relative; z-index: 1; max-width: 380px; }

.login-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(255,255,255,0.16);
    margin-bottom: 1.75rem;
}

.login-visual h1 {
    font-size: 1.9rem;
    line-height: 1.25;
    margin: 0 0 0.75rem;
}

.login-visual p {
    color: #dcebfd;
    font-size: 0.98rem;
    line-height: 1.55;
    margin: 0 0 2rem;
}

.login-features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.login-features li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.92rem;
    color: #eaf3ff;
}

.login-features .feature-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.16);
    flex-shrink: 0;
}

.login-panel {
    flex: 1 1 54%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    background: var(--bg);
}

.login-form-card {
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2.25rem 2rem;
    box-shadow: 0 10px 30px rgba(13,71,161,0.08);
}

.login-form-card h2 {
    margin: 0 0 0.3rem;
    font-size: 1.35rem;
}

.login-form-card .page-subtitle { margin-bottom: 1.5rem; }

.field { position: relative; margin-bottom: 1.15rem; }

.field label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.field .field-icon {
    position: absolute;
    left: 0.75rem;
    top: 2.35rem;
    color: var(--text-muted);
    display: flex;
}

.field input {
    width: 100%;
    padding: 0.65rem 0.75rem 0.65rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fbfcfe;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
    background: #fff;
}

.field.has-toggle input { padding-right: 2.5rem; }

.password-toggle {
    position: absolute;
    right: 0.6rem;
    top: 2.3rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    padding: 0.3rem;
}

.password-toggle:hover,
.password-toggle.active { color: var(--brand); }

.login-submit {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    margin-top: 0.35rem;
    transition: background 0.15s ease, transform 0.1s ease;
}

.login-submit:active { transform: translateY(1px); }

.remember-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
}

@media (max-width: 860px) {
    .login-shell { flex-direction: column; }
    .login-visual { flex: none; padding: 2.25rem 1.5rem; text-align: center; }
    .login-visual-inner { max-width: none; }
    .login-mark { margin-left: auto; margin-right: auto; }
    .login-visual h1 { font-size: 1.5rem; }
    .login-features { display: none; }
    .login-panel { padding: 2rem 1.25rem 3rem; }
}
