:root {
    --bg:        #2C363F;
    --bg-soft:   #1E1E1E;
    --surface:   #ffffff;
    --text:      #2C363F;
    --muted:     #6b7280;
    --border:    #e5e7eb;
    --primary:   #C9AC54;
    --primary-d: #b89a45;
    --accent-blue: #03A9F4;
    --accent-teal: #00BF87;
    --accent-orange: #F79007;
    --accent-purple: #6632FF;
    --success:   #00BF87;
    --warning:   #F79007;
    --error:     #dc2626;
    --code-bg:   #f8f8f8;
    --radius:    8px;
    --shadow:    0 1px 3px rgba(44,54,63,.08), 0 4px 16px rgba(44,54,63,.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Open Sans', Helvetica, Arial, sans-serif;
    color: var(--text);
    background: #f8f8f8;
    line-height: 1.6;
}

/* ----- Topbar ----- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: .8rem 1.5rem;
    background: var(--bg);
    color: white;
    box-shadow: 0 2px 8px rgba(44,54,63,.15);
}
.topbar .brand { font-size: 1.15rem; font-weight: 600; letter-spacing: .04em; color: var(--primary); display: flex; align-items: center; gap: .5rem; }
.topbar-logo { height: 28px; filter: brightness(0) invert(1); position: relative; top: 3px; }
.topbar-title { font-size: 1.05rem; font-weight: 300; opacity: .85; letter-spacing: .02em; }
.version-bar { text-align: center; font-size: .6rem; color: rgba(255,255,255,.45); background: var(--primary); padding: 0 1.5rem .4rem; margin-top: -0.3rem; letter-spacing: .03em; }
.topbar nav { display: flex; align-items: center; gap: .5rem; }
.topbar nav a, .topbar-icon {
    color: rgba(255,255,255,.7); text-decoration: none;
    background: none; border: none; cursor: pointer; font: inherit;
    padding: 4px; border-radius: 6px; display: inline-flex; align-items: center;
    transition: color .15s, background .15s;
}
.topbar nav a:hover, .topbar-icon:hover { color: white; background: rgba(255,255,255,.12); }

/* ----- Layout ----- */
.container { max-width: 1600px; margin: 2rem auto; padding: 0 1.5rem; }
h1 { font-size: 1.75rem; margin: 0 0 .25rem; }
h2 { margin-top: 0; }
.subtitle { color: var(--muted); margin-top: 0; }
.hint { color: var(--muted); font-size: .9rem; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* ----- Card ----- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

/* ----- Form ----- */
.form { display: grid; gap: 1rem; max-width: 600px; }
label { display: grid; gap: .35rem; font-weight: 600; font-size: .95rem; }
input[type=text], input[type=password], input[type=file], select {
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: white;
}
select { font-size: 1.05rem; }
button, .button {
    padding: .6rem 1.1rem;
    background: var(--primary); color: white; border: 2px solid var(--primary); border-radius: 6px;
    cursor: pointer; font: inherit; font-weight: 600;
    text-decoration: none; display: inline-block; transition: background .2s, border-color .2s;
}
button:hover, .button:hover { background: var(--bg); border-color: var(--bg); color: white; }
button:disabled { opacity: .4; cursor: not-allowed; }
button:disabled:hover { background: var(--primary); border-color: var(--primary); }

/* ----- Alerts ----- */
.alert {
    padding: .75rem 1rem; border-radius: 8px; margin: 1rem 0;
    border: 1px solid transparent;
}
.alert-success { background: #f0fdf4; color: #14532d; border-color: #bbf7d0; }
.alert-warning { background: #fffbeb; color: #78350f; border-color: #fde68a; }
.alert-error   { background: #fef2f2; color: #7f1d1d; border-color: #fecaca; }
.alert-info    { background: #eff6ff; color: #1e3a8a; border-color: #bfdbfe; }

/* ----- Badges ----- */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 99px;
    font-size: .8rem; font-weight: 600;
}
.badge-ok    { background: #dcfce7; color: #14532d; }
.badge-warn  { background: #fef3c7; color: #78350f; }
.badge-error { background: #fee2e2; color: #7f1d1d; }
.badge-count { background: var(--accent-blue); color: white; margin-left: .35rem; }

/* ----- Detail cards ----- */
.detail {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .75rem 1rem 1rem;
    margin-bottom: 1rem;
    background: #fafbfc;
}
.detail-head {
    display: flex; align-items: center; gap: .75rem;
    margin-bottom: .5rem;
}
.detail-no   { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: .9rem; }
.detail-type { font-weight: 700; font-size: 1.05rem; }
/* ----- Detail two-column key/value ----- */
.detail-kv {
    display: grid; grid-template-columns: 12rem 1fr 12rem 1fr; gap: .25rem 1rem;
    margin: 0 0 .5rem;
}
.detail-kv dt { color: var(--muted); font-weight: 600; font-size: .9rem; word-break: break-word; }
.detail-kv dd { margin: 0; word-break: break-word; font-size: .9rem; }
.detail-kv dd:has(.detail-nested) { grid-column: 2 / -1; }
.detail-nested { font-size: .8rem; max-height: 200px; margin: 0; padding: .5rem; }
/* ----- Detail sub-tabs (Fields / JSON) ----- */
.detail-subtabs { display: flex; gap: 4px; margin-bottom: .5rem; }
.detail-subtab {
    padding: .3rem .75rem; font-size: .8rem; font-weight: 600;
    border: 1px solid var(--border); border-radius: 5px;
    background: var(--code-bg); color: var(--muted);
    cursor: pointer; transition: background .15s, color .15s;
}
.detail-subtab.active { background: var(--accent-blue); color: white; border-color: var(--accent-blue); }
.detail-json { max-height: 420px; }
.detail-errors { margin-top: .5rem; }
.detail-errors pre { white-space: pre-wrap; margin: .25rem 0 0; font-size: .85rem; }

/* ----- Key/Value list ----- */
.kv { display: grid; grid-template-columns: 10rem 1fr 10rem 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }
.hash-truncate { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8em; cursor: help; }

/* ----- Tabs ----- */
.tabs { position: relative; }
.tabs input[type=radio] { display: none; }
.tabs label {
    display: inline-block; padding: .55rem 1rem; cursor: pointer;
    border: 1px solid var(--border); border-bottom: none;
    border-top-left-radius: 6px; border-top-right-radius: 6px;
    background: #f8fafc; margin-right: 4px; font-weight: 600;
}
.tabs input:checked + label { background: white; border-bottom: 1px solid white; position: relative; top: 1px; color: var(--primary); }
.tabs .tab-content { display: none; border: 1px solid var(--border); padding: 1.25rem; background: white; border-radius: 0 8px 8px 8px; }
.tabs #tab-pdf:checked      ~ #content-pdf,
.tabs #tab-summary:checked  ~ #content-summary,
.tabs #tab-analysis:checked ~ #content-analysis,
.tabs #tab-details:checked  ~ #content-details,
.tabs #tab-jsonld:checked   ~ #content-jsonld,
.tabs #tab-turtle:checked   ~ #content-turtle,
.tabs #tab-fulljson:checked ~ #content-fulljson,
.tabs #tab-meta:checked     ~ #content-meta { display: block; }

/* ----- PDF viewer ----- */
.pdf-viewer { width: 100%; height: 80vh; border: none; border-radius: 6px; }

/* ----- JSON Syntax Highlighting ----- */
.json-hl .json-key { color: #6632FF; }
.json-hl .json-string { color: #00BF87; }
.json-hl .json-number { color: #F79007; }
.json-hl .json-bool { color: #03A9F4; font-weight: 600; }
.json-hl .json-null { color: #6b7280; font-style: italic; }
.json-hl .json-brace { color: #2C363F; }

/* ----- Code / Markdown ----- */
.code {
    background: var(--code-bg); padding: 1rem; border-radius: 6px;
    overflow: auto; font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: .85rem; max-height: 600px;
}
.markdown h1, .markdown h2, .markdown h3 { margin-top: 1.2em; }
.markdown table { border-collapse: collapse; width: 100%; }
.markdown table th, .markdown table td { border: 1px solid var(--border); padding: .4rem .6rem; }
.markdown code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.markdown blockquote { border-left: 3px solid var(--border); padding-left: 1rem; color: var(--muted); }

/* ----- Table ----- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid var(--border); padding: .5rem .75rem; text-align: left; vertical-align: top; }
.muted { color: var(--muted); }
.dec { font-size: .8em; color: var(--muted); }
.text-danger { color: var(--error) !important; }

/* ----- Footer ----- */
.footer { text-align: center; color: var(--muted); padding: 2rem 1rem; font-size: .9rem; }
.build-info { font-size: .75rem; color: var(--muted); opacity: .6; margin-top: .3rem; }

/* ----- Login ----- */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #2C363F, #1E1E1E);
}
.login-card {
    background: white; padding: 2.5rem 2.5rem 1.5rem; width: min(600px, 92vw);
    border-radius: var(--radius); box-shadow: 0 12px 40px rgba(44,54,63,.3);
    border-top: 4px solid var(--primary); text-align: center;
}
.login-logo { max-width: 220px; margin-bottom: 1rem; }
.login-card h1 { margin: 0; font-size: 1.6rem; }
.login-card form { display: grid; gap: 1rem; margin-top: 1.25rem; text-align: left; }
.login-contact {
    margin-top: 1.5rem; padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    font-size: .9rem; line-height: 1.8;
}
.login-contact p {
    margin: 0 0 .25rem; font-weight: 600; font-size: .85rem;
    text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.login-contact a {
    color: var(--primary-d); text-decoration: none;
}
.login-contact a:hover { text-decoration: underline; }
.login-card footer { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 1.5rem; }

/* ----- Doc type select with counts ----- */
option.has-docs { font-weight: 700; background: #eff6ff; }

/* ----- Loading overlay ----- */
.loading-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(15,23,42,.6); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
}
.loading-card {
    background: white; border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(15,23,42,.3);
    padding: 2.5rem 3rem; text-align: center;
}
.loading-card p { margin: .5rem 0 0; }
.progress-bar-wrap {
    width: 100%; height: 6px; background: var(--border); border-radius: 3px;
    margin-top: .75rem; overflow: hidden;
}
.progress-bar {
    width: 100%; height: 100%; background: var(--primary); border-radius: 3px;
    transition: width 20s linear;
}
.spinner {
    width: 48px; height: 48px; margin: 0 auto 1rem;
    border: 4px solid var(--border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Table of contents ----- */
.toc { padding: 1rem 1.5rem; }
.toc-list { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.toc-item {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .4rem .8rem; border: 1px solid var(--border); border-radius: 6px;
    text-decoration: none; color: var(--text); font-size: .9rem;
    transition: background .15s, border-color .15s;
}
.toc-item:hover { background: rgba(201,172,84,.1); border-color: var(--primary); }

/* ----- Chart ----- */
.chart-wrap { margin-bottom: 1rem; padding: .5rem 0; height: 250px; position: relative; }

/* ----- Upload form layout ----- */
.upload-form { display: flex; flex-direction: column; gap: 1rem; max-width: none; }
.upload-row {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem;
}
.upload-row label { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; }

/* ----- Dropzone ----- */
.dropzone {
    border: 2px dashed var(--border); border-radius: 10px;
    padding: 2rem 1.5rem; text-align: center; cursor: pointer;
    transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone-active {
    border-color: var(--primary); background: rgba(201,172,84,.06);
}
.dropzone p { margin: .25rem 0; }
.file-list { text-align: left; margin-top: .75rem; }
.file-item { padding: .25rem 0; font-size: .9rem; }

/* ----- Small button ----- */
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-danger { background: var(--error); }
.btn-danger:hover { background: #b91c1c; }

/* ----- Icon buttons ----- */
.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 6px; border: none;
    background: var(--code-bg); color: var(--muted); cursor: pointer;
    text-decoration: none; padding: 0; transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--accent-blue); color: white; }
.btn-icon .material-symbols-outlined { font-size: 20px; }
.btn-icon-danger:hover { background: var(--error); color: white; }
.btn-copy { float: right; margin-bottom: .5rem; background: var(--muted); }
.btn-copy:hover { background: #475569; }
.btn-copy-icon { float: right; margin-bottom: .5rem; }

/* ----- Recent records table ----- */
.recent-table td, .recent-table th { font-size: .9rem; padding: .4rem .6rem; }
.recent-table a { color: var(--primary); text-decoration: none; }
.recent-table a:hover { text-decoration: underline; }

/* ----- Modal ----- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(15,23,42,.5); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
}
.modal-card {
    background: white; border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(15,23,42,.3);
    width: min(900px, 92vw); max-height: 85vh;
    display: flex; flex-direction: column;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
    font-size: 1.1rem;
}
.modal-header button { font-size: 1.5rem; line-height: 1; padding: 0 .25rem; }
.modal-card .code { margin: 0; border-radius: 0 0 var(--radius) var(--radius); flex: 1; }

/* ----- Form grid (two-column) ----- */
.form-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1.5rem;
}
.form-grid label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
.form-grid .full-width { grid-column: 1 / -1; }
.form-grid input, .form-grid textarea, .form-grid select {
    padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 6px;
    font: inherit; background: white;
}
.form-grid textarea { resize: vertical; }

/* ----- VSME area badges ----- */
.vsme-badge {
    display: inline-block; padding: 2px 10px; border-radius: 5px;
    font-size: .85rem; font-weight: 700; color: white; margin-right: .4rem;
}
.vsme-b3 { background: #f59e0b; }
.vsme-b6 { background: #3b82f6; }
.vsme-b7 { background: #10b981; }
