/* ===== CSS Variables (Shadcn Light Theme Base) ===== */
:root {
    --background: #ffffff;
    --foreground: #09090b;

    --muted: #f4f4f5;
    --muted-foreground: #71717a;

    --popover: #ffffff;
    --popover-foreground: #09090b;

    --card: #ffffff;
    --card-foreground: #09090b;

    --border: #e4e4e7;
    --input: #e4e4e7;

    --primary: #18181b;
    --primary-foreground: #fafafa;
    --primary-hover: #27272a;

    --secondary: #f4f4f5;
    --secondary-foreground: #18181b;
    --secondary-hover: #e4e4e7;

    --destructive: #ef4444;
    --destructive-foreground: #fafafa;
    --destructive-hover: #dc2626;

    --ring: #18181b;

    --radius: 0.5rem;
    --radius-sm: 0.375rem;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --md-surface: #f8f7fb;
    --md-surface-container: #ffffff;
    --md-surface-container-high: #f3f0f7;
    --md-primary: #4f46e5;
    --md-on-primary: #ffffff;
    --md-outline: #d6d0e3;
    --md-shadow: 0 12px 30px rgb(15 23 42 / 0.12);
    --touch-target: 44px;
    --mobile-nav-height: 74px;
    --mobile-page-padding: 1rem;
}

/* Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--muted);
    /* Light gray background for contrast */
    color: var(--foreground);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 0.875rem;
}

.hidden {
    display: none !important;
}

.page {
    min-height: 100vh;
}

.text-muted {
    color: var(--muted-foreground);
}

.font-medium {
    font-weight: 500;
}

.mx-2 {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
}

.mt-1 {
    margin-top: 0.25rem;
}

.mt-4 {
    margin-top: 1rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-right {
    text-align: right;
}

.text-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8125rem;
}

/* Lucide Icons */
.lucide {
    stroke-width: 2;
    width: 20px;
    height: 20px;
}

.icon-sm {
    width: 14px;
    height: 14px;
}

/* Typography */
h1,
h2,
h3 {
    font-weight: 600;
    letter-spacing: -0.025em;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

input[type="text"],
input[type="password"],
select {
    display: flex;
    width: 100%;
    height: 2.25rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--input);
    background: var(--background);
    color: var(--foreground);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input::placeholder {
    color: var(--muted-foreground);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 1px var(--ring);
}

.help-text {
    font-size: 0.8rem;
    color: var(--muted-foreground);
    margin-top: 0.375rem;
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    padding-right: 2rem;
    cursor: pointer;
}

.select-arrow {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--muted-foreground);
    width: 16px;
    height: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    height: 2.25rem;
    padding: 0 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-outline {
    background-color: var(--background);
    border-color: var(--input);
    color: var(--foreground);
}

.btn-outline:hover {
    background-color: var(--muted);
}

.btn-ghost {
    background-color: transparent;
    color: var(--foreground);
}

.btn-ghost:hover {
    background-color: var(--muted);
}

.btn-danger {
    background-color: transparent;
    color: var(--destructive);
}

.btn-danger:hover {
    background-color: #fee2e2;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    height: 1.75rem;
    padding: 0 0.5rem;
    font-size: 0.75rem;
}

/* Login */
#login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--muted);
}

.login-container {
    width: 100%;
    max-width: 380px;
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-sm);
}

.login-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 2rem;
}

.brand-logo {
    margin-bottom: 1rem;
    width: 32px;
    height: 32px;
}

.login-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

/* Navbar */
.top-nav {
    border-bottom: 1px solid var(--border);
    background-color: var(--background);
    height: 56px;
}

.nav-container {
    max-width: 1024px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
}

.brand-logo-small {
    width: 20px;
    height: 20px;
    margin-right: 0.5rem;
}

/* Dashboard Content */
.dashboard-main {
    max-width: 1024px;
    margin: 0 auto;
    padding: 2.5rem 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.875rem;
    margin-bottom: 0.25rem;
}

/* Table */
.table-container {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

#user-table {
    width: 100%;
    border-collapse: collapse;
}

#user-table th {
    background-color: var(--background);
    color: var(--muted-foreground);
    font-weight: 500;
    text-align: left;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
}

#user-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

#user-table tbody tr:last-child td {
    border-bottom: none;
}

#user-table tbody tr:hover {
    background-color: var(--muted);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    border: 1px solid transparent;
}

.badge-active {
    background-color: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.badge-banned {
    background-color: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.action-cell {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 460px;
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.125rem;
}

.modal-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    background: transparent;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background-color: var(--muted);
    color: var(--foreground);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background-color: var(--muted);
    border-top: 1px solid var(--border);
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

/* Detail Modal specific */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground);
}

.detail-value {
    font-size: 0.875rem;
    word-break: break-all;
}

.token-well {
    background-color: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-top: 0.5rem;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.875rem 1rem;
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    min-width: 250px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-success::before {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981;
}

.toast-error::before {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ef4444;
}

.toast-fade-out {
    animation: fadeOut 0.3s forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Responsive adjustments */
@media (max-width: 1048px) {

    .dashboard-main,
    .nav-container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* ===== Tab Navigation ===== */
.tab-nav {
    border-bottom: 1px solid var(--border);
    background-color: var(--background);
}

.tab-nav-container {
    max-width: 1024px;
    margin: 0 auto;
    display: flex;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted-foreground);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
    font-family: inherit;
}

.tab-item:hover {
    color: var(--foreground);
}

.tab-item.active {
    color: var(--foreground);
    border-bottom-color: var(--foreground);
}

/* Content Sections */
.content-section {
    /* visible by default unless .hidden */
}

/* Placeholder Cards */
.placeholder-card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.placeholder-card h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.placeholder-icon {
    width: 40px;
    height: 40px;
    color: var(--muted-foreground);
    margin-bottom: 1rem;
}

/* Role Badge */
.badge-role {
    font-size: 0.6875rem;
    padding: 0.125rem 0.5rem;
    margin-right: 0.5rem;
}

.badge-role-super {
    background-color: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.badge-role-regular {
    background-color: #dbeafe;
    color: #1e40af;
    border-color: #bfdbfe;
}

/* Nav actions alignment */
.nav-actions {
    display: flex;
    align-items: center;
}

/* Tab nav responsive */
@media (max-width: 1048px) {
    .tab-nav-container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Card */
.card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.p-6 {
    padding: 1.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-6 {
    margin-top: 1.5rem;
}

.text-lg {
    font-size: 1.125rem;
}

/* Inline form (input + button side by side) */
.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.inline-form input {
    flex: 0 0 auto;
}

.user-filter-card {
    margin-bottom: 1rem;
}

.filter-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-field {
    min-width: 180px;
    flex: 1 1 180px;
}

.filter-field-keyword {
    min-width: 260px;
    flex: 2 1 280px;
}

.filter-field label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.filter-actions {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.pagination-info {
    font-size: 0.875rem;
}

.pagination-actions {
    display: flex;
    gap: 0.75rem;
}

.table-empty {
    text-align: center;
    color: var(--muted-foreground);
    padding: 1.25rem;
}

.hwid-value {
    display: inline-block;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Textarea */
textarea:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 1px var(--ring);
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--input);
    transition: 0.2s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Flex utility for toggle rows */
.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.py-3 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

/* Cloud file table */
#cloudfile-table {
    width: 100%;
    border-collapse: collapse;
}

#cloudfile-table th {
    background-color: var(--background);
    color: var(--muted-foreground);
    font-weight: 500;
    text-align: left;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
}

#cloudfile-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

#cloudfile-table tbody tr:last-child td {
    border-bottom: none;
}

#cloudfile-table tbody tr:hover {
    background-color: var(--muted);
}

/* 通用表格样式（卡密、日志、管理员、备份、HWID重置等） */
#cardkey-table,
#logs-table,
#admin-table,
#backup-table,
#hwid-reset-table {
    width: 100%;
    border-collapse: collapse;
}

#cardkey-table th,
#logs-table th,
#admin-table th,
#backup-table th,
#hwid-reset-table th {
    background-color: var(--background);
    color: var(--muted-foreground);
    font-weight: 500;
    text-align: left;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
}

#cardkey-table td,
#logs-table td,
#admin-table td,
#backup-table td,
#hwid-reset-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

#cardkey-table tbody tr:last-child td,
#logs-table tbody tr:last-child td,
#admin-table tbody tr:last-child td,
#backup-table tbody tr:last-child td,
#hwid-reset-table tbody tr:last-child td {
    border-bottom: none;
}

#cardkey-table tbody tr:hover,
#logs-table tbody tr:hover,
#admin-table tbody tr:hover,
#backup-table tbody tr:hover,
#hwid-reset-table tbody tr:hover {
    background-color: var(--muted);
}

/* 日志结果颜色 */
.text-success {
    color: #10b981;
}

.text-danger {
    color: #ef4444;
}

/* 普通用户角色 badge */
.badge-role-user {
    background-color: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}

/* 子标签样式 */
.sub-tabs-container {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 0;
}

.sub-tab-item {
    padding: 10px 20px;
    background: transparent;
    color: var(--muted-foreground);
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    transition: color 0.2s, border-color 0.2s;
}

.sub-tab-item:hover {
    color: var(--foreground);
}

.sub-tab-item.active {
    color: var(--foreground);
    border-bottom-color: var(--foreground);
}

.ui-mode-switcher,
.ui-mode-inline {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.ui-mode-label {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.ui-mode-select-wrapper {
    min-width: 112px;
}

.ui-mode-select {
    min-width: 112px;
}

.mobile-bottom-nav,
.mobile-nav-drawer,
.mobile-nav-backdrop {
    display: none;
}

body.drawer-open,
body.modal-open {
    overflow: hidden;
}

body.mobile-mode {
    background: var(--md-surface);
}

body.mobile-mode .page {
    min-height: 100dvh;
}

body.mobile-mode #login-page {
    padding: 1.25rem;
    align-items: stretch;
}

body.mobile-mode .login-container {
    max-width: 100%;
    border-radius: 1.5rem;
    padding: 2rem 1.25rem;
    margin: auto 0;
    background: var(--md-surface-container);
    border-color: var(--md-outline);
    box-shadow: var(--md-shadow);
}

body.mobile-mode .login-header {
    margin-bottom: 1.5rem;
}

body.mobile-mode .login-title {
    font-size: 1.75rem;
}

body.mobile-mode input[type="text"],
body.mobile-mode input[type="password"],
body.mobile-mode select,
body.mobile-mode textarea,
body.mobile-mode .btn {
    min-height: var(--touch-target);
}

body.mobile-mode .btn-block {
    width: 100%;
}

body.mobile-mode .top-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    padding: 0.875rem 0;
    background: rgb(248 247 251 / 0.92);
    backdrop-filter: blur(16px);
}

body.mobile-mode .nav-container {
    padding-left: var(--mobile-page-padding);
    padding-right: var(--mobile-page-padding);
    gap: 0.75rem;
    align-items: flex-start;
    flex-direction: column;
}

body.mobile-mode .nav-brand {
    width: 100%;
    justify-content: space-between;
}

body.mobile-mode .nav-brand .text-muted.mx-2,
body.mobile-mode .nav-brand .text-muted:last-child {
    display: none;
}

body.mobile-mode .nav-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.5rem;
    align-items: end;
}

body.mobile-mode .ui-mode-switcher {
    min-width: 0;
}

body.mobile-mode .ui-mode-select-wrapper,
body.mobile-mode .ui-mode-select {
    min-width: 0;
    width: 100%;
}

body.mobile-mode .tab-nav {
    display: none;
}

body.mobile-mode .dashboard-main {
    max-width: 100%;
    padding: 1rem var(--mobile-page-padding) calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 1.25rem);
}

body.mobile-mode .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.875rem;
    margin-bottom: 1rem;
}

body.mobile-mode .page-title {
    font-size: 1.5rem;
}

body.mobile-mode .card,
body.mobile-mode .table-container,
body.mobile-mode .placeholder-card,
body.mobile-mode .modal-content {
    border-radius: 1.25rem;
    border-color: var(--md-outline);
    box-shadow: var(--shadow-sm);
    background: var(--md-surface-container);
}

body.mobile-mode .user-filter-card,
body.mobile-mode .card.p-6,
body.mobile-mode .placeholder-card {
    padding: 1rem;
}

body.mobile-mode .filter-toolbar,
body.mobile-mode .filter-actions,
body.mobile-mode .inline-form,
body.mobile-mode .pagination-bar,
body.mobile-mode .modal-footer,
body.mobile-mode .sub-tabs-container {
    flex-direction: column;
    align-items: stretch;
}

body.mobile-mode .flex.items-center.justify-between {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
}

body.mobile-mode .filter-field,
body.mobile-mode .filter-field-keyword {
    min-width: 0;
    flex: 1 1 100%;
}

body.mobile-mode .filter-actions .btn,
body.mobile-mode .pagination-actions .btn,
body.mobile-mode .inline-form .btn {
    width: 100%;
}

body.mobile-mode .filter-actions,
body.mobile-mode .pagination-actions,
body.mobile-mode .inline-form {
    width: 100%;
}

body.mobile-mode .pagination-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

body.mobile-mode .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

body.mobile-mode #user-table,
body.mobile-mode #cloudfile-table,
body.mobile-mode #cardkey-table,
body.mobile-mode #logs-table,
body.mobile-mode #admin-table,
body.mobile-mode #backup-table,
body.mobile-mode #hwid-reset-table,
body.mobile-mode #dlf-list-area table {
    min-width: 720px;
}

body.mobile-mode .action-cell {
    flex-wrap: wrap;
    justify-content: flex-start;
}

body.mobile-mode .hwid-value {
    max-width: 120px;
}

body.mobile-mode .sub-tabs-container {
    gap: 0.5rem;
    border-bottom: none;
}

body.mobile-mode .sub-tab-item {
    border: 1px solid var(--md-outline);
    border-radius: 999px;
    padding: 0.7rem 0.95rem;
}

body.mobile-mode .sub-tab-item.active {
    background: var(--md-primary);
    color: var(--md-on-primary);
    border-bottom-color: transparent;
    border-color: var(--md-primary);
}

body.mobile-mode #view-app-logs,
body.mobile-mode #dlf-content-pre {
    min-height: 280px;
    max-height: 50dvh;
}

body.mobile-mode #dlf-list-area .table-container {
    max-height: 42dvh;
}

body.mobile-mode #dlf-content-area > div {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

body.mobile-mode .modal {
    align-items: flex-end;
    padding: 0;
}

body.mobile-mode .modal-overlay {
    background: rgb(15 23 42 / 0.28);
    backdrop-filter: blur(6px);
}

body.mobile-mode .modal-content {
    max-width: 100% !important;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-height: min(88dvh, 880px);
    overflow: hidden;
}

body.mobile-mode .modal-body {
    max-height: calc(88dvh - 140px);
    overflow-y: auto;
}

body.mobile-mode .modal-footer {
    background: var(--md-surface-container-high);
}

body.mobile-mode .modal-footer .btn {
    width: 100%;
}

body.mobile-mode .mobile-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgb(15 23 42 / 0.24);
}

body.mobile-mode .mobile-nav-backdrop.hidden,
body.mobile-mode .mobile-nav-drawer.hidden {
    display: none;
}

body.mobile-mode .mobile-nav-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--md-surface-container);
    border-radius: 1.5rem 1.5rem 0 0;
    border: 1px solid var(--md-outline);
    box-shadow: var(--md-shadow);
    padding: 1rem;
    gap: 1rem;
    max-height: min(72dvh, 520px);
}

body.mobile-mode .mobile-nav-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

body.mobile-mode .mobile-nav-drawer-list {
    display: grid;
    gap: 0.625rem;
    overflow-y: auto;
}

body.mobile-mode .mobile-drawer-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-height: var(--touch-target);
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    border: 1px solid var(--md-outline);
    background: var(--background);
    color: var(--foreground);
    font: inherit;
    cursor: pointer;
}

body.mobile-mode .mobile-drawer-item.active {
    background: rgb(79 70 229 / 0.1);
    border-color: rgb(79 70 229 / 0.25);
    color: var(--md-primary);
}

body.mobile-mode .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom));
    background: rgb(255 255 255 / 0.94);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--md-outline);
    box-shadow: 0 -8px 24px rgb(15 23 42 / 0.08);
}

body.mobile-mode .mobile-nav-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    border: none;
    background: transparent;
    color: var(--muted-foreground);
    font: inherit;
    font-size: 0.75rem;
    border-radius: 1rem;
    cursor: pointer;
}

body.mobile-mode .mobile-nav-item.active {
    color: var(--md-primary);
    background: rgb(79 70 229 / 0.1);
}

body.mobile-mode #toast-container {
    left: 1rem;
    right: 1rem;
    bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 0.75rem);
}

body.mobile-mode .toast {
    min-width: 0;
    width: 100%;
}

@media (max-width: 640px) {
    body.mobile-mode .detail-grid {
        grid-template-columns: 1fr;
    }
}

