/* ============================================================================
   DRAWAUTO CAD ENTERPRISE - RESPONSIVE DESIGN SYSTEM (RWD)
   Tối ưu hóa đa nền tảng: Ultrawide (2560x1080), Desktop, Laptop, Tablet, Mobile
   ============================================================================ */

/* ── 1. DESIGN TOKENS & CSS VARIABLES ── */
:root {
    --bg-main: #0b1120;
    --bg-card: #151f32;
    --bg-card-hover: #1c2b45;
    --bg-input: #070d19;
    --border: #26354d;
    --border-light: #3b4f6e;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.35);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --purple: #a855f7;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --tap-target: 42px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ── 2. GLOBAL RESET & BASE RULES ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-main);
    color: var(--text-primary);
    padding: 20px 24px;
    min-height: 100vh;
    line-height: 1.55;
    overflow-x: hidden;
}

img, svg {
    max-width: 100%;
    height: auto;
}

.hidden {
    display: none !important;
}

/* Tùy chỉnh thanh cuộn đẹp mắt cho Desktop */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #0b1120;
}
::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ── 3. RESPONSIVE CONTAINER & HEADER ── */
.app-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    transition: max-width 0.3s ease;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 22px;
    gap: 16px;
    flex-wrap: wrap;
}

.logo-group h1 {
    font-size: clamp(1.15rem, 2.5vw, 1.45rem);
    font-weight: 700;
    margin-top: 6px;
    letter-spacing: -0.3px;
    color: #fff;
}

.subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.user-meta b {
    color: #38bdf8;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-sec { background: rgba(59, 130, 246, 0.2); color: var(--primary); border: 1px solid var(--primary); }
.badge-success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.badge-info { background: rgba(14, 165, 233, 0.2); color: var(--info); }
.badge-sync-ok { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid #10b981; }
.badge-sync-pending { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid #f59e0b; }
.badge-bank { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; border: 1px solid #6366f1; border-radius: 4px; padding: 3px 6px; font-size: 0.75rem; display: inline-block; margin-top: 4px; }

/* ── 4. TOUCH-SWIPE RESPONSIVE TAB BAR ── */
.app-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.tab-btn {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.92rem;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: var(--tap-target);
}

.tab-btn:hover {
    background: var(--bg-card-hover);
    color: #fff;
    border-color: var(--border-light);
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 16px var(--primary-glow);
}

.tab-pane {
    display: none !important;
}

.tab-pane.active {
    display: block !important;
    animation: tabFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tabFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── 5. RESPONSIVE FORMS & CARDS ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(16px, 2.2vw, 26px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.card-header {
    margin-bottom: 20px;
}

.card h3 {
    font-size: clamp(1.1rem, 2vw, 1.25rem);
    color: var(--text-primary);
    font-weight: 700;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.88rem;
    margin-bottom: 7px;
    color: var(--text-secondary);
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: #fff;
    padding: 11px 15px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 16px; /* Chống auto-zoom trên iOS */
    min-height: var(--tap-target);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

textarea {
    min-height: 85px;
}

/* ── 6. RESPONSIVE GRID SYSTEMS ── */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 12px;
}

.version-inputs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 16px;
}

.security-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 24px;
}

/* Split grids cho Form trên màn hình máy tính */
.create-split-grid,
.extend-split-grid,
.verify-split-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.desktop-tips-card {
    background: #111c33;
    border: 1px solid #1e293b;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-top: 14px;
}

.desktop-tips-card h4 {
    color: #38bdf8;
    font-size: 0.92rem;
    margin-bottom: 8px;
}

.desktop-tips-card ul {
    margin: 8px 0 0 18px;
    font-size: 0.86rem;
    color: #94a3b8;
    line-height: 1.6;
}

.desktop-tips-card li {
    margin-bottom: 6px;
}

/* ── 7. BUTTONS & TOUCH TARGETS ── */
.btn {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 0.92rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--tap-target);
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }

.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; transform: translateY(-1px); }

.btn-secondary { background: #334155; color: #cbd5e1; }
.btn-secondary:hover { background: #475569; color: #fff; }

.btn-block { width: 100%; }
.btn-lg { width: 100%; padding: 13px 20px; font-size: 1rem; margin-top: 10px; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; min-height: 32px; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer; }
.btn-outline:hover { background: #334155; color: #fff; }

/* ── 8. DASHBOARD STAT CARDS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #151f32 0%, #0f172a 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.18);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.3);
    border-color: var(--border-light);
}

.stat-icon { font-size: 2rem; flex-shrink: 0; }
.stat-meta { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: 0.82rem; color: var(--text-secondary); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-val { font-size: clamp(1.3rem, 2.5vw, 1.75rem); font-weight: 700; color: #fff; }

.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }

/* ── 9. SEARCH & FILTER CONTROLS ── */
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.filter-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.select-filter { width: 220px; }
.filter-group input { width: 300px; }

/* Banner Thông Báo Thu Hồi Từ Xa */
.remote-revoke-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #172439;
    border: 1px solid #2e4363;
    border-radius: var(--radius-md);
    padding: 12px 18px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.banner-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 260px;
}

.banner-btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── 10. QUICK ACTION TOOLBAR ── */
.customer-quick-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #101a2e;
    border: 1px solid #1e2c45;
    border-radius: var(--radius-md);
    padding: 11px 16px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar-title {
    font-size: 0.86rem;
    color: #94a3b8;
    font-weight: 600;
    margin-right: 4px;
}

/* Action Buttons Trong Bảng */
.action-cell {
    display: flex;
    gap: 5px;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
}

.btn-act {
    padding: 6px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
    min-height: 32px;
}

.btn-act:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.btn-act-lock { background: #d97706; color: #fff; }
.btn-act-lock:hover { background: #b45309; }

.btn-act-revoke { background: #dc2626; color: #fff; }
.btn-act-revoke:hover { background: #991b1b; }

.btn-act-unlock { background: #16a34a; color: #fff; font-weight: 700; }
.btn-act-unlock:hover { background: #15803d; }

.btn-act-extend { background: #0284c7; color: #fff; }
.btn-act-extend:hover { background: #0369a1; }

.btn-act-edit { background: #475569; color: #fff; }
.btn-act-edit:hover { background: #334155; }

.btn-act-delete { background: #450a0a; color: #fca5a5; border: 1px solid #7f1d1d; }
.btn-act-delete:hover { background: #7f1d1d; color: #fff; }

/* ── 11. TABLE RESPONSIVENESS & ERGONOMICS ── */
.table-responsive {
    overflow-x: auto;
    position: relative;
    border-radius: var(--radius-md);
    background: #0b1120;
    border: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    min-width: 980px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}

.data-table th, .data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #1a273e;
    vertical-align: middle;
}

.data-table th {
    background: #172439;
    color: #94a3b8;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

/* Zebra Striping cho hàng chẵn/lẻ */
.data-table tbody tr:nth-child(even) td {
    background: rgba(21, 31, 50, 0.45);
}
.data-table tbody tr:nth-child(odd) td {
    background: rgba(11, 17, 32, 0.6);
}

.data-table tbody tr:hover td {
    background: rgba(59, 130, 246, 0.15) !important;
}

.data-table tbody tr:hover td:first-child {
    box-shadow: inset 4px 0 0 var(--primary);
}

/* Cột Thao Tác cố định bên phải trên màn hình Desktop thường */
.data-table th.col-actions,
.data-table td.col-actions {
    position: sticky;
    right: 0;
    background: #0e1728 !important;
    z-index: 5;
    box-shadow: -5px 0 12px rgba(0, 0, 0, 0.45);
    min-width: 330px;
    text-align: center;
}

.data-table th.col-actions {
    background: #172439 !important;
    z-index: 6;
    color: #38bdf8;
}

.data-table tr:hover td.col-actions {
    background: #152238 !important;
}

.mobile-table-hint {
    display: none;
    font-size: 0.8rem;
    color: #38bdf8;
    margin-bottom: 8px;
    padding: 6px 10px;
    background: rgba(56, 189, 248, 0.1);
    border-radius: 6px;
    border: 1px dashed rgba(56, 189, 248, 0.3);
}

/* ── 12. RESPONSIVE MODALS ── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 16px;
    overflow-y: auto;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(18px, 4vw, 28px);
    width: 100%;
    max-width: 520px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.65);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    margin: auto;
}

.modal-header h2 {
    font-size: clamp(1.15rem, 2.5vw, 1.3rem);
    color: var(--primary);
    margin-bottom: 8px;
}

.modal-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 18px;
}

/* ── 13. QUICK PRESET TILES ── */
.time-duration-box {
    background: #090f1d;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 18px;
}

.section-label {
    font-weight: 600;
    color: #38bdf8;
    font-size: 0.85rem;
    display: block;
    margin-bottom: 12px;
}

.quick-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 15px;
}

.preset-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-right: 4px;
}

.btn-preset, .btn-ext-preset, .btn-oe-preset {
    background: #172439;
    color: #93c5fd;
    border: 1px solid #2b456e;
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-preset:hover, .btn-ext-preset:hover, .btn-oe-preset:hover {
    background: #2563eb;
    color: #fff;
    border-color: #3b82f6;
    transform: translateY(-1px);
}

.calculated-preview-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px dashed var(--primary);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.highlight-date {
    font-weight: 700;
    color: #60a5fa;
    font-size: 1.05rem;
}

/* ── 14. RESULT BOXES & DISPLAY ── */
.result-box {
    margin-top: 22px;
    padding: 18px;
    background: #090f1d;
    border: 1px solid var(--success);
    border-radius: var(--radius-md);
}

.result-box h4 {
    color: var(--success);
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.key-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.key-display textarea {
    background: #020617;
    color: #00ff66;
    font-family: monospace;
    font-size: 0.92rem;
}

.verify-details {
    margin-top: 20px;
    padding: 16px;
    border-radius: var(--radius-sm);
}

.verify-details.success { background: rgba(16, 185, 129, 0.15); border: 1px solid var(--success); }
.verify-details.error { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--danger); color: var(--danger); }

.info-card-box {
    background: #101a2c;
    border: 1px solid #24354f;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-bottom: 16px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: 0.88rem;
}

.info-grid code {
    background: #000;
    padding: 2px 6px;
    border-radius: 4px;
    color: #38bdf8;
    word-break: break-all;
}

.serial-box {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #020617;
    border: 1px solid #1e293b;
    padding: 3px 6px;
    border-radius: 4px;
    max-width: 100%;
}

.serial-box code {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
    font-size: 0.8rem;
    color: #38bdf8;
}

.btn-copy-mini {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 0 4px;
    font-size: 0.8rem;
}

.btn-copy-mini:hover { color: #38bdf8; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.82rem; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-dot.online { background: #10b981; box-shadow: 0 0 8px #10b981; animation: pulse 2s infinite; }
.status-dot.offline { background: #64748b; }
.time-ago { font-size: 0.72rem; color: var(--text-secondary); display: block; margin-top: 2px; }

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.highlight-box {
    background: #070d19;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-all;
}

.hint-box {
    background: rgba(59, 130, 246, 0.08);
    border: 1px dashed #3b82f6;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.84rem;
    color: #93c5fd;
    line-height: 1.55;
}

/* Affiliate Guide & Links */
.aff-guide-box {
    background: rgba(23, 36, 57, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    font-size: 0.86rem;
    line-height: 1.6;
}

.aff-link-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 260px;
}

.aff-link-text {
    font-family: monospace;
    font-size: 0.78rem;
    background: #070d19;
    padding: 4px 6px;
    border-radius: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    border: 1px solid #1e293b;
    color: #38bdf8;
}

.btn-copy-link, .btn-reward-aff, .btn-edit-aff, .btn-delete-aff, .btn-payout-aff, .btn-sales-aff {
    padding: 5px 9px;
    font-size: 0.78rem;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    font-weight: 600;
    white-space: nowrap;
}

.btn-copy-link { background: #0284c7; color: #fff; }
.btn-copy-link:hover { background: #0369a1; }
.btn-reward-aff { background: #d97706; color: #fff; }
.btn-reward-aff:hover { background: #b45309; }
.btn-edit-aff { background: #334155; color: #cbd5e1; }
.btn-edit-aff:hover { background: #475569; color: #fff; }
.btn-delete-aff { background: #ef4444; color: #fff; }
.btn-delete-aff:hover { background: #dc2626; }
.btn-payout-aff { background: #10b981; color: #fff; }
.btn-payout-aff:hover { background: #059669; }
.btn-sales-aff { background: #6366f1; color: #fff; }
.btn-sales-aff:hover { background: #4f46e5; }

.price-text { font-family: monospace; font-weight: 700; color: #34d399; }
.commission-text { font-family: monospace; font-weight: 700; color: #f59e0b; }
.pending-text { font-family: monospace; font-weight: 700; color: #38bdf8; }

.file-list-box {
    background: #070d19;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    max-height: 240px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #1a273e;
    font-size: 0.85rem;
    gap: 10px;
    flex-wrap: wrap;
}

.file-item:last-child { border-bottom: none; }
.file-item-name { font-weight: 600; color: #f1f5f9; display: flex; align-items: center; gap: 8px; word-break: break-all; }
.file-item-meta { font-size: 0.78rem; color: #94a3b8; }
.file-item-actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn-dl-file {
    background: #10b981;
    color: #fff;
    padding: 5px 10px;
    font-size: 0.78rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
}
.btn-dl-file:hover { background: #059669; }

/* ── 15. FLOATING BACK TO TOP BUTTON ── */
#btn-back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#btn-back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

#btn-back-to-top:hover {
    background: var(--primary-hover);
    transform: translateY(-3px);
}

/* ============================================================================
   RESPONSIVE MEDIA QUERIES (RWD BREAKPOINTS)
   ============================================================================ */

/* ── MÀN HÌNH SIÊU RỘNG & 2K / 4K (ULTRAWIDE / 2560x1080: >= 1440px) ── */
@media (min-width: 1440px) {
    body {
        padding: 24px 32px;
    }

    /* Mở rộng tối đa container để tận dụng toàn bộ 2560px của màn Ultrawide */
    .app-container {
        max-width: 96vw !important;
    }

    /* Bảng dữ liệu tự động dàn trải 100% không còn bị thanh cuộn ngang chèn ép */
    .data-table {
        min-width: 100%;
        font-size: 0.92rem;
    }

    .data-table th, .data-table td {
        padding: 13px 16px;
    }

    /* Trên màn Ultrawide, bảng đã đủ chỗ hiển thị toàn bộ 9 cột nên bỏ hiệu ứng bóng mờ của cột sticky */
    .data-table th.col-actions,
    .data-table td.col-actions {
        position: static !important;
        box-shadow: none !important;
    }

    /* Thẻ thống kê dàn 5 cột đều tăm tắp thành dải Dashboard chỉ huy */
    .stats-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 18px;
    }

    .stat-card {
        padding: 18px 24px;
    }

    .stat-icon { font-size: 2.3rem; }
    .stat-val { font-size: 2rem; }

    /* Bố cục Split Grid 2 cột cho các Form trên màn Ultrawide */
    .create-split-grid,
    .extend-split-grid {
        display: grid;
        grid-template-columns: 1.35fr 1fr;
        gap: 32px;
        align-items: start;
    }

    .verify-split-grid {
        display: grid;
        grid-template-columns: 1.2fr 1fr;
        gap: 28px;
        align-items: start;
    }

    /* Thanh tìm kiếm và bộ lọc mở rộng tương xứng */
    .select-filter { width: 230px; }
    .filter-group input { width: 380px; }
}

/* ── MÀN HÌNH DESKTOP TIÊU CHUẨN (LAPTOPS / DESKTOPS: 1025px - 1439px) ── */
@media (min-width: 1025px) and (max-width: 1439px) {
    .app-container {
        max-width: 1360px;
    }

    .stats-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 14px;
    }

    .create-split-grid,
    .extend-split-grid,
    .verify-split-grid {
        display: grid;
        grid-template-columns: 1.25fr 1fr;
        gap: 24px;
        align-items: start;
    }
}

/* ── MÀN HÌNH MÁY TÍNH BẢNG (TABLET: 769px - 1024px) ── */
@media (min-width: 769px) and (max-width: 1024px) {
    body {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

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

    .version-inputs-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .create-split-grid,
    .extend-split-grid,
    .verify-split-grid {
        grid-template-columns: 1fr;
    }
}

/* ── MÀN HÌNH ĐIỆN THOẠI & PHABLET (TABLET NHỎ / PHONE: <= 860px) ── */
@media (max-width: 860px) {
    /* Cột thao tác trong bảng trên điện thoại không được sticky để tránh chiếm hết màn hình */
    .data-table th.col-actions,
    .data-table td.col-actions {
        position: static !important;
        box-shadow: none !important;
        background: inherit !important;
        min-width: 280px;
    }

    .mobile-table-hint {
        display: block;
    }

    .remote-revoke-banner {
        flex-direction: column;
        align-items: stretch;
    }

    .banner-btn-group {
        width: 100%;
    }

    .banner-btn-group button,
    .banner-btn-group a {
        flex: 1;
        text-align: center;
        justify-content: center;
    }
}

/* ── MÀN HÌNH ĐIỆN THOẠI THÔNG MINH (SMARTPHONES: <= 768px) ── */
@media (max-width: 768px) {
    body {
        padding: 12px 10px;
    }

    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 0;
    }

    .user-meta {
        justify-content: space-between;
        width: 100%;
        background: #111c33;
        padding: 8px 12px;
        border-radius: var(--radius-sm);
        border: 1px solid var(--border);
    }

    /* Thanh Tab cuộn ngang mượt mà kiểu Native App */
    .app-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        padding-bottom: 8px;
        margin-bottom: 16px;
        scrollbar-width: thin;
        scrollbar-color: #334155 transparent;
    }

    .app-tabs::-webkit-scrollbar {
        height: 4px;
    }

    .app-tabs::-webkit-scrollbar-thumb {
        background: #334155;
        border-radius: 4px;
    }

    .tab-btn {
        flex-shrink: 0;
        scroll-snap-align: start;
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    /* Bố cục Grid 2 cột & 3 cột tự động chuyển thành 1 cột */
    .grid-2,
    .grid-3,
    .info-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .version-inputs-grid {
        grid-template-columns: 1fr !important;
    }

    .security-settings-grid {
        grid-template-columns: 1fr !important;
    }

    /* Bảng Thống kê (Stat Cards) chia 2 cột đều đặn */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 12px 14px;
        gap: 10px;
    }

    .stat-icon {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .stat-val {
        font-size: 1.25rem;
    }

    /* Bộ lọc và Tìm kiếm trên Mobile */
    .card-header-flex {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .filter-group {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    .select-filter,
    .filter-group input {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Thanh thao tác nhanh (Toolbar) */
    .customer-quick-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .toolbar-actions {
        width: 100%;
        gap: 6px;
    }

    .toolbar-actions .btn-act {
        flex: 1 1 calc(50% - 6px);
        justify-content: center;
        min-height: 38px;
    }

    /* Nút chọn nhanh thời hạn (Presets) */
    .quick-presets {
        gap: 6px;
    }

    .btn-preset,
    .btn-ext-preset,
    .btn-oe-preset {
        flex: 1 1 calc(33.333% - 6px);
        min-width: 85px;
        font-size: 0.8rem;
    }

    /* Hộp thoại Modal tối ưu cho màn hình cảm ứng */
    .modal {
        padding: 10px;
        align-items: flex-end;
    }

    .modal-content {
        max-height: 88vh;
        padding: 18px 14px;
        border-radius: 16px 16px 8px 8px;
    }

    /* Các nút trong footer modal */
    .modal-content .grid-2 {
        display: flex !important;
        flex-direction: column-reverse;
        gap: 8px;
    }

    .modal-content .grid-2 button {
        width: 100%;
        min-height: 44px;
    }

    #btn-back-to-top {
        bottom: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
}

/* ── MÀN HÌNH ĐIỆN THOẠI CỠ NHỎ (EXTRA SMALL PHONES: <= 400px) ── */
@media (max-width: 400px) {
    body {
        padding: 8px 6px;
    }

    .card {
        padding: 14px 10px;
    }

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

    .btn-preset,
    .btn-ext-preset,
    .btn-oe-preset {
        flex: 1 1 calc(50% - 6px);
    }
}

/* ============================================================================
   CHẾ ĐỘ MÁY LẠ CHƯA CÓ TRONG DATABASE (UNREGISTERED ROWS & HIGHLIGHT)
   ============================================================================ */
.unregistered-row {
    background: rgba(239, 68, 68, 0.08) !important;
    border-left: 4px solid #ef4444 !important;
    transition: all 0.2s ease;
}

.unregistered-row:hover {
    background: rgba(239, 68, 68, 0.15) !important;
    box-shadow: inset 4px 0 0 #ef4444, 0 0 16px rgba(239, 68, 68, 0.25) !important;
}

.unregistered-row td {
    color: #f87171 !important;
}

.unregistered-row td b,
.unregistered-row td strong {
    color: #ef4444 !important;
}

.unregistered-row .serial-box code {
    color: #ef4444 !important;
    border: 1px solid rgba(239, 68, 68, 0.5) !important;
    background: rgba(239, 68, 68, 0.15) !important;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.2) !important;
}

.unregistered-row .badge-plan {
    background: rgba(239, 68, 68, 0.18) !important;
    border: 1px solid #ef4444 !important;
    color: #ef4444 !important;
    font-weight: bold !important;
}

.unregistered-row .badge-expiry {
    background: #dc2626 !important;
    color: #ffffff !important;
    border: 1px solid #ef4444 !important;
    font-weight: bold !important;
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.5) !important;
}

.version-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: bold;
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid #ef4444;
    padding: 2px 7px;
    border-radius: 4px;
    margin-top: 4px;
}

.version-indicator-normal {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #26354d;
    padding: 2px 7px;
    border-radius: 4px;
    margin-top: 4px;
}

.btn-register-db {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
    color: #ffffff !important;
    border: 1px solid #38bdf8 !important;
    font-weight: bold !important;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.4) !important;
    transition: all 0.2s ease !important;
}

.btn-register-db:hover {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%) !important;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.6) !important;
    transform: translateY(-1px);
}
