: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 3rem;
}

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

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.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);
}

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

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

.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; }

.link-card {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.link-meta {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.6rem;
}

.link-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #e3f0ff;
    color: var(--brand);
    flex-shrink: 0;
}

.link-type { font-weight: 700; font-size: 0.85rem; }
.link-time { color: var(--text-muted); font-size: 0.78rem; }

.link-url {
    display: block;
    color: var(--brand);
    text-decoration: underline;
    word-break: break-all;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.link-actions {
    display: flex;
    justify-content: space-around;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.link-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.25rem 0.75rem;
}

.link-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #e3f0ff;
    color: var(--brand);
}

.link-action:hover .link-action-icon { background: var(--brand); color: #fff; }

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