/* ============================================================
   Kvasir Tibia Dashboard — design system
   ============================================================ */

:root {
    --bg: #0a0e17;
    --surface: #111726;
    --surface-2: #182033;
    --surface-3: #1e2840;
    --border: rgba(148, 163, 184, 0.10);
    --border-strong: rgba(148, 163, 184, 0.20);
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --accent: #6366f1;
    --accent-soft: rgba(99, 102, 241, 0.14);
    --green: #34d399;
    --green-soft: rgba(52, 211, 153, 0.12);
    --red: #f87171;
    --red-soft: rgba(248, 113, 113, 0.12);
    --amber: #fbbf24;
    --amber-soft: rgba(251, 191, 36, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 16px 40px -20px rgba(0, 0, 0, 0.6);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background:
        radial-gradient(1100px 500px at 85% -10%, rgba(99, 102, 241, 0.13), transparent 60%),
        radial-gradient(900px 450px at -10% 0%, rgba(52, 211, 153, 0.07), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

.tnum { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

/* ---------- Top bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(10, 14, 23, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 14px clamp(16px, 3vw, 32px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.brand-icon {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #10b981);
    box-shadow: 0 8px 20px -8px rgba(99, 102, 241, 0.7);
}

.brand-icon svg { width: 22px; height: 22px; }

.brand-text h1 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-text span {
    display: block;
    font-size: 0.74rem;
    color: var(--text-faint);
    margin-top: 1px;
}

.world-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--green);
    background: var(--green-soft);
    border: 1px solid rgba(52, 211, 153, 0.25);
    white-space: nowrap;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2.2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
    50%      { box-shadow: 0 0 0 5px rgba(52, 211, 153, 0); }
}

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

.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 26px clamp(16px, 3vw, 32px) 72px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0) 40%), var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: fade-up 0.45s ease both;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- KPI cards ---------- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 22px 24px;
    transition: transform 0.25s ease, border-color 0.25s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
}

.kpi-grid .kpi-card:nth-child(2) { animation-delay: 0.06s; }
.kpi-grid .kpi-card:nth-child(3) { animation-delay: 0.12s; }

.kpi-icon {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
}

.kpi-icon svg { width: 24px; height: 24px; }

.kpi-icon-indigo { color: #a5b4fc; background: var(--accent-soft); }
.kpi-icon-amber  { color: var(--amber); background: var(--amber-soft); }

.rashid-img {
    flex: 0 0 auto;
    height: 52px;
    width: auto;
    image-rendering: pixelated;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5));
}

.kpi-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.kpi-value {
    font-size: clamp(1.45rem, 2.2vw, 1.8rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: #fff;
    white-space: nowrap;
}

.kpi-hint {
    font-size: 0.76rem;
    color: var(--text-faint);
}

/* ---------- Panels ---------- */

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
    align-items: stretch;
}

@media (min-width: 1100px) {
    .content-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    #roster-card.expanded { grid-column: 1 / -1; }
}

.panel {
    padding: 20px 22px 22px;
    display: flex;
    flex-direction: column;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.panel-head h2 {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.panel-sub {
    margin: 2px 0 0;
    font-size: 0.78rem;
    color: var(--text-faint);
}

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

.table-wrap {
    overflow: auto;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 560px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    scrollbar-width: thin;
    scrollbar-color: var(--surface-3) transparent;
}

.table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.86rem;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #141b2d;
    padding: 10px 14px;
    text-align: left;
    font-size: 0.67rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}

tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    color: var(--text-muted);
}

tbody tr:last-child td { border-bottom: none; }

tbody tr.clickable { cursor: pointer; }

tbody tr.clickable:hover td { background: var(--surface-2); }

tbody tr.clickable:hover .row-chevron {
    color: var(--accent);
    transform: translateX(2px);
}

.cell-name { font-weight: 600; color: var(--text); white-space: nowrap; }
.cell-muted { color: var(--text-faint); }
.cell-time { white-space: nowrap; color: var(--text-muted); }
.cell-reason { min-width: 0; }

.cell-hint {
    display: block;
    font-size: 0.72rem;
    color: var(--text-faint);
    margin-top: 1px;
}

.th-action { width: 30px; }

.row-chevron {
    display: inline-block;
    color: var(--text-faint);
    font-size: 1.1rem;
    line-height: 1;
    transition: transform 0.2s ease, color 0.2s ease;
}

/* Badges & pills */

.pill {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    vertical-align: 1px;
}

.pill-up   { color: var(--green); background: var(--green-soft); }
.pill-down { color: var(--red);   background: var(--red-soft); }

.voc-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

.voc-knight   { color: #fca5a5; background: rgba(248, 113, 113, 0.10); border-color: rgba(248, 113, 113, 0.22); }
.voc-paladin  { color: #fcd34d; background: rgba(251, 191, 36, 0.10);  border-color: rgba(251, 191, 36, 0.22); }
.voc-sorcerer { color: #c4b5fd; background: rgba(167, 139, 250, 0.10); border-color: rgba(167, 139, 250, 0.22); }
.voc-druid    { color: #6ee7b7; background: rgba(52, 211, 153, 0.10);  border-color: rgba(52, 211, 153, 0.22); }
.voc-monk     { color: #fdba74; background: rgba(251, 146, 60, 0.10);  border-color: rgba(251, 146, 60, 0.22); }
.voc-none     { color: var(--text-faint); background: rgba(148, 163, 184, 0.08); border-color: var(--border); }

.dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: 1px;
}

.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-gray  { background: var(--text-faint); }

/* ---------- Chart ---------- */

.chart-area { margin-top: 4px; }

#lineChart {
    width: 100%;
    height: 440px;
}

.chart-help {
    margin: 10px 2px 0;
    font-size: 0.74rem;
    color: var(--text-faint);
    text-align: center;
}

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

.btn {
    font-family: inherit;
    font-size: 0.83rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.btn:hover { background: #818cf8; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: wait; }

.btn:focus-visible,
tr.clickable:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn-ghost {
    color: #a5b4fc;
    background: var(--accent-soft);
    border: 1px solid rgba(99, 102, 241, 0.32);
}

.btn-ghost:hover { background: rgba(99, 102, 241, 0.24); }

.btn-block {
    display: block;
    width: 100%;
    margin-top: 14px;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
}

.btn-block:hover { background: var(--surface-3); color: var(--text); }

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translate(-50%, 16px);
    z-index: 100;
    max-width: min(90vw, 420px);
    padding: 11px 18px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

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

@media (max-width: 900px) {
    .kpi-grid { grid-template-columns: 1fr; gap: 14px; }
    .kpi-card { padding: 18px 20px; }
    #lineChart { height: 340px; }
    .brand-text span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}
