:root{
    --bg:#0b0f19;
    --panel:#11182a;
    --panel2:#0f1526;
    --text:#e8eefc;
    --muted:#a8b3cf;
    --border:#223055;
    --primary:#5ea1ff;
    --danger:#ff5e6c;
    --ok:#2ee59d;
    --warn:#ffcc66;
}

*{ box-sizing:border-box; }

body{
    margin:0;
    font-family:system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background:var(--bg);
    color:var(--text);
}

.topbar{
    display:flex;
    justify-content:space-between;
    align-items:flex-end;
    padding:18px 22px;
    border-bottom:1px solid var(--border);
    background:linear-gradient(180deg, var(--panel), var(--bg));
}

h1{ margin:0; font-size:1.35rem; }
h2{ margin:0 0 10px 0; font-size:1.15rem; }
.muted{ color:var(--muted); margin:6px 0 0 0; }

.tabs{ display:flex; gap:10px; }
.tab{
    background:transparent;
    border:1px solid var(--border);
    color:var(--text);
    padding:10px 12px;
    border-radius:12px;
    cursor:pointer;
}
.tab.active{
    border-color:var(--primary);
    box-shadow:0 0 0 2px rgba(94,161,255,0.15) inset;
}

.container{max-width:1100px; margin:18px auto; padding:0 18px; position:relative; }

.panel{
    background:var(--panel);
    border:1px solid var(--border);
    border-radius:16px;
    padding:16px;
}

.view-header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    margin-bottom:12px;
}

.actions{ display:flex; gap:12px; align-items:center; justify-content:space-between; flex-wrap:wrap; }

.input{
    background:var(--panel2);
    color:var(--text);
    border:1px solid var(--border);
    border-radius:12px;
    padding:10px 12px;
    outline:none;
    min-width:260px;
}

.btn{
    background:transparent;
    border:1px solid var(--border);
    color:var(--text);
    padding:10px 12px;
    border-radius:12px;
    cursor:pointer;
}
.btn.primary{
    background:var(--primary);
    border-color:var(--primary);
    color:#071021;
    font-weight:600;
}
.btn.danger{
    background: rgba(255,94,108,0.08);   /* soft red shade */
    border-color: rgba(255,94,108,0.45);
    color: var(--danger);
    font-weight: 400;
}
.btn.danger:hover{
    background: rgba(255,94,108,0.15);
    border-color: rgba(255,94,108,0.65);
}

.table{
    width:100%;
    border-collapse:collapse;
    overflow:hidden;
    border-radius:12px;
}
.table th, .table td{
    border-bottom:1px solid var(--border);
    padding:10px 10px;
    vertical-align:top;
}
.table th{ text-align:left; font-size:0.85rem; color:var(--muted); }
.table td.right, .table th.right{ text-align:right; }

/* Pager (updated for page size control) */
.pager{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-top:12px;
    gap:12px;
}

.pager-group{
    display:flex;
    align-items:center;
    gap:10px;
}

.pager-center{
    display:flex;
    justify-content:center;
    flex:1;
    text-align:center;
}

.pager-right{
    justify-content:flex-end;
}

.pageSize{
    display:flex;
    align-items:center;
    gap:10px;
    white-space:nowrap;
}

.pageSizeSelect{
    min-width:90px;
}

.form{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:14px 16px;
}
.field{ display:flex; flex-direction:column; gap:8px; }
.error{ color:var(--danger); min-height:16px; }
.formActions{
    grid-column:1 / -1;
    display:flex;
    justify-content:flex-end;
    gap:10px;
}

.stats{
    display:grid;
    grid-template-columns:1fr 1fr 1fr;
    gap:12px;
}
.stat{
    background:var(--panel2);
    border:1px solid var(--border);
    border-radius:14px;
    padding:12px;
}
.statValue{ font-size:1.35rem; font-weight:700; margin-top:6px; }
.statValue.small{ font-size:0.95rem; font-weight:600; line-height:1.3; }

.modalBackdrop{
    position:fixed;
    inset:0;
    background:rgba(0,0,0,0.55);
    display:flex;
    align-items:center;
    justify-content:center;
    padding:18px;
}
.modal{
    width:100%;
    max-width:420px;
    background:var(--panel);
    border:1px solid var(--border);
    border-radius:16px;
    padding:16px;
}
.modalActions{
    display:flex;
    justify-content:flex-end;
    gap:10px;
    margin-top:12px;
}

.hidden{ display:none !important; }

@media (max-width: 720px){
    .form{ grid-template-columns:1fr; }
    .stats{ grid-template-columns:1fr; }

    .pager{
        flex-wrap:wrap;
    }
    .pager-center{
        order:3;
        flex-basis:100%;
    }
}

/* Toolbar (Search + Filter + Sort) */
.search-group{
    display:flex;
    gap:10px;
    align-items:center;
    flex:1;
    min-width:260px;
    flex-wrap:wrap;
}

.btn.icon{
    display:inline-flex;
    align-items:center;
    gap:8px;
    white-space:nowrap;
}

.icon-svg{
    width:18px;
    height:18px;
    fill:currentColor;
}

.select{
    background:var(--panel2);
    color:var(--text);
    border:1px solid var(--border);
    border-radius:10px;
    padding:10px 12px;
    outline:none;
}

.select.sort{
    min-width:220px; /* wider than filter button */
}

/* Filter popover */
.popover{
    position:absolute;
    right:22px;
    top:140px;
    width:320px;
    max-width:calc(100vw - 44px);
    background:var(--panel);
    border:1px solid var(--border);
    border-radius:14px;
    padding:12px;
    box-shadow:0 18px 40px rgba(0,0,0,0.35);
    z-index:50;
}

.popover-header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:10px;
}

.popover-section{
    padding:10px 0;
    border-top:1px solid var(--border);
}

.popover-section:first-of-type{
    border-top:none;
    padding-top:0;
}

.popover-title{
    font-size:0.9rem;
    color:var(--muted);
    margin-bottom:8px;
}

.check{
    display:flex;
    align-items:center;
    gap:10px;
    padding:6px 0;
    cursor:pointer;
}

.check input{
    width:16px;
    height:16px;
}

.btn.small{
    padding:7px 10px;
    border-radius:10px;
    font-size:0.85rem;
}

.hint{
    margin:6px 0 0 0;
    font-size:0.85rem;
    color:var(--muted);
}

/* Status pills (Progress) */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
}

.pill.ok   { border-color: rgba(46,229,157,0.45); color: var(--ok); }
.pill.warn { border-color: rgba(255,204,102,0.45); color: var(--warn); }

/* Button polish */
.btn:hover{
    border-color: rgba(94,161,255,0.45);
    box-shadow: 0 0 0 2px rgba(94,161,255,0.10) inset;
}

.btn:active{
    transform: translateY(1px);
}

.btn:focus-visible{
    outline: none;
    box-shadow: 0 0 0 3px rgba(94,161,255,0.30);
    border-color: rgba(94,161,255,0.65);
}

.table .btn.small{
    background: rgba(255,255,255,0.02);
}

/* ---------- Images (thumbnail + preview) ---------- */
.thumb{
    width:72px;
    height:72px;
    border-radius:14px;
    overflow:hidden;
    border:1px solid var(--border);
    background:var(--panel2);
    display:flex;
    align-items:center;
    justify-content:center;

    /* polish + intentional crop feeling */
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.thumb-img{
    width:100%;
    height:100%;
    object-fit:cover; /* keep cropped thumbnails */
    display:block;

    transition: transform 180ms ease;
    will-change: transform;
}

.thumb:hover{
    border-color: rgba(94,161,255,0.55);
    box-shadow: 0 10px 26px rgba(0,0,0,0.25);
}

.thumb:hover .thumb-img{
    transform: scale(1.06);
}

.noimg{
    width:100%;
    height:100%;
}

.imagePreview{
    width:100%;
    min-height:120px;
    border:1px solid var(--border);
    border-radius:14px;
    background:var(--panel2);
    display:flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
}

.imagePreview img{
    width:100%;
    height:100%;
    object-fit:cover;
    display:block;
}

.imageActions{
    margin-top:8px;
}