:root {
    --bg: #0d111c;
    --bg-2: #10141f;
    --surface: #171d2b;
    --surface-2: #1f2736;
    --border: #2a3244;
    --text: #e9ecf3;
    --muted: #8b95a7;
    --accent: #5b8cff;
    --accent-2: #7f6bff;
    --accent-dark: #3a6fd6;
    --ok: #35c17a;
    --err: #e6534d;
    --warn: #e6a83d;
    --radius: 12px;
    --tg: #29a9eb;
    --tg-dark: #1e96d4;
    --shadow-card: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 20px rgba(0,0,0,0.22);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

::selection { background: rgba(91,140,255,0.35); color: #fff; }

/* Doly ekranly ýumşak arka fon gradienti */
body {
    margin: 0;
    background:
        radial-gradient(1100px 480px at 15% -10%, rgba(91,140,255,0.10), transparent 60%),
        radial-gradient(900px 460px at 100% 0%, rgba(127,107,255,0.08), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    animation: page-fade-in 0.35s ease;
}

/* Skrollbar (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

@keyframes page-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    background: rgba(23,29,43,0.72);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-wrap: wrap;
    gap: 10px;
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
}

.logo {
    font-weight: 800;
    font-size: 1.12rem;
    letter-spacing: -0.01em;
    background: linear-gradient(120deg, var(--text) 30%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.logo:active { transform: scale(0.97); }

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px;
    width: 100%;
}

h1 { font-size: 1.6rem; margin-bottom: 6px; }
h2 { font-size: 1.2rem; margin-top: 32px; }

.muted { color: var(--muted); font-size: 0.9rem; }

.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn:active { transform: scale(0.96); }
.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(91,140,255,0.25);
}
.btn-accent:hover { filter: brightness(1.08); box-shadow: 0 6px 18px rgba(91,140,255,0.4); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: white; }
.btn-danger { background: transparent; border-color: var(--err); color: var(--err); }
.btn-danger:hover { background: var(--err); color: white; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow-card);
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
    animation: card-pop-in 0.35s ease backwards;
}
.card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 12px 28px rgba(0,0,0,0.32); }
.card:active { transform: translateY(-1px) scale(0.99); }

@keyframes card-pop-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.grid .card:nth-child(1) { animation-delay: 0.02s; }
.grid .card:nth-child(2) { animation-delay: 0.06s; }
.grid .card:nth-child(3) { animation-delay: 0.10s; }
.grid .card:nth-child(4) { animation-delay: 0.14s; }
.grid .card:nth-child(5) { animation-delay: 0.18s; }
.grid .card:nth-child(6) { animation-delay: 0.22s; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.server-name { font-weight: 600; }

.badge {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 600;
}
.badge-ok { background: rgba(53,193,122,0.15); color: var(--ok); }
.badge-err { background: rgba(230,83,77,0.15); color: var(--err); }
.badge-muted { background: rgba(139,149,167,0.15); color: var(--muted); }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 480px;
}
.form-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--muted);
}
.form-row { display: flex; gap: 12px; }
.form-row label { flex: 1; }

input[type="text"], input[type="password"], input[type="number"] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 10px;
    color: var(--text);
    font-size: 0.95rem;
    width: 100%;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,140,255,0.18); }

.hint { font-size: 0.82rem; color: var(--muted); }

.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
    animation: flash-in 0.3s ease;
}

@keyframes flash-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.flash-success { background: rgba(53,193,122,0.12); color: var(--ok); border: 1px solid rgba(53,193,122,0.3); }
.flash-danger { background: rgba(230,83,77,0.12); color: var(--err); border: 1px solid rgba(230,83,77,0.3); }
.flash-warning { background: rgba(230,168,61,0.12); color: var(--warn); border: 1px solid rgba(230,168,61,0.3); }
.flash-info { background: rgba(79,140,255,0.12); color: var(--accent); border: 1px solid rgba(79,140,255,0.3); }

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.actions-row { display: flex; gap: 10px; margin: 16px 0; }

.inline-form { display: flex; gap: 10px; margin: 16px 0; }
.inline-form input { flex: 1; }

hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}
.table th, .table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.actions-col { display: flex; gap: 6px; }

.inline-change-server { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.inline-change-server select {
    padding: 6px 8px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm, 6px);
    border: 1px solid var(--border);
    background: var(--surface);
    color: inherit;
    max-width: 150px;
}

.code-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    overflow-x: auto;
    font-size: 0.82rem;
    white-space: pre-wrap;
    word-break: break-all;
}

.footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.8rem;
    padding: 24px;
}

/* ---- Gurnama progress bar ---- */
.progress-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin: 4px 0 16px;
}
.progress-top {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    margin-bottom: 8px;
    color: var(--text);
}
.progress-bar-outer {
    width: 100%;
    height: 12px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.progress-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #7cb2ff, var(--accent));
    background-size: 200% 100%;
    width: 0%;
    transition: width 0.4s ease;
    animation: bar-shimmer 1.6s linear infinite;
}

@keyframes bar-shimmer {
    0% { background-position: 0% 0; }
    100% { background-position: -200% 0; }
}
.install-log {
    margin-top: 12px;
    max-height: 220px;
    font-size: 0.75rem;
}

/* ---- Klent ulanyş mini-bar ---- */
.usage-cell { min-width: 130px; }
.usage-text { font-size: 0.82rem; margin-bottom: 4px; white-space: nowrap; }
.mini-bar {
    width: 100%;
    height: 6px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.mini-bar-inner {
    height: 100%;
    background: var(--accent);
}
.mini-bar-danger { background: var(--err); }

/* ---- Serwer sazlama kartasy ---- */
.settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 10px;
}
.settings-card summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
}
.settings-card .inline-form { margin-top: 12px; align-items: flex-end; }
.inline-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}

.client-form { max-width: none; }
.checkbox-label {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

/* ---- Subscription link ---- */
.sub-link-row {
    display: flex;
    gap: 8px;
    margin: 12px 0 24px;
}
.sub-link-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 10px;
    color: var(--text);
    font-size: 0.85rem;
}

/* ---- Nawigasiýa (giriş edenden soň) ---- */
.topbar-nav { display: flex; gap: 8px; align-items: center; }

/* ---- Onlaýn/oflayn nokat ---- */
.online-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.online-dot-on { background: var(--ok); box-shadow: 0 0 6px var(--ok); animation: dot-pulse 1.8s ease-in-out infinite; }
.online-dot-off { background: var(--muted); }

@keyframes dot-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(53,193,122,0.5); }
    50% { box-shadow: 0 0 0 4px rgba(53,193,122,0); }
}

/* ---- Textarea (SSH açary ýapyşdyrmak üçin) ---- */
textarea, select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 10px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    width: 100%;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,140,255,0.18); }
.mono-textarea { font-family: "SFMono-Regular", Consolas, Menlo, monospace; font-size: 0.78rem; resize: vertical; }

/* ---- SSH açar çeşme saýlaýjy (goýma / faýl saýla) ---- */
.key-source-tabs {
    display: flex;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 8px;
}
.key-source-tab {
    flex: 1;
    text-align: center;
    padding: 7px 8px;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--muted);
    border: 1px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
    user-select: none;
}
.key-source-tab.active { background: var(--surface-2); color: var(--text); border-color: var(--border); font-weight: 600; }

.file-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    border: 1.5px dashed var(--border);
    border-radius: 8px;
    padding: 22px 14px;
    cursor: pointer;
    background: var(--bg);
    transition: border-color 0.15s ease, background 0.15s ease;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--accent); background: rgba(79,140,255,0.06); }
.file-drop input[type="file"] { display: none; }
.file-drop .file-drop-icon { font-size: 1.6rem; }
.file-drop .file-drop-text { font-size: 0.85rem; color: var(--muted); }
.file-drop .file-drop-name { font-size: 0.85rem; color: var(--ok); font-weight: 600; word-break: break-all; }

/* ---- Admin serwer saýlama gözenegi ---- */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

/* ---- Giriş sahypasy ---- */
.login-wrap { max-width: 380px; margin: 40px auto; }
.login-wrap .form-card { max-width: none; }

.text-danger { color: var(--err); font-weight: 600; }

/* input[type=date] ownadyş görnüşi */
input[type="date"] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 10px;
    color: var(--text);
    font-size: 0.9rem;
    width: 100%;
}
input[type="date"]:focus { outline: none; border-color: var(--accent); }

/* ---------------------------------------------------------------------- */
/* ---- Telegram goldaw düwmesi (ähli sahypalarda ýüzýän düwme) ---------- */
/* ---------------------------------------------------------------------- */
.support-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 999;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: linear-gradient(135deg, var(--tg), var(--tg-dark));
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 12px 18px 12px 14px;
    border-radius: 999px;
    box-shadow: 0 8px 22px rgba(41,169,235,0.45), 0 0 0 0 rgba(41,169,235,0.5);
    animation: support-pulse 2.6s ease-in-out infinite;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.support-fab:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 12px 28px rgba(41,169,235,0.55); }
.support-fab:active { transform: translateY(0) scale(0.97); }
.support-fab svg { width: 22px; height: 22px; flex-shrink: 0; }
.support-fab-text { white-space: nowrap; }

@keyframes support-pulse {
    0%, 100% { box-shadow: 0 8px 22px rgba(41,169,235,0.45), 0 0 0 0 rgba(41,169,235,0.45); }
    50% { box-shadow: 0 8px 22px rgba(41,169,235,0.45), 0 0 0 8px rgba(41,169,235,0); }
}

/* ---------------------------------------------------------------------- */
/* ---- Mobil / kiçi ekranlar üçin stabilizasiýa ------------------------- */
/* ---------------------------------------------------------------------- */
@media (max-width: 720px) {
    .topbar { padding: 12px 14px; }
    .logo { font-size: 1rem; }
    .topbar-nav { width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 6px; }
    .topbar-nav .btn { flex: 1 1 auto; text-align: center; padding: 9px 10px; font-size: 0.85rem; }

    .container { padding: 18px 12px 90px; }

    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.05rem; margin-top: 24px; }

    .grid { grid-template-columns: 1fr; gap: 12px; }

    .form-card { max-width: 100%; padding: 16px; gap: 14px; }
    .form-row { flex-direction: column; gap: 14px; }

    .detail-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .actions-row { flex-direction: column; align-items: stretch; }
    .actions-row .btn, .actions-row form { width: 100%; }
    .actions-row form button { width: 100%; }

    .inline-form { flex-direction: column; align-items: stretch; }
    .sub-link-row { flex-direction: column; }

    .checkbox-grid { grid-template-columns: 1fr; }

    /* Tablisalary mobilde skroll bilen okalýan görnüşe getirýäris */
    .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius);
        border: 1px solid var(--border);
    }
    .table-scroll .table { border: none; border-radius: 0; min-width: 640px; }

    .actions-col {
        flex-wrap: wrap;
    }
    .actions-col form, .actions-col a, .actions-col button { flex: 0 0 auto; }

    .support-fab { right: 14px; bottom: 14px; padding: 12px; border-radius: 50%; }
    .support-fab-text { display: none; }

    .code-block { font-size: 0.75rem; padding: 12px; }
}

@media (max-width: 420px) {
    .topbar-nav .btn span.btn-label-full { display: none; }
}
