:root {
    --bg: #f5f6f8;
    --card: #fff;
    --text: #1d2330;
    --muted: #677085;
    --border: #dfe2e8;
    --primary: #1f5fbf;
    --primary-dark: #174a96;
    --danger: #b3261e;
    --radius: 10px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
a { color: var(--primary); }
main { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }

.topbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1.5rem;
    padding: .75rem 1.25rem; background: #fff; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; }
.topbar nav a { text-decoration: none; color: var(--text); }
.topbar nav a:hover { color: var(--primary); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .9rem; }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, monospace; font-size: .8rem; word-break: break-all; }
.pre-line { white-space: pre-line; }

label { display: block; margin-bottom: .9rem; font-weight: 500; }
label.check { display: flex; align-items: center; gap: .35rem; margin: 0; font-weight: 400; white-space: nowrap; }
input[type=text], input[type=email], input[type=password], input[type=search], select {
    display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem;
    border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff;
}
button, .button {
    display: inline-block; padding: .5rem .95rem; border: 1px solid var(--border); border-radius: 8px;
    background: #fff; color: var(--text); font: inherit; cursor: pointer; text-decoration: none;
}
button:hover, .button:hover { border-color: var(--primary); }
.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-dark); }
.danger { color: var(--danger); border-color: #e7b7b4; }
button.link { border: 0; background: none; padding: 0; color: var(--text); }
button.link:hover { color: var(--primary); }
form.inline { display: inline-flex; gap: .35rem; align-items: center; margin: 0; }
form.inline input { margin: 0; width: auto; }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: .75rem; border: 1px solid; }
.flash-success { background: #eaf6ec; border-color: #b6dfbd; }
.flash-error { background: #fdecea; border-color: #f2b8b5; }
.flash-info { background: #eaf1fb; border-color: #b9cff0; }

.search { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.search input[type=search] { flex: 1 1 320px; margin: 0; }
.search select { width: auto; margin: 0; }

.doc-list { list-style: none; padding: 0; margin: 0; }
.doc-list .card { padding: .9rem 1.1rem; margin-bottom: .6rem; }
.doc-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.doc-title { font-weight: 600; font-size: 1.05rem; text-decoration: none; }
.doc-meta { color: var(--muted); font-size: .85rem; }
.snippet { margin: .4rem 0 0; font-size: .9rem; }
mark { background: #fff2a8; padding: 0 .1em; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; background: #eef0f4; white-space: nowrap; }
.status-done, .result-imported { background: #e3f3e6; color: #1e6b2c; }
.status-pending, .status-processing, .result-skipped, .result-no_attachments { background: #fff4d6; color: #7a5600; }
.status-error, .result-error, .result-rejected { background: #fdecea; color: var(--danger); }

.pagination { display: flex; justify-content: center; gap: 1.25rem; padding: 1rem; }

.detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 960px) { .detail { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); } }
.title-form { display: flex; gap: .5rem; margin-bottom: 1rem; }
.title-form input { margin: 0; font-size: 1.15rem; font-weight: 600; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.content-text pre { white-space: pre-wrap; max-height: 420px; overflow: auto; background: #f8f9fb; padding: .75rem; border-radius: 8px; font-size: .85rem; }
.preview iframe { width: 100%; height: 80vh; border: 0; }
.preview img { max-width: 100%; height: auto; }

.dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
    padding: 2.5rem 1rem; border: 2px dashed var(--border); border-radius: var(--radius);
    text-align: center; color: var(--muted); cursor: pointer; font-weight: 400;
}
.dropzone.drag { border-color: var(--primary); background: #f0f5fd; }
.dropzone input { max-width: 100%; }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; }
.table tr.inactive td { color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.card:has(> .table) { overflow-x: auto; }
