:root {
  --brand: #3673F2;
  --brand-dark: #2557C9;
  --brand-end: #36C7D7;
  --gradient: linear-gradient(90deg, #3673F2, #36C7D7);
  --ink: #101828;
  --muted: #475467;
  --line: #E4E7EC;
  --line-soft: #F2F4F7;
  --surface: #F4F6FA;
  --card: #FFFFFF;
  --tint: #EEF3FE;
  --ok-bg: #DCFAE6; --ok: #067647;
  --warn-bg: #FEF0C7; --warn: #93370D;
  --bad-bg: #FEE4E2; --bad: #B42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05);
  --shadow-lg: 0 20px 48px rgba(16,24,40,.18);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--surface); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.boot { display: grid; place-items: center; height: 100vh; }
.boot-logo { width: 200px; opacity: .9; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---- buttons & inputs ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--line-soft); }
.btn:focus-visible, .input:focus-visible, .icon-btn:focus-visible, .nav a:focus-visible { outline: 3px solid rgba(54,115,242,.35); outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #FDA29B; }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }
.input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #D0D5DD; border-radius: 10px; background: #fff; }
.input:focus { border-color: var(--brand); }
label.field, div.field { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
.field .help { font-weight: 400; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.form { display: grid; gap: 16px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.error-box { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.note { background: var(--tint); color: #1E3A8A; padding: 12px 14px; border-radius: 10px; font-size: 13px; }
.note.warn { background: var(--warn-bg); color: var(--warn); }

/* ---- auth pages ---- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 50% -10%, #DCE8FF, transparent), var(--surface); }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 20px; padding: 36px 28px; box-shadow: var(--shadow-lg); display: grid; gap: 20px; }
.auth-card .logo { width: 180px; margin: 0 auto 4px; display: block; }
.auth-card h1 { text-align: center; font-size: 20px; }
.auth-card p.sub { margin: -10px 0 0; text-align: center; color: var(--muted); }
.auth-links { text-align: center; font-size: 13px; }

/* ---- shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 256px; flex: none; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 20px 14px; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .logo { width: 150px; margin: 4px 10px 22px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; color: #344054; font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--line-soft); }
.nav a.active { background: var(--tint); color: var(--brand-dark); font-weight: 650; }
.nav-title { margin: 18px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.quota { margin-top: auto; padding: 14px; border-radius: 12px; background: var(--surface); display: grid; gap: 8px; font-size: 13px; }
.quota strong { font-size: 13px; }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--gradient); }
.bar.full > span { background: var(--bad); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .search { flex: 1; max-width: 560px; position: relative; }
.topbar .search svg { position: absolute; left: 12px; top: 12px; color: var(--muted); width: 18px; height: 18px; }
.topbar .search input { padding-left: 38px; background: var(--surface); border-color: transparent; border-radius: 99px; }
.topbar .spacer { flex: 1; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--gradient); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.menu-btn { display: none; }
.content { padding: 28px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 15px; color: var(--muted); }
.crumbs a { color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.crumbs a:last-child { color: var(--ink); font-weight: 650; }
.crumbs .sep { color: #98A2B3; }

/* ---- cards & tables ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 20px; display: grid; gap: 16px; }
.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat { padding: 18px 20px; display: grid; gap: 6px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.stat .sub { font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 10px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #FAFBFC; }
table.list td.num, table.list th.num { text-align: right; white-space: nowrap; }
.name-cell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.name-cell button.link { all: unset; cursor: pointer; font-weight: 550; overflow-wrap: anywhere; }
.name-cell button.link:hover { color: var(--brand-dark); text-decoration: underline; }
.name-cell button.link:focus-visible { outline: 3px solid rgba(54,115,242,.35); border-radius: 4px; }
.ficon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--line-soft); color: var(--muted); }
.ficon.folder { background: var(--tint); color: var(--brand); }
.ficon.image { background: #E0F7FA; color: #0E7490; }
.ficon.video { background: #F3E8FF; color: #7E22CE; }
.ficon.doc { background: #FEF3F2; color: var(--bad); }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--tint); color: var(--brand-dark); }
.usage { display: grid; gap: 4px; min-width: 140px; font-size: 12px; color: var(--muted); }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty svg { width: 44px; height: 44px; color: #98A2B3; }
.empty strong { color: var(--ink); font-size: 16px; }

/* ---- drop zone ---- */
.dropzone { position: fixed; inset: 0; z-index: 40; background: rgba(54,115,242,.12); border: 3px dashed var(--brand); display: none; place-items: center; pointer-events: none; }
.dropzone.on { display: grid; }
.dropzone div { background: #fff; padding: 18px 28px; border-radius: 14px; font-weight: 650; color: var(--brand-dark); box-shadow: var(--shadow-lg); }

/* ---- photos ---- */
.month { font-weight: 650; margin: 8px 0 -6px; }
.grid-photos { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid-photos button { all: unset; cursor: pointer; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); position: relative; display: block; }
.grid-photos button:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.grid-photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid-photos .vid { position: absolute; right: 8px; bottom: 8px; background: rgba(16,24,40,.7); color: #fff; border-radius: 6px; padding: 2px 6px; font-size: 11px; font-weight: 600; }
.grid-photos .vthumb { width: 100%; height: 100%; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #344054, #101828); }

/* ---- lightbox ---- */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(10,14,22,.94); display: grid; grid-template-rows: auto 1fr; color: #fff; }
.lightbox .lb-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.lightbox .lb-top .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lightbox .icon-btn { color: #fff; }
.lightbox .icon-btn:hover { background: rgba(255,255,255,.12); }
.lightbox .lb-body { position: relative; display: grid; place-items: center; min-height: 0; padding: 0 64px 24px; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lightbox .nav-l, .lightbox .nav-r { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.12); }
.lightbox .nav-l { left: 10px; } .lightbox .nav-r { right: 10px; }

/* ---- modal & toast ---- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(16,24,40,.45); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); display: grid; gap: 18px; padding: 24px; }
.modal.wide { max-width: 680px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.recovery-code { font: 600 19px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .04em; text-align: center; padding: 16px; border-radius: 12px; background: var(--surface); border: 1px dashed #98A2B3; word-break: break-all; user-select: all; }
.toasts { position: fixed; z-index: 70; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; }
.toast.bad { background: var(--bad); }

/* ---- uploads ---- */
.uploads { position: fixed; z-index: 45; right: 20px; bottom: 20px; width: 360px; max-width: calc(100vw - 32px); background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.uploads .u-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--ink); color: #fff; font-weight: 600; }
.uploads .u-head .icon-btn { color: #fff; }
.uploads .u-list { max-height: 260px; overflow-y: auto; }
.uploads .u-item { padding: 10px 16px; border-bottom: 1px solid var(--line-soft); display: grid; gap: 6px; font-size: 13px; }
.uploads .u-row { display: flex; justify-content: space-between; gap: 10px; }
.uploads .u-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- settings ---- */
.settings { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.list-plain { display: grid; gap: 0; }
.list-plain > div { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.list-plain > div:last-child { border-bottom: 0; }
.list-plain .grow { flex: 1; min-width: 0; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; z-index: 25; background: rgba(16,24,40,.35); }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px; }
  .hide-sm { display: none; }
  .topbar .spacer { display: none; }
  .name-cell { min-width: 160px; }
  table.list td, table.list th { padding: 10px 10px; }
  .row-actions .icon-btn { width: 34px; }
  .page-head .actions .btn { flex: 1; }
  .grid-photos { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 3px; }
  .lightbox .lb-body { padding: 0 8px 16px; }
}
