/* ==========================================================================
   ВедиSMM — Design System
   A hand-built, enterprise-grade token + component library. No frameworks.
   Light & dark theme, fully responsive, accessible focus states.
   ========================================================================== */

/* ------------------------------------------------------------------ Tokens */
:root {
    /* Brand */
    --brand-50:  #eef0ff;
    --brand-100: #e0e3ff;
    --brand-200: #c7ccff;
    --brand-300: #a5a8ff;
    --brand-400: #8a83ff;
    --brand-500: #5b4bff;
    --brand-600: #4d3ce6;
    --brand-700: #3f30bf;
    --brand-800: #342a99;
    --brand-900: #2b2478;
    --accent-500: #ff5c8a;
    --accent-600: #eb3d70;

    /* Semantic */
    --success-50: #e7f8f0; --success-500: #12b76a; --success-600: #0e9a58;
    --warning-50: #fff4e5; --warning-500: #f79009; --warning-600: #d97706;
    --danger-50:  #fdeceb; --danger-500:  #f04438; --danger-600:  #d92d20;
    --info-50:    #e8f2ff; --info-500:    #2e90fa; --info-600:    #1570cd;

    /* Neutrals (slate) */
    --gray-0:   #ffffff;
    --gray-25:  #fcfcfd;
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e6ebf1;
    --gray-300: #d3dbe4;
    --gray-400: #9aa7b8;
    --gray-500: #6b7a90;
    --gray-600: #4c586b;
    --gray-700: #364152;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --gray-950: #0b0f19;

    /* Surface / semantic aliases (light theme) */
    --bg:            var(--gray-50);
    --bg-elevated:   var(--gray-0);
    --surface:       var(--gray-0);
    --surface-2:     var(--gray-50);
    --surface-hover: var(--gray-100);
    --border:        var(--gray-200);
    --border-strong: var(--gray-300);
    --text:          var(--gray-900);
    --text-secondary:var(--gray-600);
    --text-muted:    var(--gray-500);
    --text-inverse:  var(--gray-0);
    --brand:         var(--brand-500);
    --brand-contrast:#ffffff;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
                 "PT Sans", "Noto Sans", Arial, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
    --text-xs: 12px; --text-sm: 13px; --text-base: 14px; --text-md: 15px;
    --text-lg: 17px; --text-xl: 20px; --text-2xl: 24px; --text-3xl: 30px;
    --text-4xl: 38px; --text-5xl: 48px;

    /* Spacing scale */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
    --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;
    --sp-20: 80px; --sp-24: 96px;

    /* Radius */
    --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-2xl: 28px; --r-full: 999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(16,24,40,.05);
    --shadow-sm: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
    --shadow-md: 0 4px 12px rgba(16,24,40,.08), 0 2px 4px rgba(16,24,40,.04);
    --shadow-lg: 0 12px 28px rgba(16,24,40,.12), 0 4px 8px rgba(16,24,40,.05);
    --shadow-xl: 0 24px 48px rgba(16,24,40,.16);
    --ring: 0 0 0 4px rgba(91,75,255,.16);

    /* Motion */
    --ease: cubic-bezier(.4, 0, .2, 1);
    --dur: .18s;

    --sidebar-w: 260px;
    --topbar-h: 64px;
    --container: 1200px;
}

:root[data-theme="dark"] {
    --bg:            var(--gray-950);
    --bg-elevated:   #131a26;
    --surface:       #141b28;
    --surface-2:     #10161f;
    --surface-hover: #1c2533;
    --border:        #232d3d;
    --border-strong: #2f3b4d;
    --text:          #eaf0f7;
    --text-secondary:#a7b4c6;
    --text-muted:    #7787a0;
    --text-inverse:  #0b0f19;
    --brand:         var(--brand-400);
    --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,.45);
    --shadow-lg: 0 12px 28px rgba(0,0,0,.5);
    --shadow-xl: 0 24px 48px rgba(0,0,0,.6);
    --ring: 0 0 0 4px rgba(138,131,255,.24);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:            var(--gray-950);
        --bg-elevated:   #131a26;
        --surface:       #141b28;
        --surface-2:     #10161f;
        --surface-hover: #1c2533;
        --border:        #232d3d;
        --border-strong: #2f3b4d;
        --text:          #eaf0f7;
        --text-secondary:#a7b4c6;
        --text-muted:    #7787a0;
        --text-inverse:  #0b0f19;
        --brand:         var(--brand-400);
        --shadow-md: 0 4px 12px rgba(0,0,0,.45);
        --shadow-lg: 0 12px 28px rgba(0,0,0,.5);
    }
}

/* -------------------------------------------------------------------- Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img, video { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; letter-spacing: -.02em; color: var(--text); }
ul, ol { list-style: none; padding: 0; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
::selection { background: var(--brand-200); color: var(--gray-900); }
hr { border: none; border-top: 1px solid var(--border); }

/* ------------------------------------------------------------- Utilities */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--sp-6); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: var(--sp-1);} .gap-2 { gap: var(--sp-2);} .gap-3 { gap: var(--sp-3);}
.gap-4 { gap: var(--sp-4);} .gap-6 { gap: var(--sp-6);}
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.center { text-align: center; }
.mt-2{margin-top:var(--sp-2)}.mt-3{margin-top:var(--sp-3)}.mt-4{margin-top:var(--sp-4)}
.mt-6{margin-top:var(--sp-6)}.mt-8{margin-top:var(--sp-8)}
.mb-2{margin-bottom:var(--sp-2)}.mb-4{margin-bottom:var(--sp-4)}.mb-6{margin-bottom:var(--sp-6)}
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
    height: 40px; padding: 0 var(--sp-4); border-radius: var(--r-md);
    font-size: var(--text-base); font-weight: 600; white-space: nowrap;
    border: 1px solid transparent; transition: all var(--dur) var(--ease);
    user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand-500); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-600); box-shadow: var(--shadow-md); }
.btn-gradient {
    background: linear-gradient(120deg, var(--brand-500), #7b6bff 60%, var(--accent-500));
    color: #fff; box-shadow: 0 6px 18px rgba(91,75,255,.35);
}
.btn-gradient:hover { filter: brightness(1.05); box-shadow: 0 8px 24px rgba(91,75,255,.45); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-danger { background: var(--danger-500); color: #fff; }
.btn-danger:hover { background: var(--danger-600); }
.btn-danger-soft { background: var(--danger-50); color: var(--danger-600); }
.btn-danger-soft:hover { background: var(--danger-500); color:#fff; }
.btn-sm { height: 32px; padding: 0 var(--sp-3); font-size: var(--text-sm); border-radius: var(--r-sm); }
.btn-lg { height: 48px; padding: 0 var(--sp-6); font-size: var(--text-md); border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ------------------------------------------------------------------ Cards */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: var(--sp-6); }
.card-header { padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.card-header h3 { font-size: var(--text-lg); }
.card-body { padding: var(--sp-6); }
.card-hover { transition: all var(--dur) var(--ease); }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }

/* ----------------------------------------------------------------- Forms */
.field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.label { font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.label .req { color: var(--danger-500); }
.input, .textarea, .select {
    width: 100%; height: 42px; padding: 0 var(--sp-3);
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: var(--r-md);
    transition: border-color var(--dur), box-shadow var(--dur);
    font-size: var(--text-base);
}
.textarea { height: auto; min-height: 96px; padding: var(--sp-3); resize: vertical; line-height: 1.55; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand-400); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input.error, .textarea.error { border-color: var(--danger-500); }
.field-error { font-size: var(--text-sm); color: var(--danger-600); }
.field-hint { font-size: var(--text-sm); color: var(--text-muted); }
.select { appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7a90' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.input-group { position: relative; }
.input-group .prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-group .input { padding-left: 34px; }

/* toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 42px; height: 24px; border-radius: var(--r-full); background: var(--gray-300); transition: background var(--dur); flex: none; }
.switch .thumb { position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur); }
.switch input:checked ~ .track { background: var(--brand-500); }
.switch input:checked ~ .track .thumb { transform: translateX(18px); }

/* checkbox pill (network / account picker) */
.check-pill { display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--border-strong); border-radius: var(--r-full); cursor: pointer;
    transition: all var(--dur) var(--ease); background: var(--surface); font-weight: 600; font-size: var(--text-sm); }
.check-pill:hover { border-color: var(--brand-400); background: var(--brand-50); }
.check-pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.check-pill.selected { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); box-shadow: var(--ring); }
:root[data-theme="dark"] .check-pill.selected, :root[data-theme="dark"] .check-pill:hover { background: rgba(91,75,255,.15); color: var(--brand-300); }
/* Checkmark appears only when the pill is actually selected (avoids a false "selected" look). */
.check-pill .check-mark { display: none; }
.check-pill.selected .check-mark { display: inline-flex; }

/* --------------------------------------------------------------- Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 var(--sp-2);
    font-size: var(--text-xs); font-weight: 700; border-radius: var(--r-full);
    background: var(--surface-hover); color: var(--text-secondary); text-transform: none; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-50); color: var(--success-600); }
.badge-warning { background: var(--warning-50); color: var(--warning-600); }
.badge-danger  { background: var(--danger-50);  color: var(--danger-600); }
.badge-info    { background: var(--info-50);    color: var(--info-600); }
.badge-brand   { background: var(--brand-50);   color: var(--brand-700); }
:root[data-theme="dark"] .badge-success{background:rgba(18,183,106,.16);color:#3ddc94}
:root[data-theme="dark"] .badge-warning{background:rgba(247,144,9,.16);color:#f9b155}
:root[data-theme="dark"] .badge-danger{background:rgba(240,68,56,.16);color:#f5867d}
:root[data-theme="dark"] .badge-info{background:rgba(46,144,250,.16);color:#6bb2fb}
:root[data-theme="dark"] .badge-brand{background:rgba(91,75,255,.18);color:#a5a8ff}

/* --------------------------------------------------------------- Avatars */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center;
    justify-content: center; font-weight: 700; color: #fff; flex: none; overflow: hidden;
    background: linear-gradient(135deg, var(--brand-500), var(--accent-500)); font-size: var(--text-sm); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 30px; height: 30px; font-size: var(--text-xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-lg); }

/* network glyph */
.net { width: 34px; height: 34px; border-radius: var(--r-md); display: inline-flex; align-items: center;
    justify-content: center; color: #fff; flex: none; }
.net svg { width: 20px; height: 20px; }
.net-sm { width: 24px; height: 24px; border-radius: var(--r-sm); }
.net-sm svg { width: 15px; height: 15px; }
.net-lg { width: 48px; height: 48px; border-radius: var(--r-lg); }
.net-lg svg { width: 26px; height: 26px; }

/* --------------------------------------------------------------- Alerts */
.alert { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
    border: 1px solid var(--border); background: var(--surface-2); font-size: var(--text-sm); align-items: flex-start; }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert-success { background: var(--success-50); border-color: #b6ebd0; color: var(--success-600); }
.alert-warning { background: var(--warning-50); border-color: #ffdca8; color: var(--warning-600); }
.alert-danger  { background: var(--danger-50);  border-color: #f7c6c2; color: var(--danger-600); }
.alert-info    { background: var(--info-50);    border-color: #bcdcff; color: var(--info-600); }
:root[data-theme="dark"] .alert-success{background:rgba(18,183,106,.1);border-color:rgba(18,183,106,.3);color:#5fdca0}
:root[data-theme="dark"] .alert-warning{background:rgba(247,144,9,.1);border-color:rgba(247,144,9,.3);color:#f9b155}
:root[data-theme="dark"] .alert-danger{background:rgba(240,68,56,.1);border-color:rgba(240,68,56,.3);color:#f5867d}
:root[data-theme="dark"] .alert-info{background:rgba(46,144,250,.1);border-color:rgba(46,144,250,.3);color:#6bb2fb}

/* --------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th { text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); font-weight: 700; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); font-size: var(--text-sm); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur); }
.table tbody tr:hover { background: var(--surface-2); }

/* --------------------------------------------------------------- Tabs */
.tabs { display: inline-flex; gap: 2px; padding: 4px; background: var(--surface-2); border-radius: var(--r-md); border: 1px solid var(--border); }
.tab { padding: var(--sp-2) var(--sp-4); border-radius: var(--r-sm); font-weight: 600; font-size: var(--text-sm); color: var(--text-secondary); transition: all var(--dur); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--brand-600); box-shadow: var(--shadow-xs); }
:root[data-theme="dark"] .tab.active { color: var(--brand-300); }

/* --------------------------------------------------------- Empty state */
.empty { text-align: center; padding: var(--sp-12) var(--sp-6); }
.empty .empty-icon { width: 64px; height: 64px; border-radius: var(--r-xl); background: var(--brand-50);
    color: var(--brand-500); display: inline-flex; align-items: center; justify-content: center; margin-bottom: var(--sp-4); }
.empty .empty-icon svg { width: 30px; height: 30px; }
:root[data-theme="dark"] .empty .empty-icon { background: rgba(91,75,255,.14); }
.empty h3 { font-size: var(--text-lg); margin-bottom: var(--sp-2); }
.empty p { color: var(--text-muted); max-width: 420px; margin: 0 auto var(--sp-4); }

/* --------------------------------------------------------------- Toasts */
#toasts { position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: 200; display: flex; flex-direction: column; gap: var(--sp-2); max-width: 360px; }
.toast { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4);
    background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand-500);
    border-radius: var(--r-md); box-shadow: var(--shadow-lg); animation: toastIn .25s var(--ease); font-size: var(--text-sm); }
.toast.success { border-left-color: var(--success-500); }
.toast.error { border-left-color: var(--danger-500); }
.toast.info { border-left-color: var(--info-500); }
.toast svg { width: 20px; height: 20px; flex: none; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut .2s var(--ease) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* --------------------------------------------------------------- Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11,15,25,.5); backdrop-filter: blur(3px);
    z-index: 150; display: flex; align-items: center; justify-content: center; padding: var(--sp-4); animation: fade .2s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
    box-shadow: var(--shadow-xl); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; animation: pop .22s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.modal-header { padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: var(--text-lg); }
.modal-body { padding: var(--sp-6); }
.modal-footer { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--sp-3); }

/* --------------------------------------------------------------- Progress */
.progress { height: 8px; background: var(--surface-hover); border-radius: var(--r-full); overflow: hidden; }
.progress .bar { height: 100%; background: linear-gradient(90deg, var(--brand-500), var(--accent-500)); border-radius: var(--r-full); transition: width .3s var(--ease); }

/* --------------------------------------------------------------- Misc */
.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; }
.dot-sep::before { content: "•"; margin: 0 var(--sp-2); color: var(--text-muted); }
.kbd { font-family: var(--font-mono); font-size: var(--text-xs); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px 6px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--brand-500); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
