:root {
    --bg: #f4f6f5;
    --surface: #ffffff;
    --surface-2: #eef2f0;
    --text: #17211d;
    --muted: #5b6b64;
    --border: #d5ddd9;
    --accent: #0b6e4f;
    --accent-text: #ffffff;
    --danger: #b3261e;
    --warn: #8a5a00;
    --ok: #0b6e4f;
    --radius: 10px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #101513;
        --surface: #19211e;
        --surface-2: #222c28;
        --text: #e6ece9;
        --muted: #9fb0a8;
        --border: #33403a;
        --accent: #7fdab5;
        --accent-text: #06241a;
        --danger: #ffb4ab;
        --warn: #f2c26b;
        --ok: #7fdab5;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 1.15rem; }
h2 { font-size: 1.05rem; margin-bottom: 12px; }
h3 { font-size: 0.95rem; margin-bottom: 8px; }
p { margin: 0 0 8px; }

.muted { color: var(--muted); }
.small { font-size: 0.87rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; word-break: break-all; }
.right { text-align: right; }
.hidden { display: none !important; }

/* Zaglavlje i navigacija */
.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 2;
}
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.topbar nav a {
    padding: 6px 10px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
}
.topbar nav a.active { background: var(--surface-2); color: var(--text); }
.topbar .actions { display: flex; gap: 8px; align-items: center; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

/* Obrasci */
label { display: grid; gap: 4px; font-size: 0.87rem; color: var(--muted); }
input, select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    width: 100%;
}
textarea { min-height: 84px; resize: vertical; }
input[type="checkbox"] { width: auto; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.form { display: grid; gap: 12px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 0.95rem; }
.checks { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

button {
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 7px 12px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.link { border: none; background: none; color: var(--accent); padding: 4px 6px; }
button:disabled { opacity: 0.55; cursor: default; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Tablice */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td.wrap { overflow-wrap: anywhere; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--muted);
    white-space: nowrap;
}
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--danger); }

.notice { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.notice.error { color: var(--danger); }
.notice.success { color: var(--ok); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.6rem;
    letter-spacing: 0.12em;
    font-weight: 600;
}

/* Prijava */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { font-size: 1.4rem; margin-bottom: 16px; }

@media (max-width: 640px) {
    main { padding: 10px; }
    .card { padding: 12px; }
    th, td { padding: 7px 6px; }
}
