:root {
    --sidebar-width: 240px;
    --sidebar-bg: #080b14;
    --sidebar-hover: #111827;
    --sidebar-active: #1a1f35;
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --primary-dim: #4f46e5;
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.4);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.4);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.4);
    --purple: #a855f7;
    --purple-glow: rgba(168, 85, 247, 0.4);
    --cyan: #06b6d4;
    --cyan-glow: rgba(6, 182, 212, 0.4);
    --bg: #0a0e1a;
    --card-bg: rgba(15, 20, 35, 0.85);
    --card-bg-solid: #0f1423;
    --card-hover: rgba(20, 28, 45, 0.9);
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(99, 102, 241, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.08), transparent),
        radial-gradient(ellipse 50% 40% at 100% 80%, rgba(168, 85, 247, 0.05), transparent),
        radial-gradient(ellipse 50% 40% at 0% 80%, rgba(6, 182, 212, 0.04), transparent);
    pointer-events: none;
    z-index: 0;
}

/* ============== Grid Background ============== */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black, transparent);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black, transparent);
}

/* ============== Layout ============== */
.app-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ============== Sidebar ============== */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(8, 11, 20, 0.95);
    backdrop-filter: blur(20px);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.5);
}

.sidebar::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 1px;
    background: linear-gradient(to bottom, transparent, var(--primary-glow), transparent);
    opacity: 0.5;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 19px;
    flex-shrink: 0;
    box-shadow: 0 0 20px var(--primary-glow);
    position: relative;
    overflow: hidden;
}

.brand-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.15));
    border-radius: 12px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #fff, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-sub {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: rgba(255, 255, 255, 0.85);
    border-color: rgba(99, 102, 241, 0.15);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.1), inset 0 0 15px rgba(99, 102, 241, 0.05);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 8px var(--primary-glow);
}

.nav-item.active i {
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

.nav-item i {
    font-size: 18px;
    width: 22px;
    text-align: center;
    transition: all var(--transition);
}

.nav-item:hover i {
    transform: translateX(2px);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 0 12px var(--primary-glow);
}

.user-detail {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
}

.user-name small {
    font-weight: 400;
    font-size: 11px;
    color: var(--text-muted);
}

.user-actions {
    display: flex;
    gap: 10px;
    margin-top: 2px;
}

.user-action-link {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    text-decoration: none;
    transition: color var(--transition);
}

.user-action-link:hover {
    color: var(--primary);
}

/* ============== Main Content ============== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px 36px;
    min-height: 100vh;
    animation: fadeInUp 0.5s ease;
}

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

/* ============== Page Header ============== */
.page-header {
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #e2e8f0, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* ============== Cards ============== */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: all var(--transition-slow);
    overflow: hidden;
}

.card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.card-header {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 20px;
}

.card-footer {
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
}

/* ============== Stat Cards ============== */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-slow);
    position: relative;
    overflow: hidden;
    cursor: default;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.03), transparent);
    transition: all var(--transition-slow);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.1);
}

.stat-card:hover::before {
    top: -20%;
    right: -20%;
}

.stat-card:nth-child(1) { border-left: 2px solid var(--primary); }
.stat-card:nth-child(2) { border-left: 2px solid var(--success); }
.stat-card:nth-child(3) { border-left: 2px solid var(--purple); }
.stat-card:nth-child(4) { border-left: 2px solid var(--warning); }

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.stat-icon.blue {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}
.stat-icon.green {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}
.stat-icon.orange {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.2);
}
.stat-icon.purple {
    background: rgba(168, 85, 247, 0.15);
    color: var(--purple);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.2);
}

.stat-info h3 {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1;
    background: linear-gradient(135deg, #e2e8f0, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 5px 0 0;
    font-weight: 500;
}

/* ============== Tables ============== */
.table {
    margin-bottom: 0;
    font-size: 14px;
    table-layout: fixed;
    color: var(--text);
}

.table th {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 12px 16px;
}

.table td {
    padding: 14px 16px;
    vertical-align: middle;
    border-color: var(--border);
    transition: background var(--transition);
}

.table-hover tbody tr {
    transition: all var(--transition);
}

.table-hover tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* ============== File Name Cell ============== */
.file-name-cell {
    max-width: 0;
}

.file-name-cell strong {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

/* ============== Action Buttons ============== */
.action-btns {
    white-space: nowrap;
}

/* ============== Category Badge Link ============== */
.category-badge-link {
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition);
}

.category-badge-link:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
}

/* ============== Buttons ============== */
.btn {
    border-radius: var(--radius-xs);
    font-weight: 500;
    font-size: 14px;
    padding: 8px 16px;
    transition: all var(--transition);
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dim));
    color: #fff;
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    box-shadow: 0 0 25px var(--primary-glow);
    transform: translateY(-1px);
    border-color: rgba(99, 102, 241, 0.6);
}

.btn-outline-primary {
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.btn-outline-danger {
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: var(--danger);
    background: transparent;
}

.btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    box-shadow: 0 0 15px var(--danger-glow);
}

.btn-outline-success {
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: var(--success);
    background: transparent;
}

.btn-outline-success:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
    box-shadow: 0 0 15px var(--success-glow);
}

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

.btn-outline-danger {
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: var(--danger);
    background: transparent;
}

.btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
}

/* ============== Badges ============== */
.badge {
    font-weight: 600;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.2px;
}

.badge.bg-primary { background: rgba(99, 102, 241, 0.2) !important; color: #a5b4fc; }
.badge.bg-success { background: rgba(16, 185, 129, 0.2) !important; color: #6ee7b7; }
.badge.bg-warning { background: rgba(245, 158, 11, 0.2) !important; color: #fcd34d; }
.badge.bg-danger { background: rgba(239, 68, 68, 0.2) !important; color: #fca5a5; }
.badge.bg-secondary { background: rgba(255, 255, 255, 0.08) !important; color: #94a3b8; }
.badge.bg-info { background: rgba(6, 182, 212, 0.2) !important; color: #67e8f9; }

/* ============== Forms ============== */
.form-control, .form-select {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xs);
    padding: 10px 14px;
    font-size: 14px;
    transition: all var(--transition);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15), 0 0 15px rgba(99, 102, 241, 0.1);
    outline: none;
    background: rgba(255, 255, 255, 0.08);
}

.form-select option {
    background: var(--card-bg-solid);
    color: var(--text);
}

.form-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ============== Modals ============== */
.modal-content {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(99, 102, 241, 0.1);
    animation: modalIn 0.3s ease;
    background: var(--card-bg-solid);
    backdrop-filter: blur(20px);
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.02);
}

.modal-header .modal-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.02);
}

/* ============== Toast ============== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.custom-toast {
    background: var(--card-bg-solid);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 22px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg), 0 0 20px rgba(99, 102, 241, 0.1);
    animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 14px;
    min-width: 280px;
    backdrop-filter: blur(20px);
    color: var(--text);
}

.custom-toast i {
    color: var(--primary);
    font-size: 18px;
    filter: drop-shadow(0 0 5px var(--primary-glow));
}

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

/* ============== Login Page ============== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.12), transparent 70%);
    top: -300px;
    right: -300px;
    border-radius: 50%;
    animation: float 8s ease-in-out infinite;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.08), transparent 70%);
    bottom: -200px;
    left: -200px;
    border-radius: 50%;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(40px, -40px) scale(1.1); }
}

.login-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 44px 40px;
    width: 420px;
    box-shadow: var(--shadow-lg), 0 0 60px rgba(99, 102, 241, 0.1);
    position: relative;
    z-index: 1;
    border: 1px solid var(--border);
}

.login-card .logo {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    margin: 0 auto 20px;
    box-shadow: 0 0 30px var(--primary-glow);
    position: relative;
    overflow: hidden;
}

.login-card .logo::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.15));
    border-radius: 16px;
}

.login-card h3 {
    text-align: center;
    font-weight: 800;
    font-size: 22px;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #e2e8f0, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-card .form-control {
    padding: 12px 16px;
    font-size: 15px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08) !important;
    color: #e2e8f0 !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

.login-card .form-control:focus {
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15), 0 0 15px rgba(99, 102, 241, 0.1) !important;
}

.login-card .form-control::placeholder {
    color: rgba(255, 255, 255, 0.3) !important;
}

.login-card .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 12px;
}

/* ============== Captcha ============== */
.captcha-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.captcha-input {
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 5px;
    font-weight: 700;
    font-size: 16px !important;
    text-align: center;
    background: rgba(255, 255, 255, 0.1) !important;
    color: #e2e8f0 !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.captcha-img {
    height: 48px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all var(--transition);
    background: rgba(255, 255, 255, 0.05);
}

.captcha-img:hover {
    opacity: 0.8;
    transform: scale(1.02);
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* ============== Note Cards ============== */
.note-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
}

.note-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: all var(--transition-slow);
    overflow: hidden;
}

.note-card:hover {
    box-shadow: var(--shadow-lg), 0 0 25px rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.3);
    transform: translateY(-3px);
}

.note-card-body {
    padding: 22px;
}

.note-card-body h5 {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 8px;
}

.note-card-body .note-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.note-card-body .note-preview {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-card-footer {
    padding: 12px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.note-card-footer .note-time {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============== Memo Cards ============== */
.memo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
}

.memo-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: all var(--transition-slow);
    overflow: hidden;
}

.memo-card.done {
    opacity: 0.5;
    border-color: rgba(16, 185, 129, 0.2);
}

.memo-card:hover {
    box-shadow: var(--shadow-lg), 0 0 25px rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    transform: translateY(-3px);
}

.memo-card-body {
    padding: 22px;
}

.memo-card-body h5 {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 8px;
}

.memo-card-body h5.done {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.memo-card-body p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 12px;
}

.memo-card-footer {
    padding: 12px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    background: rgba(255, 255, 255, 0.02);
}

.memo-card-footer .btn {
    font-size: 12px;
    padding: 4px 10px;
}

/* ============== Filter Bar ============== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar .search-input {
    width: 240px;
    flex-shrink: 0;
}

.filter-bar .category-select {
    width: 140px;
    flex-shrink: 0;
}

.filter-bar .type-select {
    width: 120px;
    flex-shrink: 0;
}

.filter-bar .date-input {
    width: 150px;
    flex-shrink: 0;
}

/* ============== Empty State ============== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 52px;
    color: rgba(255, 255, 255, 0.1);
    margin-bottom: 16px;
    display: block;
    transition: all var(--transition-slow);
}

.empty-state:hover i {
    transform: scale(1.1);
    color: rgba(255, 255, 255, 0.15);
}

.empty-state p {
    font-size: 15px;
}

/* ============== Preview ============== */
#preview {
    min-height: 120px;
    max-height: 500px;
    overflow-y: auto;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
}

#preview h1, #preview h2, #preview h3 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 600;
}

#preview pre {
    background: #0d1117;
    color: #c9d1d9;
    padding: 16px;
    border-radius: var(--radius-xs);
    overflow-x: auto;
    font-size: 13px;
}

#preview code {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

#preview pre code {
    background: none;
    padding: 0;
}

#preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

#preview th, #preview td {
    border: 1px solid var(--border);
    padding: 8px 12px;
}

#preview th {
    background: rgba(255, 255, 255, 0.03);
}

/* ============== Document Preview Modal ============== */
.preview-body {
    min-height: 400px;
    max-height: 70vh;
    overflow: auto;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
}

.preview-loading {
    text-align: center;
    padding: 60px;
}

.preview-loading .spinner-border {
    width: 40px;
    height: 40px;
    border-width: 3px;
    color: var(--primary);
}

.preview-loading p {
    color: var(--text-secondary);
}

.preview-error {
    text-align: center;
    padding: 60px;
    color: var(--danger);
}

.preview-error i {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.preview-error p {
    font-size: 16px;
    margin-bottom: 8px;
}

.preview-unsupported {
    text-align: center;
    padding: 60px;
    color: var(--text-secondary);
}

.preview-unsupported i {
    font-size: 64px;
    display: block;
    margin-bottom: 16px;
    color: rgba(255, 255, 255, 0.1);
}

.preview-unsupported p {
    font-size: 16px;
    margin-bottom: 4px;
}

.preview-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 20px;
}

.preview-img-content {
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
    border-radius: var(--radius-xs);
    box-shadow: var(--shadow-lg);
}

.preview-pdf-frame {
    width: 100%;
    height: 70vh;
    border: none;
    border-radius: var(--radius-xs);
}

.preview-code-block {
    margin: 0;
    padding: 20px 24px;
    background: #0d1117;
    color: #c9d1d9;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    width: 100%;
    min-height: 400px;
    max-height: 65vh;
}

.preview-code-block code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
    background: none;
    padding: 0;
}

/* ============== Scrollbar ============== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============== Dashboard grid row ============== */
.row.g-4 {
    --bs-gutter-y: 1.5rem;
}

/* ============== Text colors ============== */
.text-muted { color: var(--text-muted) !important; }

/* ============== Horizontal rule ============== */
hr {
    border-color: var(--border);
}

/* ============== Responsive ============== */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    .app-layout {
        flex-direction: column;
    }
    .main-content {
        margin-left: 0;
        padding: 20px;
    }
    .stat-cards {
        grid-template-columns: 1fr 1fr;
    }
    .note-grid, .memo-grid {
        grid-template-columns: 1fr;
    }
}