/* =========================================================
   Mesharsky ServerManager - Dashboard theme
   Dark, flat, minimal. No gradients. Just flat colors,
   subtle borders, and quiet animations.
   ========================================================= */

:root {
    --bg:          #0f1115;
    --bg-raised:   #161a22;
    --bg-elev:     #1b2029;
    --border:      #232832;
    --border-soft: #1e232c;
    --text:        #dde1e8;
    --text-mute:   #8a909c;
    --text-faint:  #5b6270;
    --accent:      #7aa2f7;
    --accent-soft: #2b3a59;
    --ok:          #86d39c;
    --ok-soft:     #24372b;
    --warn:        #e4b66b;
    --warn-soft:   #3a2f1b;
    --err:         #e56a6a;
    --err-soft:    #3a1f20;
    --radius:      8px;
    --radius-sm:   6px;
    --shadow:      0 1px 0 rgba(255,255,255,0.02) inset,
                   0 0 0 1px var(--border);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted  { color: var(--text-mute); }
.faint  { color: var(--text-faint); }
.small  { font-size: 12px; }
.center { text-align: center; }
.right  { text-align: right; }
.mt     { margin-top: .5rem; }

hr.sep {
    border: 0;
    border-top: 1px solid var(--border-soft);
    margin: 1rem 0;
}

/* ---------- App shell ---------- */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-raised);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0.9rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.25rem 0.5rem 1rem;
    border-bottom: 1px solid var(--border-soft);
}
.brand-stacked { flex-direction: row; justify-content: center; padding-bottom: .5rem; border: 0; }
.brand-mark {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elev);
    color: var(--accent);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: .5px;
    font-family: var(--mono);
}
.brand-mark.big { width: 44px; height: 44px; font-size: 15px; }
.brand-title { font-weight: 600; letter-spacing: -.01em; }
.brand-sub   { color: var(--text-mute); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    color: var(--text-mute);
    border-radius: var(--radius-sm);
    transition: background .12s ease, color .12s ease;
    font-weight: 500;
}
.nav-item:hover { background: var(--bg-elev); color: var(--text); text-decoration: none; }
.nav-item.active {
    background: var(--bg-elev);
    color: var(--text);
    box-shadow: inset 2px 0 0 var(--accent);
}
.nav-item svg { flex: 0 0 auto; }

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-soft);
    padding-top: 0.75rem;
    display: flex; align-items: center; gap: 0.5rem;
}
.me {
    display: flex; align-items: center; gap: 0.5rem; flex: 1; min-width: 0;
}
.me img, .me-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    object-fit: cover;
    display: grid; place-items: center; color: var(--text-mute); font-weight: 600; font-size: 13px;
}
.me-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.me-role { color: var(--text-mute); font-size: 11.5px; }
.logout {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-mute);
    background: transparent;
}
.logout:hover { color: var(--err); border-color: var(--err-soft); }

/* ---------- Main ---------- */
.main {
    padding: 2rem 2.25rem;
    max-width: 1280px;
    width: 100%;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-head h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -.01em;
    margin: 0.1rem 0 0.1rem;
}
.lede { color: var(--text-mute); margin: 0; font-size: 13.5px; }

/* ---------- Panels ---------- */
.panel {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    overflow: hidden;
    animation: fade-in .2s ease;
}
.panel-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--border-soft);
    gap: 1rem;
    flex-wrap: wrap;
}
.panel-head h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-mute);
}
.panel > *:not(.panel-head) { padding: 1.1rem; }
.panel > .table-wrap { padding: 0; }
.panel > .log-list   { padding: 0.35rem; }

.empty {
    color: var(--text-mute);
    font-size: 13px;
    padding: 1.5rem;
    text-align: center;
    background: var(--bg-elev);
    border-radius: var(--radius-sm);
}

/* ---------- Flashes ---------- */
.flash-stack { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.flash {
    padding: .65rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-raised);
    animation: slide-in .2s ease;
    font-size: 13px;
}
.flash-success { border-color: var(--ok-soft); color: var(--ok); }
.flash-error   { border-color: var(--err-soft); color: var(--err); }
.flash-info    { border-color: var(--accent-soft); color: var(--accent); }
.guest-flash   { max-width: 420px; margin: 0 auto 1rem; }

/* ---------- Stats ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    animation: fade-in .25s ease;
}
.stat-label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-mute);
    margin-bottom: 0.3rem;
}
.stat-value {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -.02em;
}
.stat-value .sub { color: var(--text-faint); font-size: 14px; font-weight: 500; margin-left: .35rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.tbl th {
    text-align: left;
    padding: 0.65rem 1rem;
    color: var(--text-mute);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-raised);
}
.tbl td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg-elev); }

.link        { color: var(--text); font-weight: 500; }
.link:hover  { color: var(--accent); text-decoration: none; }
.link-muted  { color: var(--text-mute); font-weight: 500; }
.link-muted:hover { color: var(--text); text-decoration: none; }

/* ---------- Pills / tags / dots ---------- */
.pill {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 11.5px;
    color: var(--text-mute);
    font-family: var(--mono);
}
.pill-small { font-size: 10.5px; padding: 1px 7px; }
.pill-accent { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.pill-accent:hover { text-decoration: none; filter: brightness(1.1); }

.tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    font-family: var(--mono);
}
.tag-plugin    { background: var(--accent-soft); color: var(--accent); }
.tag-dashboard { background: var(--ok-soft);     color: var(--ok); }
.tag-system    { background: var(--warn-soft);   color: var(--warn); }

.dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.dot-on  { background: var(--ok); box-shadow: 0 0 0 2px rgba(134,211,156,.15); }
.dot-off { background: var(--text-faint); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }

/* ---------- Buttons / forms ---------- */
.btn, .btn-ghost, .btn-primary, .btn-danger-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
    text-decoration: none;
}
.btn:hover, .btn-ghost:hover { background: #20262f; border-color: #2d333e; color: var(--text); text-decoration: none; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 12px; }
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #0c1119;
}
.btn-primary:hover {
    background: #8eb1f8;
    border-color: #8eb1f8;
    color: #0c1119;
    text-decoration: none;
}
.btn-danger-ghost {
    border-color: var(--err-soft);
    color: var(--err);
    background: transparent;
}
.btn-danger-ghost:hover { background: var(--err-soft); color: var(--err); text-decoration: none; }

.form-control, .form-select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(122,162,247,0.12);
}
.form-control-sm, .form-select-sm {
    padding: 0.35rem 0.55rem;
    font-size: 12.5px;
}
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%238a909c'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    padding-right: 2rem;
}
.select-inline {
    background: transparent;
    border: 1px dashed var(--border);
    padding: 0.25rem 1.75rem 0.25rem 0.5rem;
    font-size: 12px;
    color: var(--text);
    border-radius: var(--radius-sm);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%238a909c'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.45rem center;
    cursor: pointer;
}
.select-inline:focus { outline: none; border-color: var(--accent); border-style: solid; }

.field-label {
    display: block;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-mute);
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.inline-form { display: inline; }
.inline-grid {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) minmax(200px, 1fr) auto;
    gap: 0.6rem;
}

.row-end { display: flex; justify-content: flex-end; margin-top: .5rem; }
.stack   { display: flex; flex-direction: column; gap: 0.6rem; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.grid-2-small {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
}
@media (max-width: 700px) { .grid-2-small { grid-template-columns: 1fr; } }

.kv {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.35rem 1rem;
    margin: 0;
}
.kv dt { color: var(--text-mute); font-size: 12.5px; }
.kv dd { margin: 0; }

/* ---------- Switches ---------- */
.switch {
    --h: 20px;
    display: inline-grid; place-items: center;
    width: 36px; height: var(--h);
}
.switch input { display: none; }
.switch span {
    width: 32px; height: var(--h);
    border-radius: 999px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    position: relative;
    transition: background .15s ease, border-color .15s ease;
}
.switch span::before {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--text-mute);
    transition: transform .15s ease, background .15s ease;
}
.switch input:checked + span { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + span::before { transform: translateX(12px); background: var(--accent); }

.chk {
    display: inline-flex; align-items: center; gap: 0.35rem;
    color: var(--text-mute); font-size: 12.5px;
    user-select: none; cursor: pointer;
}
.chk input { accent-color: var(--accent); }

/* ---------- Group entries editor ---------- */
.entries-head {
    display: grid;
    grid-template-columns: 1.2fr 1.4fr 80px 110px 140px 40px;
    gap: 0.5rem;
    padding: 0.3rem 1.1rem 0.4rem;
    color: var(--text-mute);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-raised);
}
.entry-row {
    display: grid;
    grid-template-columns: 1.2fr 1.4fr 80px 110px 140px 40px;
    gap: 0.5rem;
    padding: 0.45rem 1.1rem;
    border-bottom: 1px solid var(--border-soft);
    align-items: center;
    animation: slide-in .15s ease;
}
.entry-row:last-child { border-bottom: none; }
.entry-row input.form-control, .entry-row select.form-select { padding: 0.4rem 0.55rem; font-size: 12.5px; }
@media (max-width: 900px) {
    .entries-head { display: none; }
    .entry-row { grid-template-columns: 1fr; }
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 0;
}
.form-actions .inline-form { margin-right: auto; }

.group-form .panel { padding: 0; }
.group-form .panel > :not(.panel-head):not(.entries-head):not(.entry-row):not(#entries) { padding: 1.1rem; }

/* ---------- Log list ---------- */
.log-list { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow-y: auto; }
.log-item {
    display: grid;
    grid-template-columns: 80px 90px 200px 1fr auto auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.55rem 0.8rem;
    border-bottom: 1px solid var(--border-soft);
    font-size: 12.5px;
    animation: fade-in .2s ease;
}
.log-item:last-child { border-bottom: none; }
.log-time { color: var(--text-faint); font-size: 11.5px; }
.log-event { color: var(--text-mute); }
.log-msg { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-warn  .log-msg { color: var(--warn); }
.log-error .log-msg { color: var(--err); }

.log-item.is-new { background: rgba(122,162,247,0.08); animation: highlight-in .9s ease; }
.log-item.is-hidden { display: none; }

@media (max-width: 900px) {
    .log-item { grid-template-columns: 1fr; gap: 0.2rem; }
    .log-msg { white-space: normal; }
}

.log-toolbar {
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}
.log-toolbar input[type=text] { max-width: 260px; }

.live-indicator {
    display: inline-flex; align-items: center; gap: 0.4rem;
    color: var(--text-mute);
    font-size: 12.5px;
    padding: 0.3rem 0.65rem;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 999px;
}

/* ---------- Chip list (servers using group) ---------- */
.chip-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
    display: inline-block;
    padding: 0.3rem 0.65rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text);
}
.chip:hover { border-color: var(--accent); text-decoration: none; }

/* ---------- Admin cell ---------- */
.admin-cell { display: flex; align-items: center; gap: 0.6rem; }
.avatar-sm {
    width: 32px; height: 32px; border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--bg-elev);
}
.avatar-fallback {
    display: grid; place-items: center;
    color: var(--text-mute); font-weight: 600; font-size: 13px;
}

/* ---------- Guest / login ---------- */
body.guest { background: var(--bg); }
.guest-main {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 2rem 1rem;
}
.login-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.25rem 2rem;
    max-width: 420px;
    width: 100%;
    animation: fade-in .25s ease;
}
.login-title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -.01em;
    margin: .9rem 0 0.25rem;
}
.login-lead { color: var(--text-mute); margin-bottom: 1.5rem; font-size: 13.5px; }

.btn-steam {
    display: flex; align-items: center; justify-content: center; gap: 0.6rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: #1b2838;
    border: 1px solid #1b2838;
    color: #c6d4df;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: background .12s ease;
}
.btn-steam:hover { background: #213447; color: #fff; text-decoration: none; }

.login-footer {
    margin: 1.5rem 0 0;
    color: var(--text-faint);
    font-size: 11.5px;
    text-align: center;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a313c; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #363d49; }

/* ---------- Animations ---------- */
@keyframes fade-in {
    from { opacity: 0; transform: translateY(2px); }
    to   { opacity: 1; transform: none; }
}
@keyframes slide-in {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: none; }
}
@keyframes highlight-in {
    0%   { background: rgba(122,162,247,0.25); }
    100% { background: transparent; }
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.6; transform: scale(1.15); }
}

/* Mobile shell */
@media (max-width: 800px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 0.75rem;
        flex-wrap: wrap;
    }
    .sidebar .brand { padding-bottom: 0; border: 0; }
    .sidebar .nav {
        flex-direction: row;
        flex-wrap: wrap;
        flex: 1;
        justify-content: flex-end;
    }
    .nav-item span { display: none; }
    .nav-item { padding: 0.5rem 0.6rem; }
    .sidebar-footer { margin: 0; border: 0; padding: 0; }
    .main { padding: 1.25rem; }
}
