@font-face {
    font-family: 'Peyda';
    src: url('/assets/fonts/PeydaWeb-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Peyda';
    src: url('/assets/fonts/PeydaWeb-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Peyda';
    src: url('/assets/fonts/PeydaWeb-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Peyda';
    src: url('/assets/fonts/PeydaWeb-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Peyda';
    src: url('/assets/fonts/PeydaWeb-Black.woff2') format('woff2');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #f8fafc;
    --bg-gradient: linear-gradient(135deg, #eef2ff 0%, #f8fafc 60%, #fdf4ff 100%);
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --border: #e2e8f0;
    --border-soft: #f1f5f9;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-soft: #eef2ff;
    --success: #10b981;
    --success-soft: #d1fae5;
    --warning: #f59e0b;
    --warning-soft: #fef3c7;
    --danger: #ef4444;
    --danger-soft: #fee2e2;
    --info: #0ea5e9;
    --info-soft: #e0f2fe;
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 16px -4px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.15);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 8px;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: 'Peyda', 'Tahoma', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'ss01', 'ss02';
    min-height: 100vh;
}

body.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

/* === Top bar === */
.topbar {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.topbar .brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
.topbar h1 {
    font-size: 1.05rem;
    margin: 0;
    font-weight: 700;
    color: var(--text);
}
.topbar nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* === Container === */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* === Stats === */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat {
    background: var(--card);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon.primary { background: var(--primary-soft); color: var(--primary); }
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
}
.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* === Cards === */
.card {
    background: var(--card);
    padding: 1.75rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-soft);
}
.card h1, .card h2 {
    margin-top: 0;
    color: var(--text);
}
.card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
}
.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* === Forms === */
label {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}
input[type="text"], input[type="password"], input[type="file"] {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-top: 0.4rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus, input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}
input[type="file"] {
    cursor: pointer;
    padding: 0.6rem;
}
input[type="file"]::file-selector-button {
    background: var(--primary-soft);
    color: var(--primary);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    margin-left: 0.5rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
}
input[type="file"]::file-selector-button:hover {
    background: var(--primary);
    color: white;
}

/* === Buttons === */
button, .btn, .btn-secondary, .btn-link, .btn-danger, .btn-warn, .btn-copy, .btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}
button, .btn {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}
button:hover, .btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
button:active, .btn:active { transform: translateY(0); }
.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: white;
    border-color: var(--primary);
    color: var(--primary);
}
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover {
    background: var(--border-soft);
    color: var(--text);
}
.btn-link {
    background: var(--info-soft);
    color: var(--info);
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
}
.btn-link:hover { background: var(--info); color: white; }
.btn-copy {
    background: var(--success-soft);
    color: var(--success);
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
}
.btn-copy:hover { background: var(--success); color: white; }
.btn-warn {
    background: var(--warning-soft);
    color: #b45309;
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
}
.btn-warn:hover { background: var(--warning); color: white; }
.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
}
.btn-danger:hover { background: var(--danger); color: white; }

/* === Alerts === */
.alert {
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius-xs);
    margin-bottom: 1.25rem;
    font-size: 0.93rem;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.alert.success {
    background: var(--success-soft);
    color: #047857;
    border-color: #6ee7b7;
}
.alert.error {
    background: var(--danger-soft);
    color: #991b1b;
    border-color: #fca5a5;
}

/* === Upload zone === */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    text-align: center;
    background: linear-gradient(180deg, #fafbff 0%, white 100%);
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.upload-zone-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 0.75rem;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.upload-zone-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}
.upload-zone-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.upload-zone-filename {
    margin-top: 0.75rem;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
    display: none;
}
.upload-zone.has-file .upload-zone-filename { display: block; }
.upload-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 1rem;
    justify-content: flex-end;
}

/* === Files table === */
.table-wrap {
    overflow-x: auto;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
}
.files-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 760px;
}
.files-table th, .files-table td {
    padding: 1rem 0.75rem;
    text-align: right;
    vertical-align: middle;
}
.files-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}
.files-table tbody tr {
    transition: background 0.15s;
}
.files-table tbody tr:hover {
    background: var(--border-soft);
}
.files-table tbody td {
    border-bottom: 1px solid var(--border-soft);
}
.files-table tbody tr:last-child td { border-bottom: none; }
.files-table tr.revoked { opacity: 0.5; }
.file-name-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 200px;
}
.file-icon {
    width: 38px;
    height: 38px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}
.file-name-text strong {
    display: block;
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
    line-height: 1.4;
}
.actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.actions form.inline { display: inline; margin: 0; }

/* === Misc === */
.muted { color: var(--text-muted); }
.small { font-size: 0.8rem; }
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--primary-soft);
    color: var(--primary);
}
.badge-guest { background: var(--warning-soft); color: #b45309; }

/* === Invite card === */
.invite-card {
    background: linear-gradient(135deg, #ffffff 0%, #fafbff 100%);
    border: 1px solid #e0e7ff;
}
.invite-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-xs);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.6rem;
}
.invite-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 50px;
    flex-shrink: 0;
}
.invite-value {
    flex: 1;
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 0.88rem;
    color: var(--text);
    background: transparent;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    word-break: break-all;
    user-select: all;
}
.invite-password {
    letter-spacing: 0.05em;
    color: var(--primary-dark);
    font-weight: 600;
}
.invite-message-btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.75rem;
}
@media (max-width: 540px) {
    .invite-row { flex-wrap: wrap; }
    .invite-value { width: 100%; order: 3; }
}

/* === Empty state === */
.empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
}
.empty-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    background: var(--border-soft);
    color: var(--text-dim);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Login / guest card === */
.auth-card {
    background: var(--card);
    padding: 2.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-soft);
    width: 100%;
    max-width: 420px;
}
.auth-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    text-align: center;
}
.auth-card .auth-sub {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1.75rem;
    font-size: 0.92rem;
}
.auth-card button {
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.5rem;
}
.auth-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 1.25rem;
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}
.guest-card { max-width: 480px; }

/* === Responsive === */
@media (max-width: 640px) {
    .container { padding: 0 1rem; margin: 1rem auto; }
    .topbar { padding: 0.85rem 1rem; }
    .topbar h1 { font-size: 0.95rem; }
    .card { padding: 1.25rem; }
    .files-table { font-size: 0.85rem; }
    .files-table th, .files-table td { padding: 0.7rem 0.4rem; }
    .stats { grid-template-columns: repeat(2, 1fr); }
}

/* === Animations === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.card, .alert, .stat { animation: fadeIn 0.3s ease-out; }

/* === Copy feedback === */
.copied-flash {
    animation: pulse 0.4s ease-out;
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
