:root {
    --bg-surface: #ffffff;
    --bg-page: #f8fafc;
    --border-color: #e2e8f0;
    --indigo: #4f46e5;
    --indigo-dark: #3730a3;
    --indigo-soft: rgba(79, 70, 229, 0.08);
    --teal: #0d9488;
    --text-dark: #1e1b4b;
    --text-muted: #64748b;
}

body {
    font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg-page);
    color: #0f172a;
}

a { color: var(--indigo); }
a:hover { color: var(--indigo-dark); }
.text-indigo { color: var(--indigo) !important; }
.text-teal { color: var(--teal) !important; }
code {
    color: #4338ca;
    background: var(--indigo-soft);
    border-radius: 4px;
    padding: 0.05rem 0.28rem;
    font-size: 0.85em;
}

.navbar-glass {
    background: rgba(255, 255, 255, 0.86);
    border-bottom: 1px solid rgba(226, 232, 240, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
.navbar-brand {
    color: var(--text-dark) !important;
    letter-spacing: -0.02em;
    font-size: 1.2rem;
}
.service-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.32rem 0.7rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #0f766e;
    background: rgba(13, 148, 136, 0.09);
    border: 1px solid rgba(13, 148, 136, 0.18);
}
.service-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #14b8a6;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.14);
}

.scanner-page { --dmc-accent: var(--indigo); }
.hero-scanner {
    padding: 3rem 0 2rem;
    background: radial-gradient(100% 100% at 50% 0%, rgba(99, 102, 241, 0.07) 0%, rgba(255, 255, 255, 0) 100%);
}
.hero-scanner h1 {
    line-height: 1.16;
    letter-spacing: -0.025em;
}
.hero-scanner .lead {
    max-width: 760px;
    font-size: 1.02rem;
    line-height: 1.65;
}

.app-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.01);
    padding: 1.5rem 1.6rem;
}
.result-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
}

.upload-zone { position: relative; margin-bottom: 1rem; }
.upload-zone-inner {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1.5px dashed #c7d2fe;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.04) 0%, rgba(248, 250, 252, 0.9) 100%);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.upload-zone-inner:hover,
.upload-zone-inner.dragover {
    border-color: #818cf8;
    background: rgba(99, 102, 241, 0.07);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
}
.upload-zone-head {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.upload-zone-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.12);
    color: var(--indigo);
    font-size: 1.2rem;
}
.upload-zone-title {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-dark);
}
.upload-zone-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}
.upload-zone-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.upload-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    font-weight: 600;
    font-size: 0.88rem;
    border-radius: 10px;
    padding: 0.62rem 0.9rem;
    cursor: pointer;
    line-height: 1.2;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.upload-action-btn i { font-size: 1.05rem; line-height: 1; }
.upload-action-btn-file {
    color: #4338ca !important;
    background: #fff;
    border: 1px solid #c7d2fe;
}
.upload-action-btn-file:hover,
.upload-action-btn-file:focus {
    color: #fff !important;
    background: var(--indigo);
    border-color: var(--indigo);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.22);
}
.upload-action-btn-clear {
    color: #475569 !important;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.upload-action-btn-clear:hover:not(:disabled),
.upload-action-btn-clear:focus:not(:disabled) {
    color: #b91c1c !important;
    background: #fef2f2;
    border-color: #fecaca;
}
.upload-action-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.file-input-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.file-hint {
    overflow-wrap: anywhere;
}
.source-note {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #eef2f7;
    color: #475569;
    font-size: 0.78rem;
}
.source-note i { width: 1.1rem; display: inline-block; }
.source-note code { font-size: 0.76rem; white-space: nowrap; }

.btn-scan {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border: 1px solid rgba(99, 102, 241, 0.5);
    color: #fff;
    font-weight: 700;
    border-radius: 10px;
    padding: 0.7rem 1.1rem;
}
.btn-scan:hover:not(:disabled),
.btn-scan:focus:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
    border-color: var(--indigo-dark);
    color: #fff;
}
.btn-scan:disabled { opacity: 0.55; }
.status-msg {
    font-size: 0.88rem;
    min-height: 1.4em;
    line-height: 1.45;
}
.status-msg.ok { color: #107c10; }
.status-msg.err { color: #c42b1c; }

.result-panel {
    position: relative;
    min-height: 26rem;
    scroll-margin-top: 5.5rem;
}
.result-placeholder {
    color: #94a3b8;
    text-align: center;
    padding: 5rem 1rem;
    font-size: 0.9rem;
}
.result-placeholder i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.55rem;
    color: #a5b4fc;
}
.result-body { display: none; }
.result-panel.has-result .result-placeholder { display: none; }
.result-panel.has-result .result-body { display: block; }
.result-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.75rem;
    background: rgba(248, 250, 252, 0.94);
    backdrop-filter: blur(4px);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
}
.result-loading-overlay.show { display: flex; }
.result-loading-overlay .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
    border-width: 0.28em;
    color: var(--indigo);
}
.loading-title { color: var(--text-dark); }

.result-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}
.result-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.btn-csv {
    color: #fff;
    background: #0f766e;
    border: 1px solid #0f766e;
    border-radius: 999px;
    font-weight: 600;
}
.btn-csv:hover:not(:disabled),
.btn-csv:focus:not(:disabled) {
    color: #fff;
    background: #115e59;
    border-color: #115e59;
}
.btn-csv:disabled { opacity: 0.5; }

.codes-list { margin-bottom: 0.25rem; }
.code-item {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.65rem;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.code-item:hover {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}
.code-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}
.code-badges {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.fmt-badge {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: rgba(99, 102, 241, 0.1);
    color: #4338ca;
    border-radius: 6px;
    padding: 0.16rem 0.45rem;
}
.fmt-badge.page-badge {
    background: rgba(13, 148, 136, 0.1);
    color: #0f766e;
}
.fmt-badge.raw-badge {
    background: #f1f5f9;
    color: #475569;
}
.code-text {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
    word-break: break-all;
    color: #0f172a;
    line-height: 1.5;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
    padding: 0.55rem 0.65rem;
}
.parsed-rows {
    display: grid;
    gap: 0.2rem;
    font-size: 0.8rem;
    color: #475569;
    margin-top: 0.55rem;
}
.parsed-rows div {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}
.parsed-rows span {
    color: var(--text-muted);
    min-width: 5.2rem;
    flex-shrink: 0;
}
.parsed-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
    color: #0f172a;
}
.btn-copy-inline {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    padding: 0.1rem 0.35rem;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-copy-inline:hover { color: var(--indigo); background: var(--indigo-soft); }

.export-box {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-top: 0.5rem;
}
.export-box textarea {
    width: 100%;
    border: 0;
    background: transparent;
    resize: vertical;
    min-height: 6rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    color: #0f172a;
    outline: none;
}
.csv-note {
    border-top: 1px solid #e2e8f0;
    padding-top: 0.55rem;
    margin-top: 0.4rem;
    color: var(--text-muted);
    font-size: 0.74rem;
    line-height: 1.5;
}
.csv-note code { font-size: 0.72rem; }

.error-box {
    display: none;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.86rem;
}
.error-box.show { display: block; }

.scanner-info { background: linear-gradient(180deg, transparent 0%, rgba(99, 102, 241, 0.03) 100%); }
.info-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.15rem 1.2rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.02);
}
.info-card p { line-height: 1.6; }
.site-footer {
    background: #fff;
    border-top: 1px solid var(--border-color);
}
.site-footer a { text-decoration: none; }

@media (max-width: 991.98px) {
    .hero-scanner { padding-top: 2rem; }
    .app-container { padding: 1.25rem; }
    .result-panel { min-height: 20rem; }
}
@media (max-width: 575.98px) {
    .hero-scanner h1 { font-size: 2rem; }
    .result-toolbar { align-items: flex-start; }
    .result-actions { width: 100%; }
    .result-actions .btn { flex: 1 1 auto; }
    .parsed-rows div { flex-direction: column; gap: 0.05rem; }
    .parsed-rows span { min-width: 0; }
}
