:root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1e293b;
    --surface-hover: #1a2438;
    --border: #263248;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-soft: rgba(59, 130, 246, 0.14);
    --success: #10b981;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --radius: 10px;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

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

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

code {
    background: var(--surface-2);
    padding: 2px 6px;
    border-radius: 5px;
    font-size: 12.5px;
}

/* Auth Screens */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top, #172554 0%, var(--bg) 55%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: var(--shadow);
}

.brand-badge {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}

.brand-badge svg {
    width: 24px;
    height: 24px;
}

.auth-card h1 {
    margin: 0 0 8px;
    font-size: 21px;
    font-weight: 700;
}

.auth-sub {
    margin: 0 0 22px;
    color: var(--text-muted);
    font-size: 13.5px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-form label,
.modal-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="search"],
select {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
    white-space: nowrap;
}

.btn:active {
    transform: translateY(1px);
}

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

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

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

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

.btn-secondary {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
    background: #273549;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-2);
    color: var(--text);
}

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

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

.btn-sm {
    padding: 5px 10px;
    font-size: 12.5px;
}

.btn-full {
    width: 100%;
    padding: 11px 16px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}

.icon-btn.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

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

/* App Shell */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.logo-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-mark svg {
    width: 20px;
    height: 20px;
}

.app-title {
    font-size: 15.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.storage-stats {
    font-size: 12px;
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.main-container {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 22px 20px 80px;
    flex: 1;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.toolbar-actions,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrap svg {
    position: absolute;
    left: 10px;
    width: 15px;
    height: 15px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-wrap input {
    padding: 8px 12px 8px 32px;
    width: 210px;
    font-size: 13.5px;
}

.select-input {
    padding: 8px 10px;
    font-size: 13.5px;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 14px;
    font-size: 13.5px;
    color: var(--text-muted);
}

.crumb-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
}

.crumb-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}

.crumb-btn.active {
    color: var(--text);
    cursor: default;
}

.crumb-btn.active:hover {
    background: transparent;
}

.crumb-sep {
    color: #475569;
    user-select: none;
}

/* File Table Card */
.file-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.table-wrap {
    overflow-x: auto;
}

.file-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.file-table th {
    padding: 11px 14px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
    background: rgba(15, 23, 42, 0.55);
    border-bottom: 1px solid var(--border);
}

.file-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(38, 50, 72, 0.55);
    vertical-align: middle;
}

.file-table tbody tr:last-child td {
    border-bottom: none;
}

.file-table tbody tr:hover {
    background: var(--surface-hover);
}

.col-check {
    width: 40px;
    text-align: center;
}

.col-size {
    width: 110px;
    color: var(--text-muted);
    white-space: nowrap;
}

.col-date {
    width: 165px;
    color: var(--text-muted);
    white-space: nowrap;
}

.col-actions {
    width: 190px;
    text-align: right;
    white-space: nowrap;
}

.item-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}

.item-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.item-icon svg {
    width: 17px;
    height: 17px;
}

.item-icon.dir {
    background: rgba(245, 158, 11, 0.14);
    color: #fbbf24;
}

.item-icon.file {
    background: var(--accent-soft);
    color: #60a5fa;
}

.item-name-btn {
    background: none;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 0;
    cursor: pointer;
    text-align: left;
    word-break: break-word;
}

.item-name-btn:hover {
    color: #60a5fa;
    text-decoration: underline;
}

.share-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #34d399;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 2px 7px;
    border-radius: 999px;
    margin-left: 6px;
    cursor: pointer;
}

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

/* Empty State */
.empty-state {
    padding: 56px 24px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state svg {
    width: 44px;
    height: 44px;
    color: #475569;
    margin-bottom: 12px;
}

.empty-title {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.empty-sub {
    margin: 0;
    font-size: 13.5px;
}

/* Drag & Drop Overlay */
.drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 17, 32, 0.82);
    backdrop-filter: blur(4px);
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    pointer-events: none;
}

.drop-overlay-box {
    border: 2px dashed var(--accent);
    background: rgba(30, 41, 59, 0.9);
    border-radius: 16px;
    padding: 48px 56px;
    text-align: center;
    color: var(--text);
}

.drop-overlay-box svg {
    width: 48px;
    height: 48px;
    color: var(--accent);
    margin-bottom: 12px;
}

.drop-overlay-box p {
    margin: 0;
    font-size: 16px;
}

/* Upload Queue Drawer */
.upload-drawer {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 360px;
    max-width: calc(100vw - 32px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 40;
    overflow: hidden;
}

.upload-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 13.5px;
}

.upload-queue {
    max-height: 280px;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.upload-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(38, 50, 72, 0.55);
}

.upload-item:last-child {
    border-bottom: none;
    padding-bottom: 2px;
}

.upload-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.upload-item-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11.5px;
    color: var(--text-muted);
}

.progress-track {
    width: 100%;
    height: 6px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.15s linear;
}

.progress-fill.done {
    background: var(--success);
}

.progress-fill.error {
    background: var(--danger);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 50;
}

.modal-dialog {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 18px;
    max-height: 75vh;
    overflow-y: auto;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}

/* Share list inside modal */
.share-create-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
}

.share-create-row select {
    flex: 1;
}

.share-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.share-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 11px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.share-url-row {
    display: flex;
    gap: 6px;
}

.share-url-input {
    flex: 1;
    min-width: 0;
    font-size: 12.5px !important;
    padding: 7px 9px !important;
    color: #93c5fd !important;
}

.share-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

/* Toasts */
.toast-container {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 9px;
    font-size: 13.5px;
    box-shadow: var(--shadow);
    pointer-events: auto;
}

.toast.success {
    border-color: rgba(16, 185, 129, 0.5);
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.55);
    color: #fecaca;
}

/* Responsive */
@media (max-width: 720px) {
    .topbar {
        padding: 12px 14px;
    }
    .topbar-right .btn span {
        display: none;
    }
    .main-container {
        padding: 16px 12px 80px;
    }
    .col-date {
        display: none;
    }
    .search-wrap input {
        width: 160px;
    }
}
