/* 2mail Uploads — one stylesheet, no build step. */
:root {
    --bg: #f4f6fa;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-soft: #eff4ff;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --success: #15803d;
    --amber: #b45309;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 6px; font-weight: 650; letter-spacing: -.01em; }
code { font-family: var(--mono); background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.break { word-break: break-word; }
.inline { display: inline; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- top bar */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 28px;
    height: 58px; padding: 0 24px;
    background: #fff; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand strong { font-weight: 700; }
.mainnav { display: flex; gap: 4px; }
.mainnav a {
    padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 550;
}
.mainnav a:hover { background: #f3f4f6; color: var(--text); text-decoration: none; }
.mainnav a.active { background: var(--primary-soft); color: var(--primary); }
.usermenu { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.who { display: flex; align-items: center; gap: 8px; }
.who-name { font-weight: 600; }
.avatar {
    width: 28px; height: 28px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary); color: #fff; font-weight: 700; font-size: 13px;
}
.toplink {
    background: none; border: 0; padding: 0; cursor: pointer;
    font: inherit; color: var(--muted);
}
.toplink:hover { color: var(--text); text-decoration: none; }

.chip {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    font-size: 11.5px; font-weight: 650; text-transform: capitalize;
    background: #f3f4f6; color: #374151;
}
.chip-admin { background: #ede9fe; color: #5b21b6; }
.chip-staff { background: #e0f2fe; color: #075985; }

/* ---------- layout */
.page { max-width: 1180px; margin: 0 auto; padding: 24px; }
.page-head { margin-bottom: 18px; }
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden;
}
.card > .card-title { padding: 16px 18px 0; font-weight: 650; font-size: 15px; }
.card > form, .card > p { padding: 0 18px; }
.card > p:last-child { padding-bottom: 16px; }
.card-narrow { max-width: 440px; padding: 18px; }
.card-narrow > form { padding: 0; }

/* ---------- buttons & fields */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 36px; padding: 0 14px; border-radius: 8px;
    border: 1px solid var(--border-strong); background: #fff; color: var(--text);
    font: 600 13.5px/1 var(--font); cursor: pointer; white-space: nowrap;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: #f9fafb; border-color: #9ca3af; text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, .linkbtn:focus-visible {
    outline: 2px solid var(--primary); outline-offset: 2px;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: #fca5a5; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; height: 40px; font-size: 14.5px; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }

.linkbtn {
    background: none; border: 0; padding: 0; cursor: pointer;
    font: inherit; color: var(--primary); font-weight: 550;
}
.linkbtn:hover { text-decoration: underline; }

.icon-btn {
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
}
.icon-btn:hover { background: #f3f4f6; color: var(--text); text-decoration: none; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn svg { width: 18px; height: 18px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-weight: 600; font-size: 13px; }
.field small { color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], select {
    height: 38px; padding: 0 11px; border-radius: 8px;
    border: 1px solid var(--border-strong); background: #fff; color: var(--text);
    font: 14px var(--font); width: 100%;
}
input:focus, select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
.select-sm { height: 30px; font-size: 13px; padding: 0 8px; width: auto; }
.code-input { text-align: center; font: 600 24px/1 var(--mono) !important; letter-spacing: 8px; height: 50px !important; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 14px 18px 4px !important; }
.form-row .field { flex: 1 1 200px; }
.form-row .field-role { flex: 0 0 140px; }

/* ---------- tables */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); background: #fafbfc; padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.table td { padding: 10px 14px; border-bottom: 1px solid #f0f1f4; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.row-muted td { opacity: .6; }
.col-actions { text-align: right; white-space: nowrap; width: 1%; }
.row-actions { display: inline-flex; gap: 6px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-gray { background: #f3f4f6; color: #374151; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }

.empty { padding: 44px 20px; text-align: center; }
.empty p { margin: 4px 0; }

/* ---------- files */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 18px; font-weight: 650; min-width: 0; }
.crumbs a { color: var(--muted); padding: 2px 4px; border-radius: 6px; }
.crumbs a:hover { color: var(--primary); background: var(--primary-soft); text-decoration: none; }
.crumbs .sep { color: #c0c4cc; padding: 0 2px; font-weight: 400; }
.crumbs .here { color: var(--text); padding: 2px 4px; word-break: break-word; }

.files-table .col-size { width: 120px; }
.files-table .col-date { width: 170px; }
.files-table td.size, .files-table td.date { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.fname { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fname a, .fname span { color: var(--text); font-weight: 550; word-break: break-word; }
.fname a:hover { color: var(--primary); }
.ficon { flex: 0 0 auto; width: 22px; height: 22px; }
.ficon.dir { color: #d29b15; fill: #fcd56b; }
.ficon.file { color: #8b95a7; fill: #f3f5f8; }
.files-table tr.flash td { animation: rowflash 1.6s ease-out; }
@keyframes rowflash { from { background: #e8f0ff; } to { background: transparent; } }
.hint { color: var(--muted); font-size: 13px; margin: 4px 2px; }

/* drag & drop overlay */
.dropzone {
    position: fixed; inset: 0; z-index: 60; padding: 18px;
    background: rgba(29, 78, 216, .08); backdrop-filter: blur(1px);
    pointer-events: none;
}
.dropzone-inner {
    height: 100%; border: 3px dashed var(--primary); border-radius: 18px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    background: rgba(255, 255, 255, .55);
}
.dropzone-title { font-size: 26px; font-weight: 700; color: var(--primary); }
.dropzone-sub { font-size: 15px; color: #1e3a8a; }

/* upload panel */
.uploads {
    position: fixed; right: 20px; bottom: 20px; z-index: 40;
    width: 380px; max-width: calc(100vw - 40px);
    background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.uploads-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px 8px; }
.uploads-title { font-weight: 700; }
.uploads-sub { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.uploads-tools { display: flex; align-items: center; gap: 8px; }
.uploads-overall { padding: 0 14px 10px; }
.uploads-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; border-top: 1px solid var(--border); }
.uploads.min .uploads-list, .uploads.min .uploads-overall { display: none; }
.up-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 9px 14px; border-bottom: 1px solid #f0f1f4; }
.up-item:last-child { border-bottom: 0; }
.up-name { grid-column: 1; grid-row: 1; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-where { grid-column: 1; grid-row: 2; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-item .bar { grid-column: 1 / -1; grid-row: 3; }
.up-status { grid-column: 1 / -1; grid-row: 4; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.up-item.done .up-status { color: var(--success); }
.up-item.error .up-status { color: var(--danger); }
.up-item .icon-btn { grid-row: 1 / span 2; grid-column: 2; align-self: center; width: 28px; height: 28px; }
.bar { height: 6px; background: #eef0f4; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .2s linear; }
.up-item.done .bar > span { background: #22c55e; }
.up-item.error .bar > span { background: var(--danger); }

/* ---------- dialogs & toasts */
dialog.modal {
    border: 0; padding: 0; border-radius: 14px; width: 440px; max-width: calc(100vw - 32px);
    box-shadow: var(--shadow-lg); color: var(--text);
}
dialog.modal::backdrop { background: rgba(17, 24, 39, .45); }
.modal-body { padding: 22px 22px 8px; display: flex; gap: 14px; }
.modal-icon {
    flex: 0 0 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.modal-icon svg { width: 22px; height: 22px; }
.modal-icon.error { background: #fee2e2; color: var(--danger); }
.modal-icon.warn { background: #fef3c7; color: var(--amber); }
.modal-icon.info { background: var(--primary-soft); color: var(--primary); }
.modal-title { font-weight: 700; font-size: 16px; margin: 7px 0 6px; }
.modal-text { color: #374151; white-space: pre-line; word-break: break-word; }
.modal-input { margin-top: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 18px; }

.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
    background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg);
    font-weight: 550; max-width: min(560px, calc(100vw - 32px)); animation: toastin .18s ease-out;
}
.toast.ok::before { content: "✓"; color: #4ade80; margin-right: 8px; font-weight: 800; }
@keyframes toastin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- sign-in pages */
body.bare { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(180deg, #eef2fb 0%, #f4f6fa 60%); }
.auth { width: 100%; max-width: 400px; padding: 24px 16px 60px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 19px; margin-bottom: 18px; }
.auth-brand strong { font-weight: 700; }
.auth-card {
    background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
    padding: 28px 28px 24px;
}
.auth-card > p.muted { margin: 0 0 20px; }
.auth-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; font-size: 13px; }

/* ---------- small screens */
@media (max-width: 760px) {
    .topbar { gap: 12px; padding: 0 14px; }
    .brand span, .who-name, .toplink[href="/password"] { display: none; }
    .page { padding: 16px 12px; }
    .files-table .col-date, .files-table td.date { display: none; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .actions .btn { flex: 1 1 auto; }
    .uploads { right: 10px; bottom: 10px; max-width: calc(100vw - 20px); }
}
