:root {
    --bg: #0c0d0e;
    --panel: #16181a;
    --panel-2: #1d2023;
    --line: #2a2e32;
    --ink: #e8e6e1;
    --muted: #8b8f93;
    --accent: #ffb000;
    --accent-dim: #b87f00;
    --ok: #6fcf5f;
    --err: #ff5d5d;
    --info: #5fb0e0;
    --mono: "JetBrains Mono", ui-monospace, monospace;
    --sans: "Hanken Grotesk", system-ui, sans-serif;

    /* Theme-dependent (dark defaults — overridovani u [data-theme="light"]) */
    --primary-text: #1a1300;
    --primary-hover: #ffc233;
    --log-bg: #0a0b0c;
    --log-placeholder-clr: #4a4e52;
    --input-ph: #5a5e62;
    --modal-overlay: rgba(0, 0, 0, 0.65);
    --modal-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    --pill-done-border: #2f6b25;
    --pill-err-border: #6b2525;
    --grain-opacity: 0.025;
    --grid-accent: rgba(255, 176, 0, 0.035);
}

/* ─── Light theme ───────────────────────────────────────────────────────────── */

[data-theme="light"] {
    --bg: #f5f3ef;
    --panel: #ffffff;
    --panel-2: #f0eeea;
    --line: #d4d0c8;
    --ink: #1a1815;
    --muted: #6b6560;
    --accent: #e08e00;
    --accent-dim: #b07000;
    --ok: #2d8a1e;
    --err: #d42020;
    --info: #2878a8;

    --primary-text: #ffffff;
    --primary-hover: #f0a500;
    --log-bg: #f4f2ee;
    --log-placeholder-clr: #a09890;
    --input-ph: #99938c;
    --modal-overlay: rgba(0, 0, 0, 0.3);
    --modal-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
    --pill-done-border: #c8e6c0;
    --pill-err-border: #f5c6c6;
    --grain-opacity: 0.015;
    --grid-accent: rgba(224, 142, 0, 0.06);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
}

/* subtle grid + grain atmosphere */
body {
    background-image:
        linear-gradient(
            transparent 95%,
            var(--grid-accent, rgba(255, 176, 0, 0.035)) 100%
        ),
        linear-gradient(
            90deg,
            transparent 95%,
            var(--grid-accent, rgba(255, 176, 0, 0.035)) 100%
        );
    background-size: 28px 28px;
    min-height: 100vh;
}

.grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: var(--grain-opacity, 0.025);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hidden {
    display: none !important;
}

/* ─── Topbar ─── */
.topbar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}
.brand-mark {
    color: var(--accent);
    font-family: var(--mono);
    letter-spacing: -2px;
}
.brand-name {
    font-family: var(--mono);
    font-weight: 700;
    letter-spacing: -0.5px;
}
.brand-sub {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* ─── Theme toggle ─── */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--muted);
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
    transition:
        border-color 0.15s,
        color 0.15s;
}
.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--ink);
}
.theme-toggle .icon-sun {
    display: none;
}
.theme-toggle .icon-moon {
    display: inline;
}
[data-theme="light"] .theme-toggle .icon-sun {
    display: inline;
}
[data-theme="light"] .theme-toggle .icon-moon {
    display: none;
}

/* ─── Views ─── */
.view {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 28px 20px 64px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ─── Cards ─── */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 22px;
    animation: rise 0.4s ease both;
}
.card + .card {
    animation-delay: 0.06s;
}
@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.card-title {
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 4px;
    letter-spacing: -0.3px;
}
.muted {
    color: var(--muted);
    font-size: 13px;
    margin: 4px 0 16px;
}
.hint {
    color: var(--muted);
    font-size: 12px;
    font-family: var(--mono);
    margin: 6px 0 0;
    word-break: break-all;
}

.login-card {
    max-width: 380px;
    margin: 8vh auto 0;
}

/* ─── Inputs ─── */
.field-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin: 16px 0 6px;
}
input,
select {
    width: 100%;
    padding: 11px 13px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--ink);
    font-family: var(--mono);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
input:focus,
select:focus {
    border-color: var(--accent);
}
input::placeholder {
    color: var(--input-ph, #5a5e62);
}

/* ─── Password wrapper with toggle ─── */
.password-wrapper {
    position: relative;
    width: 100%;
}
.password-wrapper input {
    padding-right: 48px; /* space for toggle button */
}
.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.password-toggle:hover {
    color: var(--accent);
    background: var(--panel-2);
}
.password-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent);
}
.password-toggle .eye-open {
    display: none;
}
.password-toggle[aria-label="Sakrij šifru"] .eye-open {
    display: inline;
}
.password-toggle[aria-label="Sakrij šifru"] .eye-closed {
    display: none;
}

.select-wrap {
    display: flex;
    gap: 8px;
}
.select-wrap select {
    flex: 1;
}

/* ─── Buttons ─── */
.primary-btn {
    width: 100%;
    margin-top: 18px;
    padding: 12px;
    background: var(--accent);
    color: var(--primary-text, #1a1300);
    border: none;
    border-radius: 5px;
    font-family: var(--mono);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition:
        transform 0.08s,
        background 0.15s;
}
.primary-btn:hover {
    background: var(--primary-hover, #ffc233);
}
.primary-btn:active {
    transform: translateY(1px);
}
.primary-btn:disabled {
    background: var(--accent-dim);
    cursor: not-allowed;
    opacity: 0.7;
}

.ghost-btn {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    border-radius: 5px;
    padding: 8px 14px;
    cursor: pointer;
    font-family: var(--mono);
    font-size: 13px;
    transition:
        border-color 0.15s,
        color 0.15s;
}
.ghost-btn:hover {
    border-color: var(--accent);
    color: var(--ink);
}
.ghost-btn.small {
    padding: 0 12px;
    min-width: 42px;
    font-size: 24px;
}
.ghost-btn.danger {
    border-color: var(--err);
    color: var(--err);
}
.ghost-btn.danger:hover {
    background: var(--err);
    color: #fff;
}

/* ─── Status pill ─── */
.log-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.status-pill {
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
}
.status-pill.idle {
    color: var(--muted);
}
.status-pill.running {
    color: var(--accent);
    border-color: var(--accent-dim);
    animation: pulse 1.2s infinite;
}
.status-pill.done {
    color: var(--ok);
    border-color: var(--pill-done-border, #2f6b25);
}
.status-pill.error {
    color: var(--err);
    border-color: var(--pill-err-border, #6b2525);
}
@keyframes pulse {
    50% {
        opacity: 0.45;
    }
}

/* ─── Log output ─── */
.log-output {
    background: var(--log-bg, #0a0b0c);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 14px;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.7;
    max-height: 340px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.log-placeholder {
    color: var(--log-placeholder-clr, #4a4e52);
}
.log-line {
    display: block;
}
.log-line .tag {
    color: var(--muted);
}
.log-line.ok .tag {
    color: var(--ok);
}
.log-line.error {
    color: var(--err);
}
.log-line.start .tag,
.log-line.progress .tag {
    color: var(--info);
}
.log-line.done {
    color: var(--ok);
    font-weight: 700;
}

/* ─── Audit ─── */
.audit-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.audit-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 5px;
    font-size: 13px;
}
.audit-row .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.audit-row .dot.done {
    background: var(--ok);
}
.audit-row .dot.error {
    background: var(--err);
}
.audit-row .a-main {
    flex: 1;
    min-width: 0;
}
.audit-row .a-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.audit-row .a-meta {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
}
.audit-empty {
    color: var(--muted);
    font-size: 13px;
}

.error-text {
    color: var(--err);
    font-size: 13px;
    margin: 12px 0 0;
}

/* ─── Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--modal-overlay, rgba(0, 0, 0, 0.65));
    backdrop-filter: blur(3px);
    animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden {
    display: none;
}
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 26px 28px 22px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--modal-shadow, 0 20px 60px rgba(0, 0, 0, 0.5));
    animation: modalSlide 0.25s ease;
}
.modal-card.small {
    max-width: 380px;
}
@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s;
}
.modal-close:hover {
    color: var(--ink);
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 16px 0 0;
    font-size: 13px;
    cursor: pointer;
    color: var(--muted);
    line-height: 1.4;
}
.checkbox-label input[type="checkbox"] {
    width: auto;
    margin-top: 3px;
    accent-color: var(--accent);
    flex-shrink: 0;
}
.checkbox-label span {
    user-select: none;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}
.modal-actions .primary-btn {
    width: auto;
    margin-top: 0;
    padding: 10px 24px;
}

/* ─── Article list (delete modal) ─── */
.article-scroll {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 5px;
    margin-top: 8px;
}
.article-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 13px;
    transition: background 0.1s;
}
.article-item:last-child {
    border-bottom: none;
}
.article-item:hover {
    background: var(--panel-2);
}
.article-item .art-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.article-item .art-count {
    color: var(--muted);
    font-size: 11px;
    flex-shrink: 0;
}
.article-item .art-input {
    width: auto;
    flex-shrink: 0;
    accent-color: var(--accent);
}
.article-item .art-del-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}
.article-item .art-del-btn:hover {
    color: var(--err);
}
.article-empty {
    padding: 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    font-family: var(--mono);
}

.select-all-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    font-family: var(--mono);
}
.select-all-row input[type="checkbox"] {
    width: auto;
    accent-color: var(--accent);
}

@media (max-width: 560px) {
    .brand-sub {
        display: none;
    }
    .view {
        padding: 18px 14px 48px;
    }
    .card {
        padding: 18px;
    }
}
