/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Arial, sans-serif; font-size: 14px; color: #1e2a3a; background: #f0f2f5; }
a { color: #4a90e2; text-decoration: none; }
code { font-family: monospace; font-size: 12px; background: #f4f6f9; padding: 2px 6px; border-radius: 3px; }

/* ── Shell ────────────────────────────────────────────────────────────────── */
.admin-shell { display: flex; min-height: 100vh; }
.admin-main  { flex: 1; padding: 28px 32px; overflow-y: auto; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.admin-sidebar {
    width: 240px; flex-shrink: 0;
    background: #0f1923;
    color: #8a9bb0;
    display: flex; flex-direction: column;
}

.sidebar-brand {
    padding: 20px;
    font-size: 16px; font-weight: 700; color: #fff;
    border-bottom: 1px solid #1e2d3d;
    display: flex; align-items: center; gap: 10px;
}

.brand-icon { font-size: 20px; }

.sidebar-user-info {
    padding: 14px 20px;
    border-bottom: 1px solid #1e2d3d;
}

.user-name { font-size: 13px; font-weight: 600; color: #fff; margin-bottom: 4px; }
.user-role {
    display: inline-block; font-size: 10px; font-weight: 700;
    padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: .05em;
}
.role-superadmin { background: #4a90e2; color: #fff; }
.role-support     { background: #3b6d11; color: #eaf3de; }
.role-billing     { background: #854f0b; color: #faeeda; }

.sidebar-nav { list-style: none; flex: 1; padding: 10px 0; }

.sidebar-nav li a {
    display: block; padding: 9px 20px;
    color: #8a9bb0; font-size: 13px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav li a:hover { background: #1e2d3d; color: #fff; }

.nav-section {
    padding: 14px 20px 4px;
    font-size: 10px; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase;
    color: #3a5068;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid #1e2d3d;
}

.btn-logout {
    width: 100%; padding: 8px;
    background: #1e2d3d; border: 1px solid #2d4157;
    color: #8a9bb0; border-radius: 5px;
    cursor: pointer; font-size: 13px; margin-bottom: 8px;
}
.btn-logout:hover { background: #2d4157; color: #fff; }

.version-label { font-size: 10px; color: #3a5068; text-align: center; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 24px; flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; font-weight: 600; }
.welcome { font-size: 13px; color: #6b7c93; margin-left: auto; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
    background: #4a90e2; color: #fff; border: none;
    padding: 8px 18px; border-radius: 6px;
    cursor: pointer; font-size: 13px; font-weight: 600;
    transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: #357abd; }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary {
    background: #e8edf2; color: #333; border: 1px solid #cdd5de;
    padding: 8px 18px; border-radius: 6px;
    cursor: pointer; font-size: 13px;
}
.btn-secondary:hover { background: #d8e0ea; text-decoration: none; }

.btn-link   { background: none; border: none; color: #4a90e2; cursor: pointer; font-size: 13px; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.btn-danger { color: #e24b4a !important; }
.btn-danger:hover { text-decoration: underline; }

.full-width { width: 100%; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #555; margin-bottom: 5px; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: 9px 12px;
    border: 1px solid #cdd5de; border-radius: 6px;
    font-size: 13px; font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none; border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74,144,226,0.12);
}
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.toggle-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; font-size: 13px; }
.toggle-row input[type="checkbox"] { width: 16px; height: 16px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.panel-card, .section-card, .detail-card {
    background: #fff; border: 1px solid #dde3ec;
    border-radius: 10px; padding: 20px; margin-bottom: 20px;
}
.section-card h3, .detail-card h3 { font-size: 15px; margin-bottom: 14px; color: #1e2a3a; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: #eaf3de; border: 1px solid #b8dba0; color: #3b6d11; }
.alert-error   { background: #fdecea; border: 1px solid #f5c6c6; color: #a32d2d; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.admin-table {
    width: 100%; border-collapse: collapse;
    background: #fff; border: 1px solid #dde3ec;
    border-radius: 10px; overflow: hidden;
    font-size: 13px; margin-bottom: 20px;
}
.admin-table th {
    background: #f4f6f9; padding: 10px 14px; text-align: left;
    font-size: 11px; font-weight: 700; color: #6b7c93;
    letter-spacing: .04em; text-transform: uppercase;
    border-bottom: 1px solid #dde3ec;
}
.admin-table td { padding: 11px 14px; border-bottom: 1px solid #f0f2f5; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #f8f9fb; }

/* ── Metrics dashboard ────────────────────────────────────────────────────── */
.metrics-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
    gap: 16px; margin-bottom: 24px;
}
.metric-card {
    border-radius: 10px; padding: 20px; color: #fff;
    cursor: pointer; transition: opacity 0.15s;
}
.metric-card:hover { opacity: 0.9; }
.metric-card.blue   { background: linear-gradient(135deg, #4a90e2, #357abd); }
.metric-card.green  { background: linear-gradient(135deg, #52c41a, #389e0d); }
.metric-card.orange { background: linear-gradient(135deg, #fa8c16, #d46b08); }
.metric-card.purple { background: linear-gradient(135deg, #722ed1, #531dab); }
.metric-value { font-size: 32px; font-weight: 700; line-height: 1; margin-bottom: 6px; }
.metric-label { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.metric-sub   { font-size: 11px; opacity: 0.8; }

/* ── Tier breakdown ───────────────────────────────────────────────────────── */
.tier-grid { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.tier-stat  { display: flex; align-items: center; gap: 8px; }
.tier-count { font-size: 18px; font-weight: 700; color: #1e2a3a; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.tier-badge {
    display: inline-block; padding: 3px 10px;
    border-radius: 12px; font-size: 11px; font-weight: 600;
}
.tier-free      { background: #f0f2f5; color: #6b7c93; }
.tier-pro500    { background: #e6f1fb; color: #185fa5; }
.tier-pro1000   { background: #eaf3de; color: #3b6d11; }
.tier-pro3000   { background: #faeeda; color: #854f0b; }
.tier-pro5000   { background: #ede8fb; color: #5a2d91; }
.tier-unlimited { background: #0f1923; color: #fff; }

.status-badge {
    display: inline-block; padding: 3px 10px;
    border-radius: 12px; font-size: 11px; font-weight: 600;
}
.status-open       { background: #e6f1fb; color: #185fa5; }
.status-inprogress { background: #faeeda; color: #854f0b; }
.status-resolved   { background: #eaf3de; color: #3b6d11; }
.status-closed     { background: #f0f2f5; color: #6b7c93; }

.priority-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.priority-low      { background: #f0f2f5; color: #6b7c93; }
.priority-normal   { background: #e6f1fb; color: #185fa5; }
.priority-high     { background: #faeeda; color: #854f0b; }
.priority-critical { background: #fcebeb; color: #a32d2d; }

.status-dot {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 600;
}
.status-dot::before { content: "●"; font-size: 8px; }
.status-dot.active   { color: #3b6d11; }
.status-dot.active::before { color: #52c41a; }
.status-dot.inactive { color: #a32d2d; }
.status-dot.inactive::before { color: #e24b4a; }

.role-badge {
    display: inline-block; padding: 3px 10px;
    border-radius: 12px; font-size: 11px; font-weight: 600;
}
.role-superadmin { background: #e6f1fb; color: #185fa5; }
.role-support    { background: #eaf3de; color: #3b6d11; }
.role-billing    { background: #faeeda; color: #854f0b; }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-container {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: #0f1923;
}
.login-card {
    background: #fff; border-radius: 12px;
    padding: 40px; width: 100%; max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-icon   { font-size: 36px; margin-bottom: 12px; }
.login-header h2 { font-size: 22px; margin-bottom: 6px; }
.login-header p  { font-size: 13px; color: #6b7c93; }
.otp-hint { font-size: 13px; color: #6b7c93; margin-bottom: 16px; }
.otp-input { font-size: 24px !important; letter-spacing: 6px; text-align: center; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input { padding: 7px 10px; border: 1px solid #cdd5de; border-radius: 6px; font-size: 13px; }
.text-muted { font-size: 12px; color: #6b7c93; }
.loading    { padding: 40px; text-align: center; color: #6b7c93; }
.empty      { color: #6b7c93; font-size: 13px; padding: 12px 0; }
.info-row   { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0f2f5; font-size: 13px; }
.info-row label { font-weight: 600; color: #6b7c93; min-width: 130px; }
.description-box { background: #f8f9fb; border-radius: 6px; padding: 14px; font-size: 13px; line-height: 1.7; margin-top: 14px; white-space: pre-wrap; }

.reply { border-radius: 8px; padding: 14px; margin-bottom: 10px; }
.reply-admin    { background: #e6f1fb; border-left: 3px solid #4a90e2; }
.reply-customer { background: #f4f6f9; border-left: 3px solid #cdd5de; }
.reply-header   { display: flex; justify-content: space-between; font-size: 12px; color: #6b7c93; margin-bottom: 8px; }
.reply-body     { font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.reply-form textarea { width: 100%; padding: 10px; border: 1px solid #cdd5de; border-radius: 6px; font-family: inherit; font-size: 13px; resize: vertical; margin: 12px 0; }

.activity-type {
    display: inline-block; padding: 2px 8px;
    border-radius: 10px; font-size: 10px; font-weight: 700;
    background: #e6f1fb; color: #185fa5; text-transform: uppercase;
}

/* ── AppConfig Crypto ─────────────────────────────────────────────────────── */
.appconfig-crypto-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 1100px) {
    .appconfig-crypto-grid { grid-template-columns: 1fr; }
}

/* ── License Settings page ────────────────────────────────────────────────── */
.code-textarea {
    width: 100%;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    padding: 12px;
    border: 1px solid #d2d6dc;
    border-radius: 6px;
    background: #f8f9fa;
    color: #333;
    resize: vertical;
    box-sizing: border-box;
}

/* ── Two-Factor Authentication ──────────────────────────────────────────── */
.input-totp {
    letter-spacing: 6px;
    font-size: 20px;
    text-align: center;
    font-family: "Courier New", monospace;
}

.totp-qr-wrap {
    display: flex;
    justify-content: center;
    margin: 18px 0;
    padding: 16px;
    background: #fff;
    border: 1px solid #e4e8ee;
    border-radius: 8px;
}
.totp-qr { width: 200px; height: 200px; }

.totp-manual { margin-top: 8px; font-size: 13px; }
.totp-manual summary { cursor: pointer; color: #2f6fed; }
.totp-secret {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 10px;
    background: #f2f4f8;
    border-radius: 6px;
    font-family: "Courier New", monospace;
    letter-spacing: 1px;
    word-break: break-all;
}

.totp-enabled-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: #ecf7ee;
    border: 1px solid #bfe3c6;
    border-radius: 8px;
    margin-bottom: 18px;
}
.totp-enabled-icon { font-size: 28px; }
.totp-enabled-banner p { margin: 2px 0 0; font-size: 13px; color: #4a6b50; }

.action-row { display: flex; gap: 10px; margin-top: 16px; }
.btn-ghost {
    background: transparent;
    border: 1px solid #cbd3df;
    color: #51607a;
    padding: 9px 16px;
    border-radius: 6px;
    cursor: pointer;
}
.btn-ghost:hover { background: #f2f4f8; }

.totp-on-badge { color: #36b37e; font-size: 10px; margin-left: 6px; vertical-align: middle; }
