/* ===== FOTOVAULT — DARK PROFESSIONAL THEME ===== */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

:root {
    --bg:        #0D0F14;
    --bg2:       #141720;
    --bg3:       #1C2030;
    --border:    #2A2F45;
    --border2:   #353B55;
    --text:      #E8EAF0;
    --text2:     #8B90A8;
    --text3:     #555B78;
    --accent:    #E8640A;
    --accent2:   #FF8A3D;
    --accent-bg: rgba(232,100,10,0.12);
    --danger:    #EF4444;
    --danger-bg: rgba(239,68,68,0.12);
    --success:   #10B981;
    --radius:    14px;
    --radius-sm: 8px;
    --shadow:    0 4px 24px rgba(0,0,0,0.45);
    --shadow-lg: 0 12px 48px rgba(0,0,0,0.6);
}

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

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ===== LOGIN ===== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100dvh; }

.login-bg {
    position: fixed; inset: 0; overflow: hidden; z-index: 0;
    background: radial-gradient(ellipse at 20% 50%, #1a0f05 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, #0a0d1a 0%, transparent 50%),
                #0D0F14;
}

.orb {
    position: absolute; border-radius: 50%;
    filter: blur(80px); opacity: 0.35; animation: float 8s ease-in-out infinite;
}
.orb1 { width: 300px; height: 300px; background: #E8640A; top: -80px; left: -80px; animation-delay: 0s; }
.orb2 { width: 200px; height: 200px; background: #3B5BDB; bottom: -60px; right: -40px; animation-delay: -3s; }
.orb3 { width: 150px; height: 150px; background: #8B5CF6; top: 50%; left: 60%; animation-delay: -6s; }

@keyframes float {
    0%, 100% { transform: translate(0,0) scale(1); }
    33% { transform: translate(20px,-20px) scale(1.05); }
    66% { transform: translate(-15px,15px) scale(0.95); }
}

.login-container { position: relative; z-index: 1; width: 100%; max-width: 400px; padding: 20px; }

.login-card {
    background: rgba(20,23,32,0.85);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.5s cubic-bezier(0.16,1,0.3,1);
}

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

.logo-area { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.logo-icon { display: flex; align-items: center; justify-content: center; }
.logo-text { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 28px; letter-spacing: -0.5px; }

.login-subtitle { color: var(--text2); font-size: 14px; margin-bottom: 28px; font-weight: 300; }

.error-msg {
    background: var(--danger-bg);
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

.pin-label { color: var(--text2); font-size: 13px; text-align: center; margin-bottom: 16px; }

.pin-display {
    display: flex; gap: 14px; justify-content: center; margin-bottom: 28px;
}

.pin-dot {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid var(--border2);
    background: transparent;
    transition: all 0.15s;
}
.pin-dot.filled {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent);
    transform: scale(1.1);
}

.keypad {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}

.key-btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: 'Syne', sans-serif;
    font-size: 20px;
    font-weight: 700;
    padding: 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.1s;
    -webkit-user-select: none; user-select: none;
}
.key-btn:active, .key-btn:hover { background: var(--border); transform: scale(0.95); }
.key-clear { color: var(--danger); font-size: 16px; }
.key-enter { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); font-size: 20px; }
.key-enter:hover { background: var(--accent); color: white; }

.register-link { text-align: center; margin-top: 24px; }
.register-link a { color: var(--accent); text-decoration: none; font-size: 14px; opacity: 0.8; transition: opacity 0.2s; }
.register-link a:hover { opacity: 1; }

.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97);
}
@keyframes shake {
    10%, 90% { transform: translateX(-3px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-5px); }
    40%, 60% { transform: translateX(5px); }
}

/* ===== APP LAYOUT ===== */
.app-body { display: flex; flex-direction: column; min-height: 100dvh; }

.app-header {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px;
    background: rgba(13,15,20,0.92);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.app-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 18px; }

.btn-back {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); text-decoration: none;
    transition: all 0.15s;
}
.btn-back:hover { background: var(--border); }

.btn-logout {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text2); text-decoration: none;
    transition: all 0.15s;
}
.btn-logout:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }

.app-main { flex: 1; padding: 20px; max-width: 900px; width: 100%; margin: 0 auto; }

.breadcrumb {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--text3);
    margin-bottom: 20px; flex-wrap: wrap;
}
.breadcrumb a { color: var(--text2); text-decoration: none; transition: color 0.15s; }
.breadcrumb a:hover { color: var(--accent); }
.bc-sep { color: var(--text3); }

.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; gap: 12px;
}
.section-title {
    font-family: 'Syne', sans-serif; font-weight: 700; font-size: 20px;
}

/* ===== BUTTONS ===== */
.btn-primary {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--accent); color: white;
    border: none; border-radius: var(--radius-sm);
    padding: 10px 18px; font-size: 14px; font-weight: 500;
    cursor: pointer; font-family: 'DM Sans', sans-serif;
    transition: all 0.15s; white-space: nowrap;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
    display: inline-flex; align-items: center; gap: 8px;
    background: transparent; color: var(--text2);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 18px; font-size: 14px;
    cursor: pointer; font-family: 'DM Sans', sans-serif;
    transition: all 0.15s;
}
.btn-ghost:hover { border-color: var(--border2); color: var(--text); }

.btn-danger {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--danger); color: white;
    border: none; border-radius: var(--radius-sm);
    padding: 10px 18px; font-size: 14px;
    cursor: pointer; font-family: 'DM Sans', sans-serif;
    transition: all 0.15s;
}
.btn-danger:hover { opacity: 0.85; }

/* ===== FOLDER GRID ===== */
.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}

.folder-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 16px 14px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    animation: fadeIn 0.3s ease;
    overflow: hidden;
}
.folder-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--folder-color, var(--accent));
    border-radius: var(--radius) var(--radius) 0 0;
}
.folder-card:hover {
    border-color: var(--folder-color, var(--accent));
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.folder-icon {
    margin-bottom: 10px;
    display: flex; align-items: center;
}

.folder-name {
    font-family: 'Syne', sans-serif;
    font-size: 14px; font-weight: 700;
    color: var(--text);
    word-break: break-word;
    margin-bottom: 12px;
    line-height: 1.3;
}

.folder-meta {
    font-size: 11px; color: var(--text3);
    margin-bottom: 10px;
}

.folder-actions {
    display: flex; gap: 6px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 4px;
}

.folder-btn {
    flex: 1;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text3);
    border-radius: 7px;
    padding: 6px 4px;
    font-size: 11px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: all 0.15s;
    display: flex; align-items: center; justify-content: center; gap: 4px;
}
.folder-btn:hover { color: var(--text); border-color: var(--border2); }
.folder-btn.delete:hover { color: var(--danger); border-color: rgba(239,68,68,0.4); background: var(--danger-bg); }
.folder-btn.rename:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text3);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 15px; color: var(--text2); margin-bottom: 6px; }
.empty-state span { font-size: 13px; }

.loading-state { grid-column: 1 / -1; text-align: center; padding: 40px; color: var(--text3); }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 500;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: fadeOverlay 0.2s;
}
@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px 24px;
    width: 100%; max-width: 360px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.16,1,0.3,1);
}

.modal-title {
    font-family: 'Syne', sans-serif;
    font-size: 18px; font-weight: 700;
    margin-bottom: 18px;
}

.modal-desc { color: var(--text2); font-size: 14px; margin-bottom: 20px; line-height: 1.5; text-align: center; }

.modal-input {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    padding: 12px 14px;
    outline: none;
    transition: border-color 0.15s;
    margin-bottom: 16px;
}
.modal-input:focus { border-color: var(--accent); }
.modal-input::placeholder { color: var(--text3); }

.modal-input-wrap { flex: 1; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.color-picker-section { margin-bottom: 20px; }
.color-label { font-size: 12px; color: var(--text2); margin-bottom: 10px; }
.color-options { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
    width: 30px; height: 30px; border-radius: 50%;
    cursor: pointer; border: 3px solid transparent;
    transition: all 0.15s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: white; box-shadow: 0 0 0 2px var(--border2); }

.delete-icon { text-align: center; margin-bottom: 14px; }

/* ===== PHOTO ACTIONS BAR ===== */
.photo-actions-bar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}

.photo-btns { display: flex; gap: 10px; }

.btn-photo {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--bg3); color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 14px; font-size: 13px;
    cursor: pointer; font-family: 'DM Sans', sans-serif;
    transition: all 0.15s;
}
.btn-photo:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.btn-import:hover { border-color: #3B82F6; color: #3B82F6; background: rgba(59,130,246,0.1); }

/* ===== PHOTO GRID ===== */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.photo-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    background: var(--bg3);
    animation: fadeIn 0.3s ease;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}
.photo-thumb:hover { transform: scale(1.02); }
.photo-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.photo-date-badge {
    position: absolute; bottom: 6px; left: 6px; right: 6px;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    color: white; font-size: 10px;
    border-radius: 5px; padding: 3px 6px;
    display: flex; align-items: center; gap: 4px;
}
.has-note::after {
    content: '📝';
    position: absolute; top: 6px; right: 6px;
    font-size: 12px; background: rgba(0,0,0,0.6);
    border-radius: 4px; padding: 2px 4px;
}

/* ===== CAMERA MODAL ===== */
.camera-card { max-width: 480px; }

.camera-container {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    margin-bottom: 16px;
    aspect-ratio: 4/3;
}
#cameraFeed, #cameraPreview {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}

.camera-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.btn-capture {
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--accent);
    border: 4px solid rgba(255,255,255,0.2);
    color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.btn-capture:hover { background: var(--accent2); transform: scale(1.05); }
.btn-capture:active { transform: scale(0.95); }

/* ===== PHOTO VIEWER ===== */
.photo-viewer-overlay {
    position: fixed; inset: 0; z-index: 600;
    background: rgba(0,0,0,0.96);
    display: flex; flex-direction: column;
    animation: fadeOverlay 0.2s;
}

.viewer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    gap: 12px;
}

.viewer-close {
    background: rgba(255,255,255,0.1); border: none; color: white;
    width: 36px; height: 36px; border-radius: 50%;
    font-size: 16px; cursor: pointer; transition: background 0.15s;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.viewer-close:hover { background: rgba(255,255,255,0.2); }

.viewer-meta { flex: 1; }
.viewer-date { font-size: 12px; color: rgba(255,255,255,0.5); }

.viewer-actions { display: flex; gap: 8px; }
.viewer-btn {
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    width: 40px; height: 40px;
    border-radius: 10px; cursor: pointer; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
}
.viewer-btn:hover { background: rgba(255,255,255,0.15); color: white; }
.viewer-btn.danger:hover { background: var(--danger-bg); border-color: rgba(239,68,68,0.4); color: var(--danger); }

.viewer-body {
    flex: 1; display: flex; align-items: center; justify-content: center;
    overflow: hidden; padding: 12px;
}
.viewer-body img {
    max-width: 100%; max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.viewer-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.note-area { display: flex; gap: 10px; }

.note-textarea {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: white;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    padding: 10px 12px;
    outline: none;
    resize: none;
    height: 42px;
    transition: border-color 0.15s;
}
.note-textarea:focus { border-color: var(--accent); height: 80px; }
.note-textarea::placeholder { color: rgba(255,255,255,0.3); }

.btn-save-note {
    background: var(--accent); color: white;
    border: none; border-radius: var(--radius-sm);
    padding: 10px 14px; font-size: 13px;
    cursor: pointer; font-family: 'DM Sans', sans-serif;
    white-space: nowrap; transition: all 0.15s;
}
.btn-save-note:hover { background: var(--accent2); }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .login-card { padding: 32px 20px; }
    .app-main { padding: 14px; }
    .folder-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
    .section-header { flex-wrap: wrap; }
    .btn-primary span { display: none; }
    .photo-btns { gap: 8px; }
    .key-btn { padding: 14px; font-size: 18px; }
    .modal-card { padding: 22px 18px; }
}

@media (max-width: 360px) {
    .folder-grid { grid-template-columns: 1fr 1fr; }
    .photo-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* ===== MULTIUSER ADDITIONS ===== */
.form-group { margin-bottom: 16px; }
.w-full { width: 100%; justify-content: center; padding: 13px; font-size: 15px; }

.user-chip {
    font-size: 13px; color: var(--text2);
    background: var(--bg3); border: 1px solid var(--border);
    padding: 5px 10px; border-radius: 20px;
}

.admin-badge {
    font-size: 10px; font-weight: 700; letter-spacing: 1px;
    background: var(--accent); color: white;
    padding: 3px 8px; border-radius: 20px;
}

.admin-setup-badge {
    display: inline-block;
    background: var(--accent-bg); border: 1px solid var(--accent);
    color: var(--accent); font-size: 13px;
    padding: 5px 12px; border-radius: 20px;
    margin-bottom: 10px;
}

/* Stats bar */
.stats-bar {
    display: grid; grid-template-columns: repeat(3,1fr); gap: 12px;
    margin-bottom: 8px;
}
.stat-card {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    text-align: center;
}
.stat-num {
    font-family: 'Syne', sans-serif; font-size: 26px; font-weight: 800;
    color: var(--accent);
}
.stat-label { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* User rows */
.user-row {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 10px; flex-wrap: wrap;
    animation: fadeIn 0.3s ease;
}
.user-row.user-inactive { opacity: 0.5; }

.user-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.user-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--accent-bg); border: 2px solid var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Syne', sans-serif; font-weight: 800; font-size: 18px;
    color: var(--accent); flex-shrink: 0;
}
.user-name { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 15px; }
.user-meta { font-size: 12px; color: var(--text3); margin-top: 3px; }
.user-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge-inactive {
    display: inline-block; font-size: 10px; background: var(--danger-bg);
    color: var(--danger); padding: 2px 7px; border-radius: 10px;
    font-family: 'DM Sans', sans-serif; font-weight: 400;
}

/* Small buttons */
.btn-ghost.small, .btn-danger.small {
    padding: 7px 12px; font-size: 12px;
}

/* Wide modal */
.wide-modal { max-width: 700px; width: 100%; }
.modal-header-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 4px;
}

/* Admin delete photo button */
.admin-del-photo {
    position: absolute; top: 6px; right: 6px;
    width: 26px; height: 26px; border-radius: 50%;
    background: rgba(239,68,68,0.85); border: none;
    color: white; font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s;
}
.photo-thumb:hover .admin-del-photo { opacity: 1; }

.photo-note-badge {
    position: absolute; top: 6px; left: 6px;
    background: rgba(0,0,0,0.6); border-radius: 4px; padding: 2px 4px;
    font-size: 12px;
}

@media (max-width: 480px) {
    .stats-bar { grid-template-columns: repeat(3,1fr); gap: 8px; }
    .stat-num { font-size: 20px; }
    .user-row { flex-direction: column; align-items: flex-start; }
    .user-actions { width: 100%; }
    .user-actions .btn-ghost, .user-actions .btn-danger { flex: 1; justify-content: center; }
}

/* ===========================
   FAB — Floating Action Button
   =========================== */
#fab-container {
    position: fixed;
    z-index: 800;
    width: 58px;
    height: 58px;
    /* prevent text selection while dragging */
    user-select: none;
    -webkit-user-select: none;
}

#fab-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(232,100,10,0.5);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    position: relative;
    z-index: 2;
    touch-action: none;
}
#fab-btn:hover  { background: var(--accent2); box-shadow: 0 6px 28px rgba(232,100,10,0.6); }
#fab-btn.fab-open { transform: scale(0.92); background: #555; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }

#fab-menu {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 160px;
    right: 0;
    opacity: 0;
    transform: translateY(8px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}
#fab-menu.fab-menu-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    text-decoration: none;
    color: var(--text);
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    box-shadow: var(--shadow);
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.fab-menu-item:hover { background: var(--bg3); border-color: var(--accent); color: var(--accent); }
.fab-menu-icon { font-size: 18px; }
.fab-menu-label { font-weight: 500; }

/* ===========================
   NOTES SYSTEM
   =========================== */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.note-card {
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.07);
    transition: transform 0.2s, box-shadow 0.2s;
    animation: fadeIn 0.3s ease;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.note-card:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(0,0,0,0.35); }

.note-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.note-card-title {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    word-break: break-word;
    line-height: 1.3;
    flex: 1;
}
.note-card-actions { display: flex; gap: 4px; flex-shrink: 0; }

.note-action-btn {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    border: none;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.note-action-btn:hover       { background: rgba(255,255,255,0.18); color: white; }
.note-action-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

.note-card-body {
    font-size: 13px;
    color: rgba(255,255,255,0.75);
    line-height: 1.5;
    flex: 1;
    word-break: break-word;
    white-space: pre-wrap;
}

.note-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 8px;
}
.note-date  { font-size: 11px; color: rgba(255,255,255,0.4); }
.note-attach-count { font-size: 11px; color: rgba(255,255,255,0.5); }

/* Note modal */
.note-modal-card { max-width: 500px; max-height: 90vh; overflow-y: auto; }

.note-body-textarea {
    width: 100%;
    min-height: 140px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    padding: 12px 14px;
    outline: none;
    resize: vertical;
    transition: border-color 0.15s;
    margin-bottom: 16px;
    line-height: 1.6;
}
.note-body-textarea:focus   { border-color: var(--accent); }
.note-body-textarea::placeholder { color: var(--text3); }

.note-color-swatch {
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
}
.note-color-swatch:hover  { transform: scale(1.2); }
.note-color-swatch.selected { border-color: rgba(255,255,255,0.8); box-shadow: 0 0 0 2px var(--border2); }

/* Attachments */
.attach-section { margin-bottom: 20px; }

.attach-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.attach-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    font-size: 12px;
    color: var(--text2);
    max-width: 200px;
}
.attach-thumb {
    width: 36px; height: 36px;
    object-fit: cover;
    border-radius: 5px;
    flex-shrink: 0;
}
.attach-icon { font-size: 20px; flex-shrink: 0; }
.attach-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}
.attach-remove {
    background: none; border: none;
    color: var(--text3); cursor: pointer;
    font-size: 13px; padding: 2px;
    transition: color 0.15s; flex-shrink: 0;
}
.attach-remove:hover { color: var(--danger); }

.btn-attach {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--bg3);
    border: 1px dashed var(--border2);
    color: var(--text2);
    border-radius: var(--radius-sm);
    padding: 9px 14px; font-size: 13px;
    cursor: pointer; font-family: 'DM Sans', sans-serif;
    transition: all 0.15s;
}
.btn-attach:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

/* Note viewer */
.note-viewer-card {
    max-width: 520px;
    max-height: 88vh;
    overflow-y: auto;
    width: 100%;
}
.note-viewer-header { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.note-viewer-title  { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 800; margin-bottom: 6px; word-break: break-word; }
.note-viewer-date   { font-size: 12px; color: rgba(255,255,255,0.45); margin-bottom: 16px; }
.note-viewer-body   {
    font-size: 15px; line-height: 1.7;
    color: rgba(255,255,255,0.85);
    white-space: pre-wrap; word-break: break-word;
    margin-bottom: 16px;
}

.viewer-attachments { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 12px; }
.viewer-attach-img  { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; cursor: pointer; transition: transform 0.2s; }
.viewer-attach-img:hover { transform: scale(1.05); }
.attach-file-link   { display: flex; align-items: center; gap: 6px; color: var(--accent); font-size: 13px; text-decoration: none; }
.attach-file-link:hover { text-decoration: underline; }

@media (max-width: 480px) {
    .notes-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .note-card  { min-height: 110px; padding: 12px; }
    .note-card-title { font-size: 13px; }
    .note-modal-card { max-height: 95vh; }
}
@media (max-width: 360px) {
    .notes-grid { grid-template-columns: 1fr; }
}

/* ===========================
   FAB ALERT INDICATOR
   =========================== */
#fab-alert-dot {
    position: absolute;
    top: 4px; right: 4px;
    width: 12px; height: 12px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg);
    animation: pulse-dot 1.5s infinite;
    z-index: 3;
}
@keyframes pulse-dot {
    0%,100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.3); opacity: 0.7; }
}
.fab-alert-badge {
    display: none;
    align-items: center; justify-content: center;
    width: 18px; height: 18px;
    background: var(--danger);
    color: white; font-size: 11px; font-weight: 800;
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
}

/* ===========================
   CREDITS MODULE
   =========================== */
.credit-summary-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 4px;
}
.credit-stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    transition: border-color 0.2s;
}
.credit-stat-card.danger-card { border-color: rgba(239,68,68,0.2); }
.credit-stat-card.danger-card.has-alert {
    border-color: var(--danger);
    background: var(--danger-bg);
    animation: pulse-border 2s infinite;
}
@keyframes pulse-border {
    0%,100% { border-color: var(--danger); }
    50%      { border-color: rgba(239,68,68,0.3); }
}
.credit-stat-num {
    font-family: 'Syne', sans-serif;
    font-size: 18px; font-weight: 800;
    color: var(--accent);
    word-break: break-all;
}
.credit-stat-label { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* Credits list */
.credits-list { display: flex; flex-direction: column; gap: 10px; }

.credit-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-left: 4px solid var(--credit-color, var(--accent));
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
    animation: fadeIn 0.3s ease;
}
.credit-card:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,0.3); }

.credit-card-left  { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.credit-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

.credit-color-dot {
    width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
}
.credit-color-dot.large { width: 20px; height: 20px; }

.credit-card-name {
    font-family: 'Syne', sans-serif; font-weight: 700; font-size: 15px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 200px;
}
.credit-card-meta  { font-size: 12px; color: var(--text3); margin-top: 2px; }
.credit-overdue-badge {
    display: inline-block; font-size: 11px;
    background: var(--danger-bg); color: var(--danger);
    border: 1px solid rgba(239,68,68,0.3);
    padding: 2px 8px; border-radius: 10px; margin-top: 4px;
}
.credit-mini-progress {
    width: 80px; height: 5px;
    background: var(--border); border-radius: 3px; overflow: hidden;
}
.credit-mini-fill {
    height: 100%; border-radius: 3px; transition: width 0.4s;
}
.credit-pct { font-size: 12px; color: var(--text2); font-weight: 500; }
.credit-card-actions { display: flex; gap: 6px; }

/* Detail view */
.btn-back-inline {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--text2); border-radius: var(--radius-sm);
    padding: 8px 14px; font-size: 13px; cursor: pointer;
    font-family: 'DM Sans', sans-serif; text-decoration: none;
    margin-bottom: 18px; transition: all 0.15s;
}
.btn-back-inline:hover { color: var(--text); border-color: var(--border2); }

.credit-detail-header { margin-bottom: 18px; }
.detail-title-row { display: flex; align-items: center; gap: 12px; }
.detail-credit-name {
    font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 800;
}

/* Progress bar */
.credit-progress-wrap { margin-bottom: 18px; }
.credit-progress-bar-bg {
    width: 100%; height: 10px;
    background: var(--bg3); border-radius: 5px; overflow: hidden; margin-bottom: 6px;
}
.credit-progress-bar-fill {
    height: 100%; border-radius: 5px; transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
}
.credit-progress-labels {
    display: flex; justify-content: space-between;
    font-size: 12px; color: var(--text3);
}

/* Money stats row */
.credit-money-row {
    display: grid; grid-template-columns: repeat(3,1fr);
    gap: 10px; margin-bottom: 8px;
}
.money-stat {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 10px; text-align: center;
}
.money-stat.success { border-color: rgba(16,185,129,0.3); background: rgba(16,185,129,0.05); }
.money-stat.danger  { border-color: rgba(239,68,68,0.3);  background: rgba(239,68,68,0.05);  }
.money-val   { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; word-break: break-all; }
.money-label { font-size: 11px; color: var(--text3); margin-top: 3px; }

/* Installment rows */
.installments-list { display: flex; flex-direction: column; gap: 8px; }

.installment-row {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 14px; gap: 10px;
    animation: fadeIn 0.25s ease; flex-wrap: wrap;
}
.installment-row.inst-paid    { border-color: rgba(16,185,129,0.3);  background: rgba(16,185,129,0.05); }
.installment-row.inst-overdue { border-color: rgba(239,68,68,0.4);   background: rgba(239,68,68,0.07); }
.installment-row.inst-pending { border-color: var(--border); }

.inst-left    { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.inst-status-icon { font-size: 18px; flex-shrink: 0; }
.inst-info    { min-width: 0; }
.inst-credit-name { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.inst-date    { font-size: 12px; color: var(--text3); }
.inst-value   { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; margin-top: 2px; }

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

.btn-pay {
    background: var(--success); color: white; border: none;
    border-radius: 8px; padding: 7px 14px; font-size: 13px;
    cursor: pointer; font-family: 'DM Sans', sans-serif;
    transition: opacity 0.15s; white-space: nowrap;
}
.btn-pay:hover { opacity: 0.85; }

.btn-unpay {
    background: transparent; color: var(--text3);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 6px 10px; font-size: 12px; cursor: pointer;
    font-family: 'DM Sans', sans-serif; transition: all 0.15s;
}
.btn-unpay:hover { color: var(--danger); border-color: rgba(239,68,68,0.4); }

.inst-edit-btn, .inst-del-btn {
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--text3); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.inst-edit-btn:hover { color: var(--accent); border-color: var(--accent); }
.inst-del-btn:hover  { color: var(--danger); border-color: rgba(239,68,68,0.4); background: var(--danger-bg); }

/* Money input */
.money-input-wrap {
    display: flex; align-items: center;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); overflow: hidden;
    transition: border-color 0.15s;
}
.money-input-wrap:focus-within { border-color: var(--accent); }
.money-prefix {
    padding: 0 12px; color: var(--text2); font-size: 16px;
    font-family: 'Syne', sans-serif; font-weight: 700;
    background: var(--bg3); border-right: 1px solid var(--border);
    height: 44px; display: flex; align-items: center;
}
.money-input {
    flex: 1; border: none !important; border-radius: 0 !important;
    background: transparent !important; margin-bottom: 0 !important;
    font-family: 'Syne', sans-serif; font-weight: 600; font-size: 16px;
}

/* Form label */
.form-label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; }

/* Responsive */
@media (max-width: 480px) {
    .credit-summary-bar { gap: 8px; }
    .credit-stat-num { font-size: 14px; }
    .credit-card { flex-direction: column; align-items: flex-start; }
    .credit-card-right { align-items: flex-start; width: 100%; flex-direction: row; flex-wrap: wrap; }
    .credit-mini-progress { width: 60px; }
    .credit-money-row { grid-template-columns: repeat(3,1fr); gap: 6px; }
    .money-val { font-size: 12px; }
    .installment-row { flex-direction: column; align-items: flex-start; }
    .inst-actions { width: 100%; justify-content: flex-end; }
}
