/* ============================================================
   Transfer · UI v2 — premium look
   ============================================================ */

@import url('https://rsms.me/inter/inter.css');

:root {
    /* Letro brand palette (corporate green #489E35) */
    --brand-50:  #ebf7e8;
    --brand-100: #d3f0cd;
    --brand-200: #a5e29a;
    --brand-300: #74cf63;
    --brand-400: #58b842;
    --brand-500: #489E35;
    --brand-600: #3d872c;
    --brand-700: #316b22;
    --brand-800: #25511a;

    --accent:    #2d5e21;
    --accent-2:  #74cf63;

    /* Surfaces (light) */
    --bg:           #f6f7fb;
    --bg-app:       linear-gradient(180deg, #f8f9fd 0%, #f1f3fa 100%);
    --bg-elev:      #ffffff;
    --bg-glass:     rgba(255, 255, 255, 0.72);
    --bg-glass-2:   rgba(255, 255, 255, 0.55);
    --bg-hover:     #f1f3fb;
    --bg-active:    #e9edff;
    --bg-subtle:    #fafbfe;

    /* Text */
    --text:         #0f172a;
    --text-muted:   #64748b;
    --text-soft:    #94a3b8;
    --text-on-brand:#ffffff;

    /* Borders & rings */
    --border:       #e6e9f2;
    --border-soft:  #eef0f7;
    --ring:         0 0 0 3px rgba(72, 158, 53, 0.22);

    /* Status */
    --primary:        var(--brand-600);
    --primary-hover:  var(--brand-700);
    --primary-soft:   var(--brand-50);
    --danger:         #e11d48;
    --danger-hover:   #be123c;
    --danger-soft:    #ffe4e6;
    --success:        #10b981;
    --success-soft:   #d1fae5;
    --warning:        #f59e0b;
    --warning-soft:   #fef3c7;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
    --shadow-sm: 0 2px 4px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
    --shadow-md: 0 8px 24px -8px rgba(15,23,42,.10), 0 2px 6px rgba(15,23,42,.06);
    --shadow-lg: 0 24px 48px -12px rgba(15,23,42,.18), 0 4px 12px rgba(15,23,42,.08);
    --shadow-xl: 0 40px 80px -20px rgba(15,23,42,.25);
    --shadow-brand: 0 8px 22px -6px rgba(72,158,53,.42);

    /* Radii */
    --r-xs: 6px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;

    /* Motion */
    --ease: cubic-bezier(.4,.0,.2,1);
    --ease-out: cubic-bezier(.16,1,.3,1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:           #0c1410;
        --bg-app:       radial-gradient(1200px 600px at 80% -10%, rgba(72,158,53,.16), transparent 60%),
                        radial-gradient(1000px 500px at -10% 110%, rgba(45,94,33,.14), transparent 60%),
                        linear-gradient(180deg, #0c1410 0%, #0f1813 100%);
        --bg-elev:      #131b16;
        --bg-glass:     rgba(20, 30, 22, 0.65);
        --bg-glass-2:   rgba(20, 30, 22, 0.4);
        --bg-hover:     #1c2820;
        --bg-active:    #25362a;
        --bg-subtle:    #0f1812;

        --text:         #e6efe7;
        --text-muted:   #93a597;
        --text-soft:    #5e7064;

        --border:       #243029;
        --border-soft:  #1b251f;
        --ring:         0 0 0 3px rgba(72, 158, 53, 0.32);

        --primary-soft: #1b2e16;
        --danger-soft:  #3a131e;
        --success-soft: #0e3325;
        --warning-soft: #3b2a0d;

        --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
        --shadow-sm: 0 2px 4px rgba(0,0,0,.35);
        --shadow-md: 0 8px 24px -6px rgba(0,0,0,.55);
        --shadow-lg: 0 28px 60px -12px rgba(0,0,0,.7);
        --shadow-xl: 0 40px 80px -20px rgba(0,0,0,.8);
        --shadow-brand: 0 10px 28px -6px rgba(72,158,53,.5);
    }
}

/* ===================================================================
   Base
   =================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg-app);
    background-color: var(--bg);
    background-attachment: fixed;
    font-size: 14px;
    line-height: 1.55;
    font-feature-settings: "cv02","cv03","cv04","cv11";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
@supports (font-variation-settings: normal) {
    body { font-family: 'Inter var', 'Inter', sans-serif; }
}

button { font-family: inherit; font-size: inherit; cursor: pointer; }
a { color: var(--primary); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--primary-hover); }

::selection { background: var(--brand-200); color: var(--brand-800); }
@media (prefers-color-scheme: dark) {
    ::selection { background: var(--brand-600); color: #fff; }
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-soft); background-clip: padding-box; border: 2px solid transparent; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: .85em; }
code { background: var(--bg-hover); padding: 2px 6px; border-radius: var(--r-xs); font-size: .9em; font-family: 'SF Mono', ui-monospace, Menlo, monospace; }

/* ===================================================================
   AUTH (login, setup)
   =================================================================== */
.auth-body {
    position: relative;
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    overflow: hidden;
    background:
        radial-gradient(1200px 700px at 20% 10%, #489E35 0%, transparent 55%),
        radial-gradient(1000px 600px at 90% 90%, #316b22 0%, transparent 55%),
        radial-gradient(800px 500px at 60% 50%, #74cf63 0%, transparent 60%),
        linear-gradient(135deg, #0c1d0a 0%, #122d12 50%, #1a3f1c 100%);
}
.auth-body::before {
    content: ''; position: absolute; inset: 0;
    background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.18) 1px, transparent 0);
    background-size: 32px 32px;
    opacity: .25;
    pointer-events: none;
}

.auth-card {
    position: relative;
    width: 100%; max-width: 420px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: var(--r-xl);
    padding: 40px 36px;
    box-shadow: var(--shadow-xl);
    color: #fff;
}

.auth-card .brand {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 28px;
}
.auth-card .brand .logo {
    width: 48px; height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, #fff 0%, #d3f0cd 100%);
    color: var(--brand-700);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 20px -4px rgba(255,255,255,.4), inset 0 -2px 0 rgba(0,0,0,.05);
}
.auth-card .brand .text h1 { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; color: #fff; }
.auth-card .brand .text p  { margin: 0; font-size: .85em; color: rgba(255,255,255,.65); }

.auth-card form { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.auth-card label {
    display: flex; flex-direction: column; gap: 7px;
    font-weight: 500; font-size: .85em;
    color: rgba(255,255,255,.85);
    letter-spacing: .01em;
    text-transform: uppercase;
}
.auth-card input {
    padding: 12px 14px;
    border: 1.5px solid rgba(255,255,255,.18);
    border-radius: var(--r-sm);
    background: rgba(255,255,255,.08);
    color: #fff;
    font-size: 1em;
    font-family: inherit;
    transition: border-color .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
}
.auth-card input::placeholder { color: rgba(255,255,255,.45); }
.auth-card input:focus {
    outline: none;
    border-color: rgba(255,255,255,.55);
    background: rgba(255,255,255,.14);
    box-shadow: 0 0 0 4px rgba(255,255,255,.08);
}

.auth-card .btn.primary {
    margin-top: 8px;
    background: #fff;
    color: var(--brand-700);
    font-weight: 600;
    padding: 12px;
    border: none;
    box-shadow: 0 8px 20px -6px rgba(0,0,0,.35);
}
.auth-card .btn.primary:hover { background: #f5fbf3; box-shadow: 0 12px 28px -6px rgba(0,0,0,.4); }

.auth-card .alert {
    padding: 11px 14px; border-radius: var(--r-sm); font-size: .9em;
    margin-top: 0;
    border: 1px solid transparent;
}
.auth-card .alert.error    { background: rgba(244,63,94,.18);  color: #ffd5db; border-color: rgba(244,63,94,.4); }
.auth-card .alert.success  { background: rgba(16,185,129,.18); color: #c8f7e3; border-color: rgba(16,185,129,.4); }

.auth-card .muted, .auth-card .small { color: rgba(255,255,255,.55); }
.auth-card code { background: rgba(255,255,255,.12); color: #fff; }

/* ===================================================================
   BUTTONS
   =================================================================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    font-weight: 500;
    font-size: .92em;
    line-height: 1;
    transition: background .12s, border-color .12s, color .12s;
    white-space: nowrap;
    user-select: none;
}
.btn:hover { background: var(--bg-hover); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn.primary {
    background: linear-gradient(180deg, var(--brand-500) 0%, var(--brand-600) 100%);
    color: #fff;
    border-color: var(--brand-600);
    box-shadow: var(--shadow-brand);
}
.btn.primary:hover {
    background: linear-gradient(180deg, var(--brand-600) 0%, var(--brand-700) 100%);
    border-color: var(--brand-700);
}

.btn.ghost { background: transparent; border-color: transparent; color: var(--text); }
.btn.ghost:hover { background: var(--bg-hover); border-color: var(--border-soft); }

.btn.subtle { background: var(--bg-subtle); border-color: var(--border-soft); }
.btn.subtle:hover { background: var(--bg-hover); }

.btn.danger {
    background: linear-gradient(180deg, #f43f5e 0%, var(--danger) 100%);
    color: #fff; border-color: var(--danger);
    box-shadow: 0 6px 18px -6px rgba(225,29,72,.5);
}
.btn.danger:hover { filter: brightness(1.05); transform: translateY(-1px); }

.btn.icon {
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--r-xs);
}
.btn.icon:hover { background: var(--bg-hover); color: var(--text); }

.btn.block { width: 100%; padding: 11px 14px; }
.btn.lg    { padding: 12px 22px; font-size: 1em; }

.btn[disabled], .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* ===================================================================
   APP LAYOUT
   =================================================================== */
.app-body {
    display: grid;
    grid-template-columns: 264px 1fr;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar -------------------------------------------------------- */
.sidebar {
    position: relative;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: 18px 14px;
    display: flex; flex-direction: column; gap: 10px;
    overflow: hidden;
}
.sidebar::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(400px 200px at 0% 0%, rgba(72,158,53,.10), transparent 60%),
        radial-gradient(300px 200px at 100% 100%, rgba(45,94,33,.08), transparent 60%);
    pointer-events: none;
    z-index: 0;
}
.sidebar > * { position: relative; z-index: 1; }

.sidebar .brand {
    display: flex; align-items: center; gap: 11px;
    padding: 6px 8px 18px;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 8px;
}
.sidebar .brand .logo {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand-500) 0%, var(--accent) 100%);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-brand);
}
.sidebar .brand .name {
    font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em;
}
.sidebar .brand .name small {
    display: block; font-weight: 500; font-size: .7rem;
    color: var(--text-muted); letter-spacing: .04em; text-transform: uppercase;
}

.sidebar .section-label {
    font-size: .68rem; font-weight: 600;
    color: var(--text-soft);
    text-transform: uppercase; letter-spacing: .08em;
    padding: 12px 8px 4px;
}

.sidebar .nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.sidebar .nav-item:hover { background: var(--bg-hover); color: var(--text); }
.sidebar .nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(72,158,53,.20);
}
.sidebar .nav-item .badge {
    margin-left: auto;
    font-size: .72em; font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-subtle);
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
}

.storage {
    margin-top: auto;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: linear-gradient(180deg, var(--bg-subtle) 0%, var(--bg-elev) 100%);
}
.storage-header { display: flex; justify-content: space-between; align-items: center; }
.storage-label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.storage-icon { color: var(--brand-500); }
.storage-value { font-weight: 700; margin-top: 4px; font-size: 1rem; letter-spacing: -.01em; }
.storage-bar { height: 6px; border-radius: 999px; background: var(--bg-hover); margin-top: 10px; overflow: hidden; }
.storage-bar > div {
    height: 100%; width: 8%;
    background: linear-gradient(90deg, var(--brand-500) 0%, var(--accent) 100%);
    border-radius: inherit;
    transition: width .5s var(--ease-out);
}
.storage-meta { font-size: .75em; color: var(--text-muted); margin-top: 6px; }

.sidebar-foot {
    padding-top: 12px;
    border-top: 1px solid var(--border-soft);
}
.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 6px;
    border-radius: var(--r-sm);
    transition: background .15s var(--ease);
}
.user-chip:hover { background: var(--bg-hover); }
.user-chip .avatar {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand-500) 0%, var(--accent-2) 100%);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .95rem;
    letter-spacing: -.01em;
    box-shadow: 0 4px 10px -2px rgba(72,158,53,.35);
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95em; }
.user-role {
    font-size: .7em;
    color: var(--brand-600);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: .06em;
}

/* Main area -------------------------------------------------------- */
.main {
    display: flex; flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: transparent;
}

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    padding: 18px 28px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 5;
}

.topbar-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }

.breadcrumb {
    display: flex; align-items: center; gap: 2px;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -.01em;
    min-width: 0; overflow: hidden;
}
.breadcrumb a, .breadcrumb span {
    padding: 4px 9px;
    border-radius: var(--r-xs);
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background .12s var(--ease), color .12s var(--ease);
}
.breadcrumb a:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.breadcrumb .sep {
    color: var(--text-soft); padding: 0 2px; cursor: default;
    font-weight: 400;
}
.breadcrumb .current { color: var(--text); cursor: default; }

.topbar .meta { font-size: .8rem; color: var(--text-muted); padding-left: 9px; font-weight: 500; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.search-wrap {
    position: relative;
}
.search-wrap svg {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-soft); pointer-events: none;
}
.topbar-actions input[type=search] {
    padding: 9px 14px 9px 36px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-elev);
    color: var(--text);
    width: 240px;
    font-family: inherit;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), width .25s var(--ease);
}
.topbar-actions input[type=search]:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: var(--ring);
    width: 280px;
}

.view-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--bg-elev);
}
.view-toggle button {
    padding: 8px 11px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    transition: background .12s var(--ease), color .12s var(--ease);
}
.view-toggle button:hover { background: var(--bg-hover); color: var(--text); }
.view-toggle button.active {
    background: var(--primary-soft);
    color: var(--primary);
}

/* Action bar (selection) ------------------------------------------- */
.actionbar {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    z-index: 55;
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px 6px 18px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
    max-width: calc(100vw - 32px);
    flex-wrap: wrap;
}
.actionbar #selection-count {
    display: inline-flex; align-items: center; gap: 8px;
    font-weight: 600;
    color: var(--primary);
    padding-right: 6px;
    border-right: 1px solid var(--border-soft);
    margin-right: 4px;
    white-space: nowrap;
}
.actionbar #selection-count::before {
    content: ''; width: 8px; height: 8px; border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
    flex-shrink: 0;
}
.actionbar .btn {
    padding: 7px 14px;
    border-radius: 999px;
    font-size: .9em;
}

/* ===================================================================
   FILES (grid + list)
   =================================================================== */
.dropzone {
    flex: 1;
    position: relative;
    overflow: auto;
    padding: 22px 28px 28px;
}

.files.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}
.files.list { display: flex; flex-direction: column; gap: 4px; }

/* List header */
.files.list .list-header {
    display: grid;
    grid-template-columns: 32px 1fr 120px 180px 40px;
    align-items: center; gap: 14px;
    padding: 8px 14px;
    font-size: .72em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
    border-bottom: 1px solid var(--border-soft);
    cursor: default;
    user-select: none;
}

/* GRID item */
.files.grid .item {
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 18px 12px 14px;
    display: flex; flex-direction: column; align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: border-color .12s, box-shadow .12s, background .12s;
    position: relative;
    user-select: none;
    overflow: hidden;
}
.files.grid .item:hover {
    border-color: var(--brand-300);
    box-shadow: var(--shadow-sm);
    background: var(--bg-hover);
}
.files.grid .item.selected {
    background: var(--primary-soft);
    border-color: var(--brand-500);
    box-shadow: 0 0 0 1px var(--brand-500), var(--shadow-md);
}
.files.grid .item.selected::after {
    content: '';
    position: absolute; top: 8px; right: 8px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--brand-500);
    box-shadow: 0 0 0 3px #fff, var(--shadow-sm);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'%3E%3Cpath d='M6.5 11.5l-3-3 1-1 2 2 4.5-4.5 1 1z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: center;
    background-size: 14px;
}
@media (prefers-color-scheme: dark) {
    .files.grid .item.selected::after { box-shadow: 0 0 0 3px var(--bg-elev), var(--shadow-sm); }
}

.files.grid .item .icon-wrap {
    width: 64px; height: 64px;
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-subtle);
}
.files.grid .item .icon { width: 36px; height: 36px; }
.files.grid .item .name {
    text-align: center;
    font-size: .88rem;
    font-weight: 500;
    word-break: break-word;
    line-height: 1.35;
    max-height: 2.7em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.files.grid .item .meta {
    font-size: .72rem;
    color: var(--text-muted);
    display: flex; align-items: center; gap: 4px;
}

/* LIST item */
.files.list .item {
    display: grid;
    grid-template-columns: 32px 1fr 120px 180px 40px;
    align-items: center; gap: 14px;
    padding: 10px 14px;
    border-radius: var(--r-sm);
    cursor: pointer;
    border: 1px solid transparent;
    user-select: none;
    transition: background .12s var(--ease), border-color .12s var(--ease);
}
.files.list .item:hover { background: var(--bg-hover); }
.files.list .item.selected {
    background: var(--primary-soft);
    border-color: rgba(72,158,53,.25);
}
.files.list .item .icon-wrap {
    width: 30px; height: 30px;
    border-radius: var(--r-xs);
    background: var(--bg-subtle);
    display: flex; align-items: center; justify-content: center;
}
.files.list .item .icon { width: 18px; height: 18px; }
.files.list .item .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files.list .item .meta { color: var(--text-muted); font-size: .85em; }
.files.list .item .row-actions { display: flex; justify-content: flex-end; opacity: 0; transition: opacity .15s var(--ease); }
.files.list .item:hover .row-actions { opacity: 1; }

/* File-type icon colors */
.icon-tone-folder  { color: #f59e0b; background: linear-gradient(135deg, rgba(245,158,11,.13), rgba(245,158,11,.05)) !important; }
.icon-tone-image   { color: #10b981; background: linear-gradient(135deg, rgba(16,185,129,.13), rgba(16,185,129,.05)) !important; }
.icon-tone-video   { color: #ef4444; background: linear-gradient(135deg, rgba(239,68,68,.13), rgba(239,68,68,.05)) !important; }
.icon-tone-audio   { color: #6d28d9; background: linear-gradient(135deg, rgba(109,40,217,.13), rgba(109,40,217,.05)) !important; }
.icon-tone-doc     { color: #3b82f6; background: linear-gradient(135deg, rgba(59,130,246,.13), rgba(59,130,246,.05)) !important; }
.icon-tone-code    { color: #06b6d4; background: linear-gradient(135deg, rgba(6,182,212,.13), rgba(6,182,212,.05)) !important; }
.icon-tone-archive { color: #f97316; background: linear-gradient(135deg, rgba(249,115,22,.13), rgba(249,115,22,.05)) !important; }
.icon-tone-pdf     { color: #dc2626; background: linear-gradient(135deg, rgba(220,38,38,.13), rgba(220,38,38,.05)) !important; }
.icon-tone-file    { color: var(--text-muted); }

/* Empty state */
.empty {
    height: 100%;
    min-height: 380px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--text-muted);
    text-align: center;
    gap: 10px;
    padding: 40px;
}
.empty .empty-icon {
    width: 96px; height: 96px;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--brand-50) 0%, rgba(72,158,53,.10) 100%);
    color: var(--brand-500);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 8px;
}
@media (prefers-color-scheme: dark) {
    .empty .empty-icon { background: linear-gradient(135deg, rgba(72,158,53,.22), rgba(45,94,33,.12)); }
}
.empty h3 { margin: 4px 0 0; color: var(--text); font-size: 1.1rem; font-weight: 600; letter-spacing: -.01em; }
.empty p { margin: 0; max-width: 320px; }
.empty .hint {
    margin-top: 18px;
    font-size: .82em;
    padding: 7px 12px;
    background: var(--bg-elev);
    border: 1px dashed var(--border);
    border-radius: var(--r-sm);
}
.empty kbd {
    font-family: 'SF Mono', ui-monospace, Menlo, monospace;
    font-size: .8em;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg);
    box-shadow: 0 1px 0 var(--border);
}

/* Drop overlay */
.drop-overlay {
    position: absolute; inset: 12px;
    background: rgba(72,158,53,.10);
    border: 2.5px dashed var(--brand-500);
    color: var(--brand-700);
    display: none;
    align-items: center; justify-content: center;
    pointer-events: none;
    border-radius: var(--r-lg);
    z-index: 20;
}
@media (prefers-color-scheme: dark) {
    .drop-overlay { color: var(--brand-300); background: rgba(72,158,53,.14); }
}
.drop-overlay > div {
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    font-size: 1.3em; font-weight: 600;
}
.drop-overlay .icon-circle {
    width: 84px; height: 84px;
    border-radius: 50%;
    background: var(--brand-500);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 12px 28px -8px rgba(72,158,53,.5);
}

.dropzone.dragover .drop-overlay { display: flex; }

/* ===================================================================
   UPLOADS TRAY
   =================================================================== */
.uploads {
    position: fixed; right: 22px; bottom: 22px;
    width: 380px; max-height: 60vh;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xl);
    z-index: 50;
    display: none;
    overflow: hidden;
}
.uploads.active { display: flex; flex-direction: column; }

.uploads-header {
    padding: 14px 16px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg-subtle) 100%);
    display: flex; justify-content: space-between; align-items: center;
}
.uploads-header .title { display: flex; align-items: center; gap: 9px; }
.uploads-header .title .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--brand-500);
    box-shadow: 0 0 0 4px var(--primary-soft);
}
.uploads-header .summary {
    font-size: .8em; color: var(--text-muted); font-weight: 500;
}
.uploads-list { overflow-y: auto; max-height: 50vh; }

.upload-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-soft);
    display: flex; flex-direction: column; gap: 6px;
}
.upload-item:last-child { border-bottom: none; }
.upload-item .row1 { display: flex; align-items: center; gap: 10px; }
.upload-item .row1 .icon-wrap {
    width: 32px; height: 32px;
    border-radius: var(--r-xs);
    background: var(--bg-subtle);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.upload-item .name {
    font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1;
    font-size: .92em;
}
.upload-item .pct {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    font-size: .82em;
    font-weight: 600;
}
.upload-item .bar {
    height: 5px;
    background: var(--bg-hover);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}
.upload-item .bar > div {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-500) 0%, var(--accent) 100%);
    border-radius: inherit;
    transition: width .2s linear;
}
.upload-item.done  .bar > div { background: linear-gradient(90deg, #10b981 0%, #34d399 100%); }
.upload-item.done  .pct { color: var(--success); }
.upload-item.error .bar > div { background: var(--danger); }
.upload-item.error .pct { color: var(--danger); }

/* ===================================================================
   MODAL
   =================================================================== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 26px;
    min-width: 400px;
    max-width: 92vw;
    box-shadow: var(--shadow-xl);
}
.modal h3 {
    margin: 0 0 16px;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -.01em;
}
.modal p {
    margin: 0 0 18px;
    color: var(--text-muted);
    line-height: 1.55;
}
.modal input[type=text] {
    width: 100%; padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 1em;
    font-family: inherit;
    margin-bottom: 18px;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.modal input[type=text]:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: var(--ring);
}
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ===================================================================
   TOASTS
   =================================================================== */
.toast-stack {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
    z-index: 200;
    display: flex; flex-direction: column; gap: 10px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: 11px 18px 11px 16px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    min-width: 240px;
    display: flex; align-items: center; gap: 10px;
    font-weight: 500;
    transition: opacity .2s;
    position: relative;
    overflow: hidden;
}
.toast::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--brand-500);
}
.toast.error::before   { background: var(--danger); }
.toast.success::before { background: var(--success); }
.toast .toast-icon {
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.toast.error   .toast-icon { background: var(--danger); }
.toast.success .toast-icon { background: var(--success); }
.toast:not(.error):not(.success) .toast-icon { background: var(--brand-500); }

/* ===================================================================
   CONTEXT MENU
   =================================================================== */
.ctxmenu {
    position: fixed;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xl);
    padding: 6px;
    min-width: 200px;
    z-index: 90;
}
.ctxmenu button {
    display: flex; align-items: center; gap: 11px;
    width: 100%;
    padding: 9px 11px;
    background: transparent; border: none; border-radius: var(--r-xs);
    color: var(--text);
    text-align: left;
    font-weight: 500;
    transition: background .12s var(--ease), color .12s var(--ease);
}
.ctxmenu button:hover { background: var(--bg-hover); }
.ctxmenu button.danger { color: var(--danger); }
.ctxmenu button.danger:hover { background: var(--danger-soft); }
.ctxmenu button svg { color: var(--text-muted); }
.ctxmenu button:hover svg { color: var(--text); }
.ctxmenu button.danger svg { color: var(--danger); }
.ctxmenu hr { border: none; border-top: 1px solid var(--border-soft); margin: 4px 0; }

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 900px) {
    .topbar-actions input[type=search] { width: 180px; }
    .topbar-actions input[type=search]:focus { width: 200px; }
}

@media (max-width: 720px) {
    .app-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .sidebar {
        flex-direction: row;
        padding: 10px 14px;
        gap: 10px;
        flex-wrap: nowrap;
        overflow-x: auto;
        align-items: center;
    }
    .sidebar::before { display: none; }
    .sidebar .brand { padding: 0; border: none; margin: 0; flex-shrink: 0; }
    .sidebar .section-label { display: none; }
    .sidebar .nav-item { padding: 8px 10px; font-size: .85em; flex-shrink: 0; }
    .sidebar .btn.block { width: auto; }
    .storage, .sidebar-foot { display: none; }

    .topbar { padding: 12px 16px; }
    .breadcrumb { font-size: 1rem; }
    .topbar-actions input[type=search] { width: 130px; }
    .topbar-actions input[type=search]:focus { width: 150px; }
    .actionbar { padding: 8px 16px; }
    .dropzone { padding: 14px; }
    .files.grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
    .files.list .item { grid-template-columns: 28px 1fr 80px 40px; }
    .files.list .item .meta:nth-of-type(2) { display: none; }
    .files.list .list-header { grid-template-columns: 28px 1fr 80px 40px; }
    .files.list .list-header > :nth-child(4) { display: none; }
    .uploads { left: 12px; right: 12px; bottom: 12px; width: auto; }
    .modal { min-width: 0; width: 100%; }
}

/* ===================================================================
   ADMIN PANEL
   =================================================================== */
.admin-main { padding: 28px; overflow-y: auto; }
.admin-grid {
    display: grid;
    gap: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
}
.card-header h2 {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 600;
    letter-spacing: -.01em;
    display: flex; align-items: center; gap: 10px;
}
.card-header h2 .badge-icon {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--r-xs);
    background: var(--primary-soft);
    color: var(--primary);
}
.card-header p { margin: 4px 0 0; font-size: .85em; color: var(--text-muted); font-weight: 400; }
.card-body { padding: 22px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
    font-size: .82em;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.field .hint { font-size: .78em; color: var(--text-soft); }
.field input[type=text],
.field input[type=number],
.field input[type=password],
.field select {
    padding: 10px 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg);
    color: var(--text);
    font-size: .95rem;
    font-family: inherit;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: var(--ring);
    background: var(--bg-elev);
}

.card-footer {
    padding: 14px 22px;
    background: var(--bg-subtle);
    border-top: 1px solid var(--border-soft);
    display: flex; gap: 10px; justify-content: flex-end; align-items: center;
}
.card-footer .status { margin-right: auto; font-size: .85em; color: var(--text-muted); }

/* Stats row */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}
.stat {
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: linear-gradient(180deg, var(--bg-subtle) 0%, var(--bg-elev) 100%);
}
.stat .stat-label {
    font-size: .72rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .06em;
}
.stat .stat-value {
    font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em;
    margin-top: 6px;
}
.stat .stat-icon {
    width: 36px; height: 36px;
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary);
    background: var(--primary-soft);
    margin-bottom: 10px;
}

/* Table */
.table-wrap { overflow-x: auto; }
table.users {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}
table.users th, table.users td {
    padding: 12px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
table.users th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--bg-subtle);
}
table.users tbody tr { transition: background .12s var(--ease); }
table.users tbody tr:hover { background: var(--bg-hover); }
table.users tbody tr:last-child td { border-bottom: none; }
table.users .user-cell { display: flex; align-items: center; gap: 11px; }
table.users .user-cell .avatar {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand-500) 0%, var(--accent-2) 100%);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: .82rem;
}
table.users .user-cell .uname { font-weight: 600; }
table.users .user-cell .urole { font-size: .74em; color: var(--text-muted); }
table.users .row-actions { display: flex; justify-content: flex-end; gap: 4px; }

.tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.tag.admin   { background: var(--primary-soft); color: var(--primary); }
.tag.user    { background: var(--bg-hover);     color: var(--text-muted); }
.tag.you     { background: var(--success-soft); color: var(--success); }

/* Mini bar inside row */
.mini-bar {
    display: flex; align-items: center; gap: 8px;
    min-width: 140px;
}
.mini-bar .bar { flex: 1; height: 5px; background: var(--bg-hover); border-radius: 999px; overflow: hidden; }
.mini-bar .bar > div {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-500) 0%, var(--accent) 100%);
    border-radius: inherit;
}
.mini-bar .bar.warn > div  { background: var(--warning); }
.mini-bar .bar.full > div  { background: var(--danger); }
.mini-bar .pct { font-variant-numeric: tabular-nums; font-size: .8em; color: var(--text-muted); width: 40px; text-align: right; }

/* Big modal (forms) */
.modal.lg { min-width: 480px; }
.modal .modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) {
    .modal.lg { min-width: 0; }
    .modal .modal-row { grid-template-columns: 1fr; }
}

.empty-row {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

/* Language picker (account page) */
.lang-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.lang-card {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-elev);
    cursor: pointer;
    transition: border-color .12s, background .12s;
    user-select: none;
}
.lang-card:hover { border-color: var(--brand-300); background: var(--bg-hover); }
.lang-card.active {
    border-color: var(--brand-500);
    background: var(--primary-soft);
    box-shadow: 0 0 0 1px var(--brand-500);
}
.lang-card input[type=radio] {
    position: absolute; opacity: 0; pointer-events: none;
}
.lang-card .flag { font-size: 1.5rem; line-height: 1; }
.lang-card .lang-name {
    font-weight: 600;
    flex: 1;
}
.lang-card .lang-code {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-subtle);
    padding: 3px 8px;
    border-radius: 999px;
    letter-spacing: .04em;
}
.lang-card.active .lang-code {
    background: var(--brand-500);
    color: #fff;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}
