/* =========================================================
   WPS Card Key Management System - Global Stylesheet
   ========================================================= */

:root {
    --primary: #FF1C1F;
    --primary-dark: #FF4A04;
    --primary-gradient: linear-gradient(135deg, #FF1C1F 0%, #FF4A04 100%);

    --sidebar-bg-start: #1a1a2e;
    --sidebar-bg-end: #16213e;
    --sidebar-gradient: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);

    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --text-inverse: #ffffff;
    --border: #e5e7eb;
    --border-light: #f3f4f6;

    --success: #16a34a;
    --success-bg: #dcfce7;
    --error: #dc2626;
    --error-bg: #fee2e2;
    --info: #2563eb;
    --info-bg: #dbeafe;
    --warning: #d97706;
    --warning-bg: #fef3c7;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;

    --sidebar-width: 240px;
    --topbar-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--info);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== Scrollbar (webkit) ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35);
}

.sidebar ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* =========================================================
   Layout: Sidebar + Main
   ========================================================= */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-gradient);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo img {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.sidebar-logo .logo-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
    text-decoration: none;
}

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

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.75);
    font-size: 14px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    user-select: none;
}

.sidebar-nav .nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav .nav-item.active {
    background: rgba(255, 28, 31, 0.12);
    border-left-color: var(--primary);
    color: #fff;
    font-weight: 500;
}

.sidebar-nav .nav-item .nav-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.sidebar-footer {
    padding: 12px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar .page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.topbar .topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar .user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-light);
}

.topbar .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.content {
    padding: 24px;
    flex: 1;
}

/* Mobile sidebar toggle button */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text);
    cursor: pointer;
    padding: 4px 8px;
}

/* =========================================================
   Cards / Panels
   ========================================================= */
.card,
.panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.card + .card,
.panel + .panel,
.card + .panel,
.panel + .card {
    margin-top: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

/* =========================================================
   Stat Cards (Dashboard)
   ========================================================= */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-card .stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #fff;
    flex-shrink: 0;
}

.stat-card .stat-icon.total {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-card .stat-icon.used {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
}

.stat-card .stat-icon.unused {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.stat-card .stat-info {
    flex: 1;
    min-width: 0;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

/* =========================================================
   Tables
   ========================================================= */
.table-wrap {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.data-table thead th {
    background: #f9fafb;
    color: var(--text-light);
    font-weight: 600;
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    vertical-align: middle;
}

table.data-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

table.data-table tbody tr:hover {
    background: #fff5f5;
}

table.data-table tbody tr:last-child td {
    border-bottom: none;
}

.cell-link {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 13px;
    color: var(--info);
    word-break: break-all;
    max-width: 320px;
}

.cell-link input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 12px;
    color: var(--text);
    background: #fafbfc;
    cursor: text;
}

.cell-link input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
}

.cell-muted {
    color: var(--text-light);
}

.empty-row {
    text-align: center;
    color: var(--text-light);
    padding: 40px 14px !important;
}

/* =========================================================
   Badges
   ========================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-unused,
.badge-pending {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-used,
.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-failed {
    background: var(--error-bg);
    color: var(--error);
}

.badge-expired {
    background: var(--warning-bg);
    color: var(--warning);
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.15s;
    background: #fff;
    color: var(--text);
    border-color: var(--border);
    white-space: nowrap;
    user-select: none;
}

.btn:hover {
    text-decoration: none;
}

.btn:focus {
    outline: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    border-color: transparent;
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.92;
    color: #fff;
}

.btn-secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #d1d5db;
}

.btn-danger {
    background: #fff;
    color: var(--error);
    border-color: #fecaca;
}

.btn-danger:hover:not(:disabled) {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}

.btn-link {
    background: none;
    border: none;
    color: var(--info);
    padding: 4px 6px;
    cursor: pointer;
    font-size: 13px;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-link.danger {
    color: var(--error);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 13px;
}

.btn-lg {
    padding: 12px 22px;
    font-size: 15px;
}

.btn-block {
    width: 100%;
    display: flex;
}

/* =========================================================
   Forms
   ========================================================= */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-group .help-text {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 6px;
}

.form-control,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 28, 31, 0.12);
}

.form-control:disabled {
    background: #f3f4f6;
    color: var(--text-light);
    cursor: not-allowed;
}

.form-inline {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row > .form-group {
    flex: 1;
}

/* =========================================================
   Toolbar
   ========================================================= */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar .toolbar-left,
.toolbar .toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar .toolbar-right {
    margin-left: auto;
}

.search-box {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.search-box input {
    width: 260px;
    padding-left: 34px;
    border-radius: 999px;
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-light);
    font-size: 14px;
    pointer-events: none;
}

/* =========================================================
   Pagination
   ========================================================= */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-top: 1px solid var(--border-light);
    background: #fff;
    flex-wrap: wrap;
    gap: 10px;
}

.pagination .page-info {
    font-size: 13px;
    color: var(--text-light);
}

/* 每页大小选择器 */
.pagination .page-size-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-light);
}

.pagination .page-size-select {
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    line-height: 1.4;
}

.pagination .page-size-select:focus {
    outline: none;
    border-color: var(--primary);
}

.pagination .page-list {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
}

.pagination .page-list .page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pagination .page-list .page-btn:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #d1d5db;
}

.pagination .page-list .page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .page-list .page-btn.active {
    background: var(--primary-gradient);
    color: #fff;
    border-color: transparent;
}

/* =========================================================
   Modal
   ========================================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.15s ease-out;
}

.modal-box {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.2s ease-out;
}

/* 宽版弹窗：用于展示卡密链接列表等需要更宽空间的场景 */
.modal-box.modal-box-wide {
    max-width: 760px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--text-light);
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
}

.modal-close:hover {
    color: var(--text);
    background: #f3f4f6;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* =========================================================
   Toast Notifications
   ========================================================= */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fff;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 12px 14px;
    border-left: 4px solid var(--info);
    min-width: 280px;
    animation: toastIn 0.25s ease-out;
}

.toast.toast-success {
    border-left-color: var(--success);
}

.toast.toast-error {
    border-left-color: var(--error);
}

.toast.toast-info {
    border-left-color: var(--info);
}

.toast .toast-icon {
    font-size: 18px;
    line-height: 1.2;
    flex-shrink: 0;
}

.toast.toast-success .toast-icon { color: var(--success); }
.toast.toast-error .toast-icon { color: var(--error); }
.toast.toast-info .toast-icon { color: var(--info); }

.toast .toast-msg {
    flex: 1;
    font-size: 14px;
    color: var(--text);
    word-break: break-word;
}

.toast .toast-close {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}

.toast.toast-out {
    animation: toastOut 0.25s ease-in forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* =========================================================
   Login Page
   ========================================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 45%, #6b1010 100%);
}

.login-card {
    width: 360px;
    max-width: 100%;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    padding: 36px 28px 28px;
    text-align: center;
}

.login-card .login-logo {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    display: block;
}

.login-card .login-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.login-card .login-subtitle {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 24px;
}

.login-card .form-group {
    text-align: left;
}

.login-card .input-with-icon {
    position: relative;
}

.login-card .input-with-icon .input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 16px;
}

.login-card .input-with-icon input {
    padding-left: 38px;
}

.login-error {
    background: var(--error-bg);
    color: var(--error);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

.login-error.show {
    display: block;
}

/* =========================================================
   Customer Page
   ========================================================= */
.customer-page {
    min-height: 100vh;
    background: linear-gradient(180deg, #fff5f5 0%, #fff 60%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
}

.customer-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 28px 24px;
    text-align: center;
}

.customer-card .customer-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    display: block;
}

.customer-card .customer-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.customer-card .customer-subtitle {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 20px;
}

.card-key-box {
    background: #f9fafb;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 20px;
    font-family: "SFMono-Regular", Consolas, Menlo, monospace;
    font-size: 15px;
    color: var(--text);
    word-break: break-all;
}

.card-key-box .label {
    color: var(--text-light);
    font-size: 12px;
    margin-right: 6px;
}

/* Step indicator */
.steps {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    gap: 6px;
}

.steps .step {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-light);
    font-size: 13px;
}

.steps .step .step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e5e7eb;
    color: var(--text-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.steps .step.active .step-num {
    background: var(--primary-gradient);
    color: #fff;
}

.steps .step.done .step-num {
    background: var(--success);
    color: #fff;
}

.steps .step.active {
    color: var(--text);
    font-weight: 500;
}

.steps .step.done {
    color: var(--success);
}

.steps .step-line {
    width: 24px;
    height: 2px;
    background: #e5e7eb;
    border-radius: 1px;
}

.steps .step-line.done {
    background: var(--success);
}

.step-panel {
    display: none;
    text-align: left;
}

.step-panel.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

.step-panel .form-group {
    margin-bottom: 14px;
}

.phone-row {
    display: flex;
    gap: 8px;
}

.phone-row .form-control {
    flex: 1;
}

.phone-row .btn {
    flex-shrink: 0;
}

.code-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.code-row .form-control {
    flex: 1;
}

.code-row .btn {
    flex-shrink: 0;
    min-width: 110px;
}

.result-panel {
    text-align: center;
    padding: 20px 0;
}

.result-panel .result-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.result-panel.success .result-icon { color: var(--success); }
.result-panel.error .result-icon { color: var(--error); }
.result-panel.loading .result-icon {
    color: var(--info);
    animation: spin 1s linear infinite;
}

.result-panel .result-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}

.result-panel .result-desc {
    font-size: 13px;
    color: var(--text-light);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Floating tutorial button */
.tutorial-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    background: var(--primary-gradient);
    color: #fff;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(255, 28, 31, 0.4);
    cursor: pointer;
    text-decoration: none;
    z-index: 50;
    border: none;
    transition: transform 0.15s;
}

.tutorial-fab:hover {
    transform: translateY(-2px);
    text-decoration: none;
    color: #fff;
}

/* Region ranking bars */
.region-row {
    display: grid;
    grid-template-columns: 40px 1fr 80px;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
}

.region-row .rank {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #f3f4f6;
    color: var(--text-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.region-row.rank-1 .rank { background: #fef3c7; color: #d97706; }
.region-row.rank-2 .rank { background: #e5e7eb; color: #6b7280; }
.region-row.rank-3 .rank { background: #fee2e2; color: #b45309; }

.region-row .region-name {
    font-size: 14px;
    color: var(--text);
}

.region-row .bar-wrap {
    grid-column: 2 / 3;
    height: 8px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 2px;
}

.region-row .bar-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 4px;
    transition: width 0.4s ease-out;
}

.region-row .count {
    text-align: right;
    font-size: 13px;
    color: var(--text-light);
    font-variant-numeric: tabular-nums;
}

.region-table th,
.region-table td {
    padding: 10px 14px;
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 900px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 99;
    }

    .sidebar-backdrop.show {
        display: block;
    }

    .content {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    .search-box input {
        width: 100%;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar .toolbar-right {
        margin-left: 0;
    }

    .cell-link {
        max-width: 180px;
    }

    .topbar .user-chip span.username-text {
        display: none;
    }
}

@media (max-width: 480px) {
    .customer-card {
        padding: 22px 18px;
    }

    .login-card {
        padding: 28px 20px 22px;
    }

    .steps .step {
        font-size: 11px;
    }

    .steps .step-line {
        width: 12px;
    }
}
