/* ==========================================================================
   UVI Boards - shared design system (matches uvi.gg look & feel)
   ========================================================================== */

:root {
    --ink: #1d1d1f;
    --ink-2: #424245;
    --muted: #6e6e73;
    --faint: #86868b;
    --line: #e8e8ed;
    --line-strong: #d2d2d7;
    --surface: #f5f5f7;
    --card: #ffffff;

    --brand: #0071e3;
    --brand-hover: #0077ed;
    --brand-dark: #0060c0;
    --brand-soft: #eaf4fe;

    --success: #008138;
    --success-soft: #e8f8ee;
    --danger: #d70015;
    --danger-soft: #fff0f1;
    --warn: #b75000;
    --warn-soft: #fff5e6;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --pill: 999px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);

    --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--surface);
    color: var(--ink);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }
img { max-width: 100%; }

::selection { background: var(--brand-soft); }

/* ---------- Top navigation ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.topbar-inner {
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.brand img { height: 22px; width: auto; }
.brand span { color: var(--muted); font-weight: 500; }

.nav {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}

.nav::-webkit-scrollbar { display: none; }

.nav a,
.nav-actions a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--pill);
    color: var(--ink-2);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.nav a:hover,
.nav-actions a:hover { background: rgba(0, 0, 0, 0.05); color: var(--ink); }

.nav a.active { background: var(--ink); color: #fff; }

.nav-actions { display: flex; gap: 4px; flex-shrink: 0; }
.nav-actions a.logout:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Layout ---------- */

.container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.container.narrow { max-width: 1100px; }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-head h1 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-head p { color: var(--muted); margin-top: 4px; }

.grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

@media (max-width: 1000px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Cards ---------- */

.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 28px;
    margin-bottom: 24px;
}

.card h2 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.card-sub {
    color: var(--muted);
    font-size: 0.9rem;
    margin: -10px 0 18px;
}

.divider {
    border: none;
    border-top: 1px solid var(--line);
    margin: 24px 0;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--pill);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.25); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }

.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #000; }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--line); }

.btn-info { background: var(--brand-soft); color: var(--brand-dark); }
.btn-info:hover:not(:disabled) { background: #d6eafc; }

.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-ghost { background: transparent; color: var(--brand); padding-left: 10px; padding-right: 10px; }
.btn-ghost:hover:not(:disabled) { background: var(--brand-soft); }

.btn-sm { padding: 6px 14px; font-size: 0.84rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */

.form-row {
    display: flex;
    gap: 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 110px;
    gap: 6px;
}

.form-group.w-xs { flex: 0 0 90px; min-width: 90px; }
.form-group.w-sm { flex: 0 0 130px; min-width: 110px; }
.form-group.w-md { flex: 0 0 200px; }
.form-group.grow-2 { flex: 2; }

label,
.form-group label,
.label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea { resize: vertical; min-height: 90px; line-height: 1.5; }

input::placeholder,
textarea::placeholder { color: #aeaeb2; }

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 43px;
}

.checkbox-group label { font-size: 0.92rem; color: var(--ink); cursor: pointer; }

.form-actions { display: flex; gap: 10px; align-items: center; }

.hint { color: var(--faint); font-size: 0.82rem; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.data-table th {
    font-weight: 500;
    color: var(--faint);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom-color: var(--line-strong);
}

.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover td { background: #fafafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table .empty-row td {
    text-align: center;
    color: var(--faint);
    padding: 40px 14px;
}

/* Stays a real table cell (display:flex on a td breaks the row borders) */
.actions-cell { white-space: nowrap; }
.actions-cell > * + * { margin-left: 6px; }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: var(--pill);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    background: var(--surface);
    color: var(--ink-2);
    vertical-align: middle;
}

.badge-brand { background: var(--brand-soft); color: var(--brand-dark); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Messages ---------- */

.msg {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 0.92rem;
}

.msg-success { background: var(--success-soft); color: var(--success); }
.msg-error { background: var(--danger-soft); color: var(--danger); }

/* ---------- Thumbnails ---------- */

.thumb {
    width: 72px;
    height: 54px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--surface);
    display: block;
}

.thumb-empty {
    width: 72px;
    height: 54px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--faint);
    font-size: 0.7rem;
}

/* ---------- Modal ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 6vh 16px;
    overflow-y: auto;
}

.modal.open { display: flex; }

.modal-dialog {
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 680px;
    padding: 28px;
    animation: modal-in 0.2s ease-out;
}

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

.modal-head h2 { font-size: 1.25rem; font-weight: 600; }

.modal-close {
    border: none;
    background: var(--surface);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
}

.modal-close:hover { background: var(--line); color: var(--ink); }

.modal-foot {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 20px;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

/* ---------- Login ---------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    padding: 40px 32px;
    text-align: center;
}

.login-card img { height: 34px; margin-bottom: 18px; }
.login-card h1 { font-size: 1.4rem; font-weight: 600; margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 0.9rem; margin-bottom: 24px; }
.login-card .form-group { text-align: left; margin-bottom: 16px; }
.login-card .msg { text-align: left; }

/* ---------- Misc ---------- */

.loading-dots::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--line-strong);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.text-muted { color: var(--muted); }
.mt-0 { margin-top: 0; }

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
    body { font-size: 14px; }
    .topbar-inner { padding: 0 16px; gap: 12px; }
    .brand span { display: none; }
    .nav-actions a .label-text { display: none; }
    .container { padding: 20px 16px 48px; }
    .page-head h1 { font-size: 1.5rem; }
    .card { padding: 20px 16px; border-radius: var(--radius); }
    .form-row { flex-direction: column; align-items: stretch; }
    .form-group.w-xs, .form-group.w-sm, .form-group.w-md { flex: 1 1 auto; }
    .data-table th, .data-table td { padding: 10px 8px; }
    .table-wrap .data-table { min-width: 720px; } /* scroll sideways instead of squeezing columns */
    .modal-dialog { padding: 20px 16px; }
}
