/* ===================================================
   Samba Manager - Style Sheet
   =================================================== */

/* --- CSS Variables --- */
:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-success: #16a34a;
    --color-success-bg: #f0fdf4;
    --color-warning: #d97706;
    --color-warning-bg: #fffbeb;
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    --color-gray-800: #1f2937;
    --color-gray-900: #111827;
    --sidebar-width: 240px;
    --sidebar-bg: #f5f7fa;
    --sidebar-text: #303133;
    --sidebar-hover: #ecf5fe;
    --sidebar-active: #333333;
    --sidebar-active-bg: #fafafa;
    --sidebar-border: #e4e7ed;
    --header-footer-bg: #0F6CBD;
    --header-height: 48px;
    --footer-height: 36px;
    --radius: 6px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --transition: 0.2s ease;
}

/* Normal-user (SMB) view: widen the sidebar by 50% (240 -> 360). */
body.user-mode {
    --sidebar-width: 360px;
}
@media (max-width: 768px) {
    body.user-mode {
        --sidebar-width: 240px;
    }
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    color: var(--color-gray-800);
    background: var(--color-gray-50);
    line-height: 1.6;
}

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

/* ===================================================
   Header
   =================================================== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--header-footer-bg);
    color: rgba(255, 255, 255, 0.92);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 200;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.85);
}

.header-logo-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-user {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.8);
}

.header-user strong {
    color: #fff;
    font-weight: 600;
}

.header-divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.2);
}

.header-link {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.8);
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: var(--radius);
}

.header-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.12);
}

.header-link.link-danger:hover {
    color: #fca5a5;
}

/* Header Dropdown */
.header-dropdown {
    position: relative;
}

.header-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.9);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    transition: background var(--transition);
}

.header-dropdown-trigger:hover {
    background: rgba(255,255,255,0.12);
}

.header-dropdown-trigger strong {
    color: #fff;
}

.header-caret {
    font-size: 0.7rem;
    opacity: 0.6;
    transition: transform 0.2s;
}

.header-dropdown.open .header-caret {
    transform: rotate(180deg);
}

.header-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 140px;
    overflow: hidden;
    z-index: 210;
    animation: fadeIn 0.12s ease;
}

.header-dropdown.open .header-dropdown-menu {
    display: block;
}

.header-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    font-size: 0.88rem;
    color: var(--color-gray-700);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.header-dropdown-item:hover {
    background: var(--color-gray-50);
    color: var(--color-gray-900);
}

.header-dropdown-item.link-danger {
    color: var(--color-danger);
}

.header-dropdown-item.link-danger:hover {
    background: #fef2f2;
}

/* ===================================================
   App Body & Layout
   =================================================== */
.app-body {
    display: flex;
    margin-top: var(--header-height);
    height: calc(100vh - var(--header-height) - var(--footer-height));
    overflow: hidden;
}

/* ===================================================
   Footer
   =================================================== */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    background: #f5f7fa;
    border-top: 1px solid #e4e7ed;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 20px;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    font-size: 13px;
    color: #909399;
    z-index: 200;
}

.app-footer a {
    color: #909399;
    text-decoration: none;
    transition: color 0.2s;
}

.app-footer a:hover {
    color: #303133;
}

/* ===================================================
   Sidebar (Menu)
   =================================================== */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height) - var(--footer-height));
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 2px 0 6px rgba(0,0,0,0.04);
}

.sidebar + .app-content {
    margin-left: var(--sidebar-width);
}

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

.nav-section {
    margin-bottom: 6px;
}

.nav-section-title {
    padding: 14px 20px 6px;
    font-size: 12px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #909399;
}

.nav-btn {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 0 20px;
    height: 48px;
    line-height: 48px;
    background: none;
    border: none;
    border-radius: 0;
    color: #303133;
    font-size: 14px;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: #ecf5fe;
    color: #303133;
}

.nav-btn.active {
    background: #fafafa;
    color: #333;
    font-weight: 700;
}

/* ===================================================
   Main Content
   =================================================== */
.app-content {
    flex: 1;
    padding: 24px 28px 48px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;
}

.app-content.centered {
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-content h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--color-gray-900);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--color-gray-200);
}

/* Section Header (title + icon actions) */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding: 6px 0;
    border-bottom: 2px solid var(--color-gray-200);
}

.section-header h2 {
    font-size: 1.15rem;
    margin: 0;
    padding: 0;
    border: none;
    line-height: 1;
}

/* SMB file-browser: the section title is a clickable breadcrumb. */
#file-browser-title {
    font-size: 1rem;
    flex: 1 1 auto;
    min-width: 0;
}
#file-browser-title .bc-link {
    color: var(--color-primary);
    text-decoration: none;
}
#file-browser-title .bc-link:hover {
    text-decoration: underline;
}
#file-browser-title .bc-sep {
    margin: 0 4px;
    color: var(--color-gray-400);
}
#file-browser-title .bc-current {
    color: var(--color-gray-800);
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    position: relative;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--color-primary-hover);
    transform: scale(1.1);
}

.btn-icon[title]::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-gray-900);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 400;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.btn-icon:hover[title]::after {
    opacity: 1;
}

.btn-icon svg {
    display: block;
}

/* Table Footer (batch dropdown) */
.table-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.table-footer select {
    width: auto;
    min-width: 140px;
    padding: 6px 10px;
    font-size: 0.82rem;
}

/* ===================================================
   Alerts (server-side flash messages)
   =================================================== */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid #bbf7d0;
}

.alert-danger {
    background: #fef2f2;
    color: var(--color-danger);
    border: 1px solid #fecaca;
}

.alert-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
    border: 1px solid #fde68a;
}

/* ===================================================
   Toast Notifications
   =================================================== */
#toast-container {
    position: fixed;
    top: calc(var(--header-height) + 12px);
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    min-width: 280px;
    max-width: 420px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
}

.toast-success { border-left: 4px solid var(--color-success); }
.toast-danger  { border-left: 4px solid var(--color-danger); }
.toast-warning { border-left: 4px solid var(--color-warning); }
.toast-info    { border-left: 4px solid var(--color-primary); }

.toast-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

.toast-icon-success { background: var(--color-success); }
.toast-icon-danger  { background: var(--color-danger); }
.toast-icon-warning { background: var(--color-warning); }
.toast-icon-info    { background: var(--color-primary); }

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    color: var(--color-gray-800);
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--color-gray-400);
    font-size: 16px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color var(--transition);
}

.toast-close:hover {
    color: var(--color-gray-700);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 0 var(--radius);
    animation: toastProgress 4s linear forwards;
}

.toast-success .toast-progress { background: var(--color-success); }
.toast-danger  .toast-progress { background: var(--color-danger); }
.toast-warning .toast-progress { background: var(--color-warning); }
.toast-info    .toast-progress { background: var(--color-primary); }

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

.toast-exit {
    animation: toastOut 0.3s ease forwards;
}

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

@keyframes toastProgress {
    from { width: 100%; }
    to   { width: 0%; }
}

/* ===================================================
   Confirm Dialog
   =================================================== */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    animation: fadeIn 0.15s ease;
}

.confirm-card {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s ease;
}

.confirm-icon {
    text-align: center;
    margin-bottom: 16px;
}

.confirm-icon-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 22px;
}

.confirm-icon-circle.warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.confirm-icon-circle.danger {
    background: #fef2f2;
    color: var(--color-danger);
}

.confirm-body p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--color-gray-800);
    text-align: center;
    white-space: pre-line;
}

.confirm-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

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

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

/* ===================================================
   Buttons
   =================================================== */
.btn {
    display: inline-block;
    padding: 7px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
    text-align: center;
    white-space: nowrap;
    user-select: none;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

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

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

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

.btn-success:hover:not(:disabled) {
    background: #15803d;
    border-color: #15803d;
}

.btn-default {
    background: #fff;
    color: var(--color-gray-700);
    border-color: var(--color-gray-300);
}

.btn-default:hover:not(:disabled) {
    background: var(--color-gray-50);
    border-color: var(--color-gray-400);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.82rem;
}

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

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--color-gray-700);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--color-gray-800);
    background: #fff;
    border: 1px solid var(--color-gray-300);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    padding: 8px 0;
}

.checkbox-group label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 400;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

/* ===================================================
   Login / Centered Card
   =================================================== */
.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 10px;
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}

.login-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-gray-900);
    margin-bottom: 24px;
}

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

.toolbar select {
    width: auto;
    min-width: 160px;
}

/* ===================================================
   Data Tables
   =================================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table th,
.data-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--color-gray-200);
}

.data-table th {
    background: var(--color-gray-100);
    font-weight: 600;
    color: var(--color-gray-700);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table tbody tr:nth-child(even) {
    background: var(--color-gray-50);
}

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

.data-table td .btn + .btn {
    margin-left: 6px;
}

.data-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.data-table th:last-child,
.data-table td:last-child {
    text-align: right;
}

/* --- Batch Actions --- */
.batch-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding-top: 12px;
}

/* ===================================================
   Modals
   =================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 250;
    padding: 20px;
}

.modal-card {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-gray-900);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--color-gray-400);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--color-gray-700);
}

.modal-body {
    padding: 20px;
}

/* --- Empty state --- */
.empty-row td {
    text-align: center;
    color: var(--color-gray-400);
    padding: 32px 14px;
    font-style: italic;
}

/* ===================================================
   Permission / QX styles
   =================================================== */
.qx-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid #e9ecef;
}
.qx-row:last-child {
    border-bottom: none;
}
.qx-dept-name {
    min-width: 120px;
    font-weight: 500;
    color: #333;
}
.qx-row label {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    font-size: 13px;
    margin: 0;
}
.checkbox-group {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
}
.form-error {
    background: #f8d7da;
    color: #721c24;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 14px;
}
.form-hint {
    display: block;
    color: #6c757d;
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.4;
}

/* ===================================================
   Tree Table
   =================================================== */
.tree-table .tree-parent {
    background: var(--color-gray-100);
    font-weight: 500;
}
.tree-table .tree-parent td {
    border-bottom: 1px solid var(--color-gray-200);
}
.tree-table .tree-child td {
    padding-left: 48px;
}
.tree-table .tree-child:hover {
    background: #eff6ff;
}
.tree-toggle {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    color: var(--color-gray-500);
    font-size: 12px;
    transition: transform 0.15s;
    user-select: none;
}
.tree-toggle:hover {
    color: var(--color-primary);
}
.tree-toggle.tree-empty {
    color: var(--color-gray-300);
    font-size: 8px;
    cursor: default;
}
.dept-name-cell {
    font-weight: 600;
    color: var(--color-gray-800);
}
.user-name-cell {
    color: var(--color-gray-600);
    padding-left: 20px;
}

/* ===================================================
   Mobile Sidebar Toggle (hamburger)
   =================================================== */
.header-hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    border-radius: var(--radius);
    transition: background var(--transition);
}
.header-hamburger:hover {
    background: rgba(255,255,255,0.12);
}

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

/* ===================================================
   Table Responsive Wrapper
   =================================================== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 12px;
}
.table-responsive .data-table {
    min-width: 520px;
}

/* ===================================================
   Responsive
   =================================================== */
@media (max-width: 768px) {
    .header-hamburger {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        width: var(--sidebar-width);
        height: calc(100vh - var(--header-height));
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 110;
        border-right: 1px solid var(--sidebar-border);
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

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

    .sidebar + .app-content {
        margin-left: 0;
    }

    .app-content {
        padding: 16px;
    }

    .app-footer {
        height: 30px;
        font-size: 0.7rem;
    }

    .header-divider {
        display: none;
    }

    .header-right {
        gap: 8px;
    }

    .header-link {
        padding: 4px 6px;
        font-size: 0.82rem;
    }

    .login-card {
        padding: 24px 18px;
        margin: 0 8px;
    }

    .login-title {
        font-size: 1.25rem;
    }

    .modal-card {
        max-width: none;
        margin: 0 8px;
        border-radius: 8px;
        max-height: 85vh;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .confirm-card {
        max-width: none;
        margin: 0 12px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    #toast-container {
        right: 8px;
        left: 8px;
    }

    .toast {
        min-width: 0;
        max-width: none;
    }

    .qx-dept-name {
        min-width: 80px;
        font-size: 0.82rem;
    }

    .batch-actions {
        flex-wrap: wrap;
    }

    .toolbar {
        flex-wrap: wrap;
    }

    /* --- Mobile table: no scroll, auto-fit --- */
    .table-responsive {
        overflow-x: hidden;
    }
    .table-responsive .data-table {
        min-width: 0;
        table-layout: fixed;
        width: 100%;
    }

    .data-table th,
    .data-table td {
        padding: 7px 6px;
        font-size: 0.78rem;
        white-space: normal;
        word-break: break-all;
    }

    .data-table th {
        font-size: 0.72rem;
        letter-spacing: 0;
    }

    /* Hide secondary columns in tree table */
    .tree-table th:nth-child(3),
    .tree-table td:nth-child(3),
    .tree-table th:nth-child(4),
    .tree-table td:nth-child(4) {
        display: none;
    }

    /* Set column widths for remaining visible columns */
    .tree-table th:nth-child(1) { width: 28px; }
    .tree-table th:nth-child(5) { width: 32px; text-align: center; }
    .tree-table th:nth-child(6) { width: auto; }

    .tree-table .tree-child td:nth-child(1) { width: 28px; }
    .tree-table .tree-child td:nth-child(5) { text-align: center; }
    .tree-table .tree-child td:nth-child(6) { white-space: nowrap; }

    .data-table input[type="checkbox"] {
        width: 14px;
        height: 14px;
    }

    /* Button sizing on mobile */
    .btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    .btn-sm {
        padding: 4px 8px;
        font-size: 0.72rem;
    }

    /* Mobile section-header: tighter, centered alignment */
    .section-header {
        margin-bottom: 10px;
        padding: 4px 0;
    }

    .section-header h2 {
        font-size: 0.95rem;
        margin: 0;
        padding: 0;
    }

    .section-actions .btn-icon + .btn-icon {
        margin-left: 8px;
    }

    .btn-icon {
        width: 28px;
        height: 28px;
    }
    .btn-icon svg {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 13px;
    }

    .app-header {
        padding: 0 12px;
    }

    .header-logo {
        font-size: 1rem;
    }

    .app-content {
        padding: 10px;
    }

    .app-content h2 {
        font-size: 1.05rem;
        margin-bottom: 12px;
        padding-bottom: 8px;
    }

    .section-header h2 {
        font-size: 0.85rem;
        margin: 0;
        padding: 0;
    }

    .section-header {
        margin-bottom: 8px;
        padding: 3px 0;
    }

    .section-actions .btn-icon + .btn-icon {
        margin-left: 8px;
    }

    .btn-icon {
        width: 26px;
        height: 26px;
    }
    .btn-icon svg {
        width: 13px;
        height: 13px;
    }

    .data-table th,
    .data-table td {
        padding: 6px 4px;
        font-size: 0.72rem;
    }

    .data-table th {
        font-size: 0.68rem;
    }

    .tree-table .tree-child td {
        padding-left: 20px;
    }

    .user-name-cell {
        padding-left: 8px;
    }

    .dept-name-cell {
        font-size: 0.78rem;
    }

    .btn {
        padding: 5px 8px;
        font-size: 0.75rem;
    }
    .btn-sm {
        padding: 3px 6px;
        font-size: 0.68rem;
    }
}

/* ===================================================
   Operation Log (admin)
   =================================================== */
.log-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius);
}

.log-filter-bar select,
.log-filter-bar input[type="text"],
.log-filter-bar input[type="date"] {
    width: auto;
    min-width: 120px;
    max-width: 180px;
    padding: 6px 10px;
    font-size: 0.82rem;
}

.log-filter-bar input[type="date"] {
    min-width: 130px;
}

.log-filter-bar input[type="text"] {
    min-width: 160px;
}

.log-time {
    white-space: nowrap;
    font-size: 0.82rem;
    color: var(--color-gray-600);
}

.log-detail {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
    color: var(--color-gray-600);
}

.log-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 500;
}

.log-type-admin {
    background: #eff6ff;
    color: var(--color-primary);
}

.log-type-smb {
    background: #f0fdf4;
    color: var(--color-success);
}

.log-pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.log-page-info {
    font-size: 0.85rem;
    color: var(--color-gray-500);
}

@media (max-width: 768px) {
    .log-filter-bar {
        gap: 6px;
    }
    .log-filter-bar select,
    .log-filter-bar input {
        min-width: 100px;
        max-width: none;
        flex: 1 1 calc(50% - 6px);
    }
    .log-detail {
        max-width: 100px;
    }
}

/* ===================================================
   Log Tabs
   =================================================== */
.log-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 14px;
    border-bottom: 2px solid var(--color-gray-200);
}

.log-tab {
    padding: 8px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.9rem;
    color: var(--color-gray-500);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
}

.log-tab:hover {
    color: var(--color-gray-700);
}

.log-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

/* ===================================================
   File Browser (smb user mode)
   =================================================== */
.file-breadcrumb {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 12px;
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius);
    color: var(--color-gray-600);
    font-size: 0.88rem;
    line-height: 1.6;
}

.bc-path {
    flex: 1;
    min-width: 0;
}

.bc-back-btn {
    margin-left: 12px;
    flex-shrink: 0;
}

.file-breadcrumb a {
    color: var(--color-primary);
    text-decoration: none;
}

.file-breadcrumb a:hover {
    text-decoration: underline;
}

.bc-sep {
    margin: 0 4px;
    color: var(--color-gray-400);
}

.bc-current {
    color: var(--color-gray-800);
    font-weight: 500;
}

.file-table td {
    vertical-align: middle;
}

.file-icon-dir,
.file-icon-file {
    margin-right: 6px;
    font-size: 1.1rem;
    vertical-align: middle;
}

.file-nav-link {
    color: var(--color-primary) !important;
    text-decoration: none;
    font-weight: 500;
}

.file-nav-link:hover {
    text-decoration: underline;
}

.file-row .file-size,
.file-row .file-time,
.file-row .file-owner {
    white-space: nowrap;
    color: var(--color-gray-500);
    font-size: 0.85rem;
}

.file-actions {
    white-space: nowrap;
    text-align: right;
}

.file-actions .btn + .btn,
.file-actions .btn + a,
.file-actions a + .btn {
    margin-left: 4px;
}

.file-back td {
    background: var(--color-gray-50);
    font-style: italic;
}

.share-nav-btn {
    padding-left: 16px;
}

.share-nav-btn .share-icon {
    margin-right: 0;
    font-style: normal;
}

/* menu icon (admin sidebar SVG icons, like SSO /home el-menu) */
.nav-btn .nav-icon {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    flex-shrink: 0;
    color: inherit;
}

/* ---- Sidebar directory tree (expandable shares) ---- */
.tree-node {
    width: 100%;
}
.tree-row {
    overflow: hidden;
}
.tree-label {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tree-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    flex: 0 0 16px;
    margin-left: auto;
    font-size: 10px;
    color: #909399;
    cursor: pointer;
    user-select: none;
    transition: transform 0.18s ease;
}
.tree-arrow:hover {
    color: #303133;
}
.tree-arrow.tree-arrow-open {
    transform: rotate(90deg);
}
.tree-children {
    width: 100%;
}
.tree-loading,
.tree-empty,
.tree-error {
    padding: 6px 20px 6px 46px;
    font-size: 12px;
    line-height: 1.4;
    color: #909399;
    font-style: italic;
}
.tree-error {
    color: #f56c6c;
}

/* Prevent iOS input zoom */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="password"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px;
    }
}

/* ===================================================
   Pagination nav (client-side, list pages)
   =================================================== */
.pagenav {
    position: fixed;
    bottom: var(--footer-height);
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
    padding: 6px 28px;
    background: #fff;
    z-index: 5;
}

.pagenav-info {
    font-size: 0.85rem;
    color: var(--color-gray-500);
    margin-right: 4px;
}

.pagenav-pages {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.pagenav .btn-sm {
    min-width: 32px;
}

.pagenav-ellipsis {
    padding: 0 2px;
    color: var(--color-gray-400);
    font-size: 0.85rem;
    user-select: none;
}

@media (max-width: 768px) {
    .pagenav {
        gap: 4px;
        padding: 6px 2px;
    }
    .pagenav .btn-sm {
        min-width: 28px;
        padding: 4px 8px;
    }
}

/* ===================================================
   RAG Settings & Queue (admin) - minimal additions
   =================================================== */
.rag-tab-panel {
    padding: 4px 2px 8px;
}

.rag-subgroup-title {
    margin: 4px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-gray-200);
    font-size: 0.95rem;
    color: var(--color-gray-700);
}

.rag-sep {
    border: none;
    border-top: 1px dashed var(--color-gray-200);
    margin: 22px 0 18px;
}

.rag-test-result {
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    min-height: 1em;
}

/* blackout time-window row (总开关 Tab) */
.rag-blackout-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.rag-blackout-row input[type="time"] { width: 7rem; }
.rag-blackout-sep { color: var(--color-gray-500); }

/* OCR engine install badge (文件解析 Tab) */
.rag-ocr-status {
    display: inline-block;
    margin-left: 10px;
    font-size: 0.82rem;
    vertical-align: middle;
}
.rag-ocr-status .rag-ocr-ok { color: var(--color-success); font-weight: 600; }
.rag-ocr-status .rag-ocr-no { color: var(--color-danger); font-weight: 600; }

/* Full parsing/OCR/转换 capability checklist (rendered inside .rag-ocr-status).
   When the list is present the badge becomes a block under the OCR checkbox. */
.rag-ocr-status .rag-ocr-ok,
.rag-ocr-status .rag-ocr-no { display: block; margin-bottom: 4px; }
.rag-cap-list {
    display: block;
    margin: 4px 0 0;
    padding: 0 0 0 10px;
    list-style: none;
    border-left: 2px solid var(--color-gray-300);
    color: var(--color-gray-600);
    line-height: 1.5;
}
.rag-cap-list > li { margin: 2px 0; }
.rag-cap-list .rag-cap-cat { font-weight: 600; color: var(--color-gray-700); }
.rag-cap-list ul { list-style: none; margin: 2px 0 6px; padding: 0 0 0 16px; }
.rag-cap-list ul li { margin: 1px 0; }
.rag-cap-mark { display: inline-block; width: 1.1em; font-weight: 700; }
.rag-cap-on { color: var(--color-success); }
.rag-cap-off { color: var(--color-gray-400); }
/* Override the inline-block badge: with the capability checklist present,
   render as a full-width block below the OCR checkbox. */
.rag-ocr-status:has(.rag-cap-list) {
    display: block;
    margin-left: 0;
    margin-top: 8px;
    vertical-align: baseline;
}

.rag-autorefresh-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    color: var(--color-gray-600);
    cursor: pointer;
    margin-right: 4px;
    white-space: nowrap;
}

.rag-batch-bar {
    background: var(--color-gray-50);
}

.rag-batch-bar label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    color: var(--color-gray-700);
}

/* stat tiles — single-row inline layout (总数：N | 正常：N | ...) */
.rag-stat-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    padding: 8px 4px;
    margin-bottom: 12px;
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius);
    min-height: 36px;
    line-height: 1.4;
}

.rag-stat-tile {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    padding: 2px 14px;
    font-size: 0.88rem;
    white-space: nowrap;
    border-right: 1px solid var(--color-gray-200);
}
.rag-stat-tile:last-child { border-right: none; }

.rag-stat-num {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-gray-800);
    line-height: 1.2;
}

.rag-stat-label {
    font-size: 0.82rem;
    color: var(--color-gray-600);
    font-weight: 500;
}

/* color accents on stat numbers */
.rag-stat-queued { color: var(--color-primary); }
.rag-stat-processing { color: var(--color-warning); }
.rag-stat-done { color: var(--color-success); }
.rag-stat-failed { color: var(--color-danger); }
.rag-stat-excluded { color: var(--color-gray-500); }

/* status badge colors (reuse .log-type-badge shape) */
.rag-status-QUEUED { background: #eff6ff; color: var(--color-primary); }
.rag-status-PARSING,
.rag-status-EMBEDDING,
.rag-status-INDEXING { background: var(--color-warning-bg); color: var(--color-warning); }
.rag-status-DONE { background: var(--color-success-bg); color: var(--color-success); }
.rag-status-FAILED { background: #fef2f2; color: var(--color-danger); }
.rag-status-EXCLUDED { background: var(--color-gray-100); color: var(--color-gray-500); }

/* ---- File management (文件管理) badges ----
   Self-contained color variants scoped under .fm-* so they don't collide
   with the RAG-queue badges. */
.fm-badge { display: inline-block; padding: 2px 8px; border-radius: 10px;
    font-size: 12px; font-weight: 600; white-space: nowrap; }
/* file-health status (file_status_class) */
.fm-fs-normal      { background: var(--color-success-bg); color: var(--color-success); }
.fm-fs-corrupt     { background: #fef2f2; color: var(--color-danger); }
.fm-fs-empty       { background: #fef2f2; color: var(--color-danger); }
.fm-fs-scan        { background: var(--color-warning-bg); color: var(--color-warning); }
.fm-fs-unsupported { background: var(--color-gray-100); color: var(--color-gray-500); }
.fm-fs-other       { background: var(--color-gray-100); color: var(--color-gray-500); }
/* RAG ingestion status (rag_status_class) */
.fm-rag-done       { background: var(--color-success-bg); color: var(--color-success); }
.fm-rag-failed     { background: #fef2f2; color: var(--color-danger); }
.fm-rag-excluded   { background: var(--color-gray-100); color: var(--color-gray-500); }
.fm-rag-queued     { background: #eff6ff; color: var(--color-primary); }
.fm-rag-processing { background: var(--color-warning-bg); color: var(--color-warning); }
.fm-rag-non-rag    { background: var(--color-gray-100); color: var(--color-gray-500); }

@media (max-width: 768px) {
    .rag-stat-bar { gap: 4px; padding: 6px 4px; }
    .rag-stat-tile { padding: 2px 8px; font-size: 0.82rem; }
}

/* ============================================================
   Dashboard  -- post-login landing page (admin + smb)
   ============================================================ */
.dash-loading, .dash-error {
    padding: 28px 16px;
    text-align: center;
    color: var(--color-gray-600);
    font-size: 0.92rem;
}
.dash-error { color: var(--color-danger); }

.dash-empty {
    padding: 60px 16px;
    text-align: center;
    color: var(--color-gray-600);
}
.dash-empty-icon { font-size: 40px; margin-bottom: 8px; }
.dash-empty-text { font-size: 0.92rem; }

.dash-stat-bar { margin-bottom: 14px; }
.rag-stat-num.rag-stat-done { color: var(--color-success); }
.rag-stat-num.rag-stat-failed { color: var(--color-danger); }
.rag-stat-num.rag-stat-muted { color: var(--color-gray-500); }

.dash-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.dash-card {
    background: #fff;
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius);
    padding: 12px 14px 14px;
}
.dash-card-wide { grid-column: 1 / -1; }
.dash-card-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--color-gray-700);
    margin-bottom: 8px;
}
.dash-canvas-wrap {
    position: relative;
    height: 240px;
}
.dash-canvas-tall { height: 300px; }

.dash-footnote {
    margin-top: 14px;
    font-size: 0.78rem;
    color: var(--color-gray-500);
}
.dash-footnote a { color: var(--color-primary); }

@media (max-width: 768px) {
    .dash-grid { grid-template-columns: 1fr; }
    .dash-canvas-wrap { height: 220px; }
    .dash-canvas-tall { height: 260px; }
}

/* ===================================================
   Notifications (message center, admin + smb)
   =================================================== */

/* Unread count badge on the sidebar 消息通知 button. */
.nav-btn .notif-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
}

/* Table cells */
.notif-title { font-weight: 600; color: var(--color-gray-900); word-break: break-word; }
.notif-content {
    margin-top: 3px;
    font-size: 0.82rem;
    color: var(--color-gray-500);
    /* Improvement 1: clamp the 2nd line (content/detail) to one line with an
       ellipsis. Hover the row/cell to see the full text via the title attr. */
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.notif-meta { margin-top: 3px; font-size: 0.74rem; color: var(--color-gray-400); }

/* Improvement 3: status tags merged into the title row (replaces the old
   已读/已处理 columns). [未读]=blue, [未处理]=orange, [已处理]=gray. */
.notif-tag {
    display: inline-block;
    padding: 1px 7px;
    margin-left: 6px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    vertical-align: middle;
    white-space: nowrap;
}
.notif-tag-unread  { background: #e8f0fe; color: #1a73e8; }
.notif-tag-pending { background: #fef3e7; color: #c2410c; }
.notif-tag-done    { background: var(--color-gray-100); color: var(--color-gray-500); }

.notif-type-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    background: #eef2ff;
    color: #393970;
    font-size: 0.78rem;
    white-space: nowrap;
}

.notif-sev-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}
.notif-sev-error   { background: #fee4e2; color: #b42318; border: 1px solid #fecdca; }
.notif-sev-warning { background: var(--color-warning-bg); color: #b54708; border: 1px solid #fed7aa; }
.notif-sev-info    { background: var(--color-gray-100); color: var(--color-gray-600); border: 1px solid var(--color-gray-200); }

.notif-path {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-gray-600);
    cursor: help;
}

.notif-yes { color: var(--color-success); font-size: 0.82rem; white-space: nowrap; }
.notif-no  { color: var(--color-gray-400); font-size: 0.82rem; white-space: nowrap; }

.notif-actions .btn + .btn { margin-left: 4px; }

/* Subtle highlight for unread rows. */
.data-table tbody tr.notif-unread-row td { background: #f5f8ff; }
.data-table tbody tr.notif-unread-row:hover td { background: #eaf1ff; }

/* ===================================================
   Notification detail modal (improvement 2)
   =================================================== */
#modal-notification-detail .modal-card { max-width: 620px; }

.notif-detail-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.notif-detail-row {
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--color-gray-700);
    word-break: break-word;
}
.notif-detail-label {
    display: inline-block;
    min-width: 64px;
    color: var(--color-gray-500);
    font-size: 0.8rem;
}
.notif-detail-content {
    margin-top: 4px;
    padding: 10px 12px;
    background: var(--color-gray-100);
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.85rem;
    color: var(--color-gray-800);
}
.notif-detail-path {
    display: inline-block;
    max-width: 100%;
    padding: 2px 6px;
    background: var(--color-gray-100);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--color-gray-700);
    word-break: break-all;
    user-select: all;
}
.notif-status-unread  { color: #1a73e8; font-weight: 600; }
.notif-status-read    { color: var(--color-gray-500); }
.notif-status-pending { color: #c2410c; font-weight: 600; }
.notif-status-done    { color: var(--color-gray-500); }

.muted { color: var(--color-gray-400); }

