@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;1,14..32,400&display=swap');

:root {
    --bg-base: #09090b;
    --bg-surface: #18181b;
    --bg-surface-hover: #27272a;
    --bg-surface-2: #1f1f23;

    --border-color: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.14);

    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);

    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --purple: #a855f7;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.25);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.35);
    --shadow-glow: 0 0 24px rgba(59,130,246,0.12);

    --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-surface-hover); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Surfaces ─── */
.glass-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.glass-panel:hover {
    border-color: var(--border-hover);
}
.glass-panel-inner {
    background: rgba(0,0,0,0.22);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

/* ─── Layout ─── */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}
.main-content {
    flex: 1;
    padding: 2.5rem;
    overflow-x: hidden;
    min-width: 0;
}

/* ─── SPA Sections ─── */
#app-content {
    transition: opacity 0.28s ease, transform 0.28s ease;
}
.spa-section {
    animation: fadeUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Sidebar ─── */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    background: var(--bg-base);
    border-right: 1px solid var(--border-color);
    z-index: 50;
    overflow-y: auto;
}
.sidebar-header {
    padding: 1.5rem 1.25rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.4px;
}
.logo-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 12px rgba(59,130,246,0.4);
}
.close-sidebar {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.close-sidebar:hover { color: var(--text-primary); background: var(--bg-surface-hover); }

.sidebar-menu {
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.menu-section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.75rem 0.875rem 0.25rem;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}
.menu-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-primary);
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: inherit;
}
.menu-item:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}
.menu-item.active {
    color: var(--text-primary);
    background: var(--bg-surface);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}
.menu-item.active .menu-icon { color: var(--accent-primary); }
.menu-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s;
}

.sidebar-footer {
    padding: 1rem 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
}
.lang-switch-container { margin-bottom: 1rem; }
.lang-select {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}
.lang-select:hover { border-color: var(--border-hover); }

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
    cursor: pointer;
}
.user-profile:hover {
    background: var(--bg-surface-hover);
}
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 0.8125rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}
.user-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.user-name { font-size: 0.8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.6875rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Buttons ─── */
button {
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--accent-primary);
    color: #fff;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    box-shadow: 0 1px 4px rgba(59,130,246,0.25);
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-primary-hover);
    box-shadow: 0 4px 12px rgba(59,130,246,0.35);
    transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
}
.btn-secondary:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    border-color: var(--border-hover);
}

.btn-danger {
    background: rgba(239,68,68,0.08);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.18);
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
}
.btn-danger:hover:not(:disabled) {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.3);
}

.btn-small { padding: 0.375rem 0.75rem; font-size: 0.8rem; }

.btn-logout {
    width: 100%;
    padding: 0.5625rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: var(--transition);
    gap: 0.5rem;
}
.btn-logout:hover {
    color: var(--danger);
    border-color: rgba(239,68,68,0.25);
    background: rgba(239,68,68,0.05);
}

/* ─── Stats Cards ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}
.stat-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    border-radius: 50%;
    opacity: 0.04;
    transform: translate(30%, -30%);
    transition: opacity 0.3s;
}
.stat-card:hover::after { opacity: 0.07; }
.stat-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-lg); }

.stat-icon {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}
.stat-title { font-size: 0.8125rem; color: var(--text-secondary); font-weight: 500; }
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.stat-delta {
    font-size: 0.75rem;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ─── Table ─── */
.table-section { padding: 1.5rem; }
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.table-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}
th {
    padding: 0.875rem 1.125rem;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(0,0,0,0.18);
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}
td {
    padding: 0.875rem 1.125rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: background 0.15s;
}
tr:hover td { background: rgba(255,255,255,0.025); }
tr:last-child td { border-bottom: none; }
tr { transition: background 0.15s; }

.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ─── Status Badges ─── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.2rem 0.65rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.status-open {
    background: rgba(16,185,129,0.1);
    color: var(--success);
    border: 1px solid rgba(16,185,129,0.2);
}
.status-close {
    background: rgba(239,68,68,0.1);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.2);
}

/* ─── Filters ─── */
.filters-container {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    align-items: flex-end;
}
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1;
    min-width: 180px;
}
.input-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

/* ─── Form Inputs ─── */
input, select, textarea {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s;
    width: 100%;
    font-family: inherit;
    box-sizing: border-box;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
input:disabled, select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: rgba(0,0,0,0.1);
}
select option { background: #1a1a1e; color: var(--text-primary); }

.clean-form input:not(:disabled),
.clean-form select:not(:disabled) {
    background: rgba(255,255,255,0.03);
}

/* ─── Checkbox Items ─── */
.filials-checkbox-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.625rem;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: rgba(0,0,0,0.15);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
}
.checkbox-item:hover { border-color: var(--accent-primary); background: var(--accent-glow); }
.checkbox-item input[type="checkbox"] {
    width: 14px; height: 14px;
    cursor: pointer;
    accent-color: var(--accent-primary);
    flex-shrink: 0;
}
.checkbox-item:has(input:checked) {
    border-color: var(--accent-primary);
    background: rgba(59,130,246,0.08);
}

/* ─── Status Box (Telegram) ─── */
.status-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ─── Loader ─── */
.loader {
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--accent-primary);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Alerts ─── */
.error-text {
    color: var(--danger);
    font-size: 0.8125rem;
    padding: 0.75rem 1rem;
    background: rgba(239,68,68,0.08);
    border-radius: var(--radius-md);
    border: 1px solid rgba(239,68,68,0.18);
    animation: fadeUp 0.2s ease;
}
.success-text {
    color: var(--success);
    font-size: 0.8125rem;
    padding: 0.75rem 1rem;
    background: rgba(16,185,129,0.08);
    border-radius: var(--radius-md);
    border: 1px solid rgba(16,185,129,0.18);
    animation: fadeUp 0.2s ease;
}
.hidden { display: none !important; }

/* ─── Code Block ─── */
.code-block {
    background: rgba(0,0,0,0.4);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.775rem;
    color: #a1a1aa;
    border: 1px solid var(--border-color);
    display: inline-block;
    word-break: break-all;
    max-width: 280px;
}

/* ─── Dashboard chart section ─── */
.chart-wrapper {
    padding: 1.25rem;
}
.chart-bar {
    transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.chart-bar:hover {
    opacity: 1 !important;
    filter: brightness(1.2);
}

/* ─── Profile ─── */
.profile-avatar-large {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 16px rgba(59,130,246,0.35);
    margin: 0 auto 1rem;
}

/* ─── Skeleton loading ─── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-hover) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Pulse animation for online indicators ─── */
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}
.pulse-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

/* ─── Responsive form row (2 cols -> 1 col on small screens) ─── */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 560px) {
    .form-row-2 { grid-template-columns: 1fr; gap: 1rem; }
}

/* ─── Login Page ─── */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
}
.ambient-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}
.ambient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.28;
    animation: orbFloat 14s ease-in-out infinite;
}
.orb-1 {
    width: 420px; height: 420px;
    background: var(--accent-primary);
    top: -120px; left: -100px;
}
.orb-2 {
    width: 380px; height: 380px;
    background: var(--purple);
    bottom: -140px; right: -100px;
    animation-delay: -7s;
}
@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -20px) scale(1.08); }
}

.login-lang-switch {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 2;
}
.login-lang-switch .lang-select {
    width: auto;
    background: var(--bg-surface);
    font-size: 0.8rem;
    padding: 0.4rem 0.7rem;
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 380px;
    padding: 2.25rem 2rem;
    animation: fadeUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.login-logo {
    width: 52px; height: 52px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-primary), #6366f1);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 6px 18px rgba(59,130,246,0.35);
}
.login-header { text-align: center; margin-bottom: 1.75rem; }
.login-header h2 {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.3rem;
}
.login-header p { color: var(--text-secondary); font-size: 0.85rem; }

#login-form .input-group { margin-bottom: 1rem; min-width: 0; }
.password-field-wrap { position: relative; }
.password-field-wrap input { padding-right: 2.6rem; }
.password-toggle-btn {
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem; height: 2rem;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 0;
}
.password-toggle-btn:hover { color: var(--text-secondary); background: var(--bg-surface-hover); }
.password-toggle-btn svg { width: 18px; height: 18px; }

.btn-block { width: 100%; justify-content: center; }
#login-form button[type="submit"] {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}
#login-form button[type="submit"]:disabled { opacity: 0.75; cursor: not-allowed; }
#login-form .loader { width: 16px; height: 16px; border-width: 2px; }

#login-error { margin-top: 1rem; margin-bottom: 0; }

/* ─── Merchant door-history: table (tablet+) / cards (phone) ─── */
.mh-cards { display: none; }
.mh-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    margin-bottom: 0.75rem;
    background: rgba(255,255,255,0.02);
}
.mh-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.mh-card-device { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); }
.mh-card-row { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 0.25rem; }
.mh-card-label { color: var(--text-muted); }
.mh-card-time { margin-top: 0.5rem; font-size: 0.75rem; color: var(--text-muted); }

@media (max-width: 700px) {
    .mh-table-wrap { display: none; }
    .mh-cards { display: block; }
}

/* ─── Mobile ─── */
@media (max-width: 768px) {
    .main-content { padding: 1rem; }
    .sidebar {
        position: fixed;
        left: -100%;
        width: 280px;
        transition: left 0.28s cubic-bezier(0.4,0,0.2,1);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { left: 0; }
    .sidebar-header .close-sidebar { display: flex; }
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.875rem 1rem;
        background: var(--bg-base);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 40;
    }
    .hamburger-btn {
        background: transparent;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        padding: 4px;
    }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filters-container { flex-direction: column; }
    table { min-width: 600px; }
}
.mobile-header { display: none; }
@media (max-width: 768px) { .mobile-header { display: flex; } }
