/* ZCloud — hand-written styles, no build step */

:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #eef1f7;
  --text: #16202f;
  --muted: #67748b;
  --border: #dde3ec;
  --accent: #3d5afe;
  --accent-hover: #2f49d1;
  --accent-soft: #e9edff;
  --danger: #d24141;
  --danger-soft: #fdecec;
  --success: #1c8259;
  --success-soft: #e6f6ee;
  --warning: #b7791f;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 10px 30px rgba(16, 24, 40, 0.08);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117;
    --panel: #161b23;
    --panel-2: #1d2430;
    --text: #e7ecf5;
    --muted: #93a0b7;
    --border: #29313f;
    --accent: #8393ff;
    --accent-hover: #a0adff;
    --accent-soft: #232b4d;
    --danger: #f07d7d;
    --danger-soft: #3a2024;
    --success: #5bd6a0;
    --success-soft: #16352a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 0.83rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon { flex: none; }

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  padding: 20px 14px;
  border-right: 1px solid var(--border);
  background: var(--panel);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, #4f6bff, #7d4dff);
  box-shadow: 0 4px 12px rgba(79, 107, 255, 0.3);
}
.brand-mark .icon { width: 20px; height: 20px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 520;
}
.nav-link:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.who { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
}
.avatar.small { width: 30px; height: 30px; font-size: 0.72rem; }
.who-text { min-width: 0; }
.who-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-sub { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; padding: 28px 36px 60px; }

/* ---------- page furniture ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.page-title { display: flex; flex-direction: column; gap: 4px; }
.page-title h1 { overflow-wrap: anywhere; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 420px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input {
  flex: 1;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}
.search input::-webkit-search-cancel-button { filter: grayscale(1); }

.quota { width: 140px; flex: none; }
.quota-bar {
  height: 7px;
  border-radius: 99px;
  background: var(--panel-2);
  overflow: hidden;
}
.quota-bar span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }

.crumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}
.crumb { color: var(--muted); padding: 3px 5px; border-radius: 6px; }
.crumb:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.crumb.current { color: var(--text); font-weight: 600; }
.crumb-sep { display: inline-flex; opacity: 0.55; }
.crumb-sep .icon { width: 14px; height: 14px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.94); }
.btn-sm { padding: 5px 9px; font-size: 0.83rem; border-radius: 7px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn .icon { width: 17px; height: 17px; }
.inline-form { display: inline-flex; margin: 0; }

/* ---------- tables ---------- */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.file-table { width: 100%; border-collapse: collapse; }
.file-table th {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: left;
}
.file-table td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.file-table tbody tr:last-child td { border-bottom: 0; }
.file-row:hover, .file-table tbody tr:hover { background: color-mix(in srgb, var(--panel-2) 55%, transparent); }
.file-table .col-size { width: 90px; white-space: nowrap; }
.file-table .col-modified { width: 165px; white-space: nowrap; }
.file-table .col-actions { width: 190px; text-align: right; }
.file-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  color: var(--text);
  font-weight: 520;
}
.file-link:hover { text-decoration: none; }
.file-link:hover .file-name { color: var(--accent); text-decoration: underline; }
.file-name { overflow-wrap: anywhere; }
.enc-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 7px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 650;
  vertical-align: 1px;
  white-space: nowrap;
}
.enc-badge .icon { width: 11px; height: 11px; }
.file-path { margin: 2px 0 0 32px; color: var(--muted); font-size: 0.78rem; }
.file-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
}
.file-icon .icon { width: 17px; height: 17px; }
.file-icon.folder { background: #fdf3d8; color: #b7791f; }
.file-icon.image { background: #e2f5ec; color: #1c8259; }
.file-icon.video { background: #ece7ff; color: #6b4de0; }
.file-icon.music { background: #fde7f1; color: #c23d7e; }
@media (prefers-color-scheme: dark) {
  .file-icon.folder { background: #3a2f14; color: #e2b34a; }
  .file-icon.image { background: #16352a; color: #5bd6a0; }
  .file-icon.video { background: #2a2350; color: #a793ff; }
  .file-icon.music { background: #3d1f2d; color: #f08ab5; }
}
.row-actions { display: inline-flex; align-items: center; gap: 1px; justify-content: flex-end; }

.empty { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 38px; height: 38px; opacity: 0.6; margin-bottom: 8px; }

.empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--muted);
}
.empty-card > .icon { width: 42px; height: 42px; opacity: 0.55; }
.empty-card h2 { color: var(--text); }

/* ---------- cards & forms ---------- */

.card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.card h2 { margin-bottom: 14px; }
.card h3 { margin: 18px 0 8px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.form-grid .btn { height: 40px; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 550; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-grid .card:last-child { grid-column: 1 / -1; }

.token-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: var(--accent-soft);
  font-size: 0.85rem;
}
.token-box code { font-weight: 700; }

.inline-create { display: flex; gap: 8px; margin-bottom: 14px; }
.inline-create input {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.simple-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.simple-table th { padding: 7px 8px; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; text-align: left; }
.simple-table td { padding: 7px 8px; border-top: 1px solid var(--border); }

.code-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow-x: auto;
}
.code-row code { flex: 1; white-space: nowrap; font-size: 0.86rem; }
.code-block {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.6;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.pager { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---------- dialogs ---------- */

dialog {
  width: min(520px, 92vw);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 14, 22, 0.55); backdrop-filter: blur(3px); }
.dialog-form { display: flex; flex-direction: column; gap: 15px; padding: 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-head h2 { font-size: 1.15rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }

/* ---------- flash, toast, uploads ---------- */

.flash {
  margin-bottom: 18px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  font-size: 0.9rem;
}
.flash-error { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: var(--danger-soft); color: var(--danger); }
.flash-success { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); background: var(--success-soft); color: var(--success); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 90;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 10px;
  background: #101725;
  color: #f2f5fb;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}

.upload-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  width: min(360px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.upload-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 650; }
.upload-list { display: flex; flex-direction: column; gap: 9px; max-height: 220px; overflow-y: auto; }
.upload-name { margin-bottom: 4px; font-size: 0.83rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-bar { height: 5px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.upload-bar span { display: block; width: 0; height: 100%; border-radius: 99px; background: var(--accent); transition: width 0.15s; }
.upload-item.done .upload-bar span { background: var(--success); }
.upload-item.failed .upload-bar span { background: var(--danger); }

.drop-hint {
  position: fixed;
  inset: 14px;
  z-index: 70;
  display: none;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--accent-soft) 88%, transparent);
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 650;
  pointer-events: none;
}
body.dragging .drop-hint { display: grid; }

/* ---------- errors ---------- */

.error-card { max-width: 460px; margin: 8vh auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.error-code { font-size: 3.6rem; font-weight: 750; color: var(--accent); line-height: 1; }

/* ---------- auth ---------- */

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 15% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    radial-gradient(700px 380px at 110% 110%, color-mix(in srgb, #7d4dff 16%, transparent), transparent 60%),
    var(--bg);
}
.auth-card {
  width: min(390px, 100%);
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; font-size: 1.1rem; font-weight: 700; }
.auth-title { margin-bottom: 4px; }
.auth-sub { margin-bottom: 20px; color: var(--muted); font-size: 0.9rem; }
.auth-hint { margin-top: 18px; color: var(--muted); font-size: 0.8rem; text-align: center; }

/* ---------- public share ---------- */

.public-body { display: flex; flex-direction: column; min-height: 100vh; }
.public-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.public-main { flex: 1; width: min(980px, 100%); margin: 0 auto; padding: 34px 24px 60px; }
.public-foot { padding: 20px; text-align: center; color: var(--muted); font-size: 0.8rem; }

.share-card { display: flex; flex-direction: column; gap: 14px; margin: 0 auto; max-width: 760px; }
.share-card.narrow { max-width: 430px; }
.share-lock {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.share-lock .icon { width: 24px; height: 24px; }
.share-file-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 14px;
  background: var(--panel-2);
  color: var(--muted);
}
.share-file-icon .icon { width: 28px; height: 28px; }
.share-file-name { overflow-wrap: anywhere; }
.share-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 34px 20px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  cursor: pointer;
}
.dropzone:hover { border-color: var(--accent); color: var(--accent); }
.dropzone .icon { width: 28px; height: 28px; }
.dropzone input[type="file"] { max-width: 100%; font-size: 0.85rem; }

/* ---------- shares & admin tables ---------- */

.share-url { display: flex; align-items: center; gap: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
.shares-table .col-actions { width: 100px; }

.admin-table td { font-size: 0.88rem; }
.user-cell { display: flex; align-items: center; gap: 9px; }
.admin-row-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; justify-content: flex-end; }
.admin-row-form input, .admin-row-form select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
}
.admin-row-form input[name="display_name"] { width: 150px; }
.admin-row-form input[name="quota_gb"] { width: 84px; }
.admin-row-form input[name="password"] { width: 180px; }
.check { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    z-index: 30;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .brand { padding: 0 6px 0 0; }
  .brand span:last-child { display: none; }
  .nav { flex-direction: row; gap: 2px; }
  .nav-link { padding: 7px 9px; }
  .nav-link span { display: none; }
  .nav-link .icon { width: 19px; height: 19px; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; align-items: center; }
  .who-text { display: none; }
  .main { padding: 20px 18px 50px; }
  .settings-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .col-size, .col-modified { display: none; }
  .file-table .col-actions { width: auto; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .toolbar { flex-wrap: wrap; }
  .quota { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .crumbs { font-size: 0.82rem; }
  .settings-grid { gap: 12px; }
  .token-box { word-break: break-all; }
}
