/* ----------------- DESIGN TOKENS ----------------- */
:root {
    --c-bg:           #0f1117;
    --c-bg-elev:      #161a23;
    --c-bg-elev-2:    #1d2230;
    --c-line:         #262d3d;
    --c-line-soft:    #1f2533;
    --c-text:         #e6e9ef;
    --c-text-dim:     #8b93a7;
    --c-text-soft:    #a9b0c1;

    --c-primary:      #5b8cff;
    --c-primary-h:    #7aa3ff;
    --c-primary-d:    #3f6ed1;

    --c-accent:       #5ad8a6;
    --c-warn:         #ffb454;
    --c-danger:       #ff6e6e;

    --c-status-free:    #4ad991;
    --c-status-busy:    #ffb454;
    --c-status-dnd:     #ff6e6e;
    --c-status-away:    #8b93a7;
    --c-status-offline: #5a6076;

    --r-sm: 4px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 18px;

    --shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 2px 8px rgba(0,0,0,.18);
    --shadow-2: 0 4px 12px rgba(0,0,0,.35), 0 12px 28px rgba(0,0,0,.24);

    --t-fast: .12s ease;
    --t-mid:  .2s ease;
}

/* ----------------- RESET ----------------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

/* The HTML `hidden` attribute has low CSS specificity (UA stylesheet),
   so any explicit `display:` rule (e.g. `.modal { display: flex }`)
   silently overrides it. This rule is what fixes that. */
[hidden] { display: none !important; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    background: var(--c-bg);
    color: var(--c-text);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-h); }

button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea {
    font-family: inherit; font-size: inherit;
    background: var(--c-bg-elev-2);
    color: var(--c-text);
    border: 1px solid var(--c-line);
    border-radius: var(--r-md);
    padding: 8px 10px;
    outline: none;
    transition: border-color var(--t-fast);
}
input:focus, select:focus, textarea:focus { border-color: var(--c-primary); }
textarea { resize: vertical; min-height: 60px; font-size: 14px; }

label {
    display: block;
    font-size: 13px;
    color: var(--c-text-soft);
    margin-bottom: 12px;
}
label > span { display: block; margin-bottom: 4px; }
label input, label select, label textarea { width: 100%; }

.muted { color: var(--c-text-dim); }
.center { text-align: center; }
.error-msg { color: var(--c-danger); font-size: 13px; padding: 8px 0; }

/* ----------------- BUTTONS ----------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px; font-weight: 500;
    background: var(--c-bg-elev-2);
    color: var(--c-text);
    border: 1px solid var(--c-line);
    border-radius: var(--r-md);
    transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.btn:hover { background: #232a3b; border-color: #303a52; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-h); border-color: var(--c-primary-h); }
.btn-danger { background: transparent; color: var(--c-danger); border-color: rgba(255,110,110,.4); }
.btn-danger:hover { background: rgba(255,110,110,.12); border-color: var(--c-danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--c-text-soft); }
.btn-ghost:hover { background: rgba(255,255,255,.04); color: var(--c-text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.icon-btn {
    width: 34px; height: 34px;
    padding: 0;
    font-size: 16px;
    line-height: 1;
}
.icon-btn.muted { color: var(--c-text-dim); }
.icon-btn.muted:hover { color: var(--c-text); }

/* ----------------- BADGES ----------------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-radius: 999px;
    background: var(--c-line);
    color: var(--c-text-soft);
}
.badge-role { background: rgba(91,140,255,.15); color: var(--c-primary-h); }
.badge-ask    { background: rgba(90,216,166,.15); color: #5ad8a6; }
.badge-report { background: rgba(255,110,110,.15); color: #ff8a8a; }

.status-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--c-status-offline);
    margin-right: 6px;
    vertical-align: middle;
}
.status-dot.free    { background: var(--c-status-free); }
.status-dot.busy    { background: var(--c-status-busy); }
.status-dot.dnd     { background: var(--c-status-dnd); }
.status-dot.away    { background: var(--c-status-away); }
.status-dot.offline { background: var(--c-status-offline); }

/* ----------------- TOPBAR ----------------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 22px;
    height: 54px;
    background: var(--c-bg-elev);
    border-bottom: 1px solid var(--c-line);
    position: sticky; top: 0; z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 24px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.brand {
    font-weight: 700; font-size: 15px; letter-spacing: .04em;
    color: var(--c-primary-h);
}
.nav { display: flex; gap: 4px; }
.nav a {
    padding: 8px 12px;
    color: var(--c-text-soft);
    border-radius: var(--r-md);
    font-size: 13px;
    transition: background var(--t-fast), color var(--t-fast);
}
.nav a:hover { background: rgba(255,255,255,.04); color: var(--c-text); }
.nav a.active { background: rgba(91,140,255,.12); color: var(--c-primary-h); }

.me { display: inline-flex; align-items: center; gap: 8px; }
.me-username { font-weight: 500; }
.status-picker {
    display: inline-flex; align-items: center; gap: 6px;
    margin-bottom: 0;
    color: var(--c-text-dim);
    font-size: 13px;
}
.status-picker select { padding: 6px 8px; }

/* ----------------- TABLES ----------------- */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--c-line-soft);
}
.table th { color: var(--c-text-dim); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table tr:hover td { background: rgba(255,255,255,.02); }
.table-wrap { background: var(--c-bg-elev); border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--c-line); }

/* ----------------- MODALS ----------------- */
.modal {
    position: fixed; inset: 0;
    background: rgba(8,10,16,.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 50;
    padding: 20px;
    backdrop-filter: blur(2px);
}
.modal-card {
    background: var(--c-bg-elev);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    width: 100%; max-width: 460px;
    box-shadow: var(--shadow-2);
    display: flex; flex-direction: column;
    max-height: 90vh;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--c-line-soft);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 12px 18px;
    border-top: 1px solid var(--c-line-soft);
}

/* ----------------- SCROLLBAR ----------------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #303a52; }
