/* Rebel Republic Files — print-shop palette: paper, ink, and CMYK for file types */
:root {
  --paper: #f3f4f6;
  --sheet: #ffffff;
  --ink: #16181d;
  --ink-soft: #2b2f37;
  --muted: #5b626e;
  --line: #d9dde3;
  --line-soft: #e8ebef;
  --cyan: #0094c8;
  --magenta: #cf1f68;
  --yellow: #f2b300;
  --green: #1a9e4b;
  --danger: #b4232f;
  --radius: 6px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  font-variation-settings: "wdth" 100;
}
a { color: inherit; }
h1, h2 { font-stretch: 112%; font-variation-settings: "wdth" 112; letter-spacing: -0.01em; line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); font-weight: 750; }
h2 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.login-sheet > .small { margin-top: 18px; margin-bottom: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* ── Top bar ─────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px; height: 64px;
  background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-variation-settings: "wdth" 115; }
.brand-logo { max-height: 36px; width: auto; display: block; }
.brand-swatch { display: grid; grid-template-columns: 9px 9px; gap: 2px; }
.brand-swatch i { width: 9px; height: 9px; display: block; }
.brand-swatch i:nth-child(1) { background: var(--cyan); }
.brand-swatch i:nth-child(2) { background: var(--magenta); }
.brand-swatch i:nth-child(3) { background: var(--yellow); }
.brand-swatch i:nth-child(4) { background: currentColor; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  white-space: nowrap;
  text-decoration: none; padding: 8px 12px; border-radius: var(--radius);
  color: #c9ced6; font-weight: 500;
}
.nav a:hover { color: #fff; background: var(--ink-soft); }
.nav a.on { color: #fff; box-shadow: inset 0 -3px 0 var(--cyan); border-radius: 0; }
.signout { margin: 0; }
.topbar .btn-text { color: #c9ced6; }

.main { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }

/* ── Buttons & fields ────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink);
  font: 600 .95rem/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-soft); }
.btn-whatsapp { background: var(--green); border-color: var(--green); color: #fff; }
.btn-whatsapp:hover { border-color: #137a39; background: #137a39; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: .875rem; }
.btn-big { min-height: 56px; padding: 0 40px; font-size: 1.1rem; }
.btn-wide { width: 100%; }
.btn-text { background: none; border: 0; padding: 4px 6px; font: 600 .875rem var(--font); color: var(--cyan); cursor: pointer; }
.btn-icon { background: none; border: 0; font-size: 1.1rem; cursor: pointer; color: var(--muted); padding: 6px 8px; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { border-color: var(--danger); }

.stack { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; margin: 0; border: 0; padding: 0; }
.field > span, .field > legend, .field-static > span { font-weight: 600; font-size: .9rem; }
.field-static { display: grid; gap: 2px; margin: 0; }
input[type=text], input[type=password], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink); font: 400 1rem var(--font);
}
textarea { font-size: .95rem; line-height: 1.5; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(0, 148, 200, .25); }
.pw { display: flex; align-items: center; gap: 4px; }
.pw input { flex: 1; }
.choice { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; cursor: pointer; padding: 4px 0; }
.choice input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--ink); }
.form-error { color: var(--danger); font-weight: 600; margin: 0; }
.note { background: #fff8e1; border-left: 4px solid var(--yellow); padding: 10px 12px; margin: 12px 0; font-size: .9rem; }
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; background: var(--sheet); border-left: 4px solid var(--cyan); }
.flash-err { border-left-color: var(--danger); }
.status { padding: 10px 12px; border-radius: var(--radius); font-weight: 600; font-size: .9rem; }
.status-ok { background: #e7f6ec; color: #136c33; }
.status-err { background: #fdecee; color: var(--danger); }

/* ── Page head & panels ─────────────────── */
.page-head { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 4px 16px; margin-bottom: 24px; }
.page-head > * { grid-column: 1; }
.page-head .head-actions { grid-column: 2; grid-row: 1 / span 3; display: flex; gap: 8px; align-self: end; }
.page-head h1 { margin: 0; overflow-wrap: anywhere; }
.page-head p { margin: 6px 0 0; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; font-size: .9rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs .sep { color: var(--line); }

.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.panel.narrow { max-width: 520px; }
.panel h2 + .muted { margin-top: -4px; }
.facts { display: grid; gap: 10px; margin: 0 0 28px; }
.facts div { display: flex; gap: 12px; }
.facts dt { width: 90px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

.empty { background: var(--sheet); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px 24px; text-align: center; }
.empty p { color: var(--muted); }

/* ── File list ───────────────────────────── */
.toolbar { display: flex; gap: 12px; margin-bottom: 12px; }
.search { flex: 1; }
.sort { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }
.sort select { width: auto; }

.files, .links, .user-list, .picker { list-style: none; margin: 0; padding: 0; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); }
.file-row, .link-row, .user-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; align-items: center; gap: 4px 16px;
  padding: 12px 16px; border-top: 1px solid var(--line-soft);
}
.file-row:first-child, .link-row:first-child, .user-row:first-child { border-top: 0; }
.file-row:hover { background: #fafbfc; }
.file-name { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
a.file-name:hover { text-decoration: underline; text-decoration-color: var(--cyan); text-underline-offset: 3px; }
.file-meta { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.file-actions { display: flex; gap: 6px; align-items: center; }
.file-actions form { margin: 0; }

/* The file-type badge: printed CMYK chip */
.kind {
  width: 40px; height: 30px; display: grid; place-items: center;
  border-radius: 3px; font: 700 .68rem/1 var(--font); font-variation-settings: "wdth" 80;
  letter-spacing: .02em; color: #fff; background: #7b828d;
}
.k-c { background: var(--cyan); }
.k-m { background: var(--magenta); }
.k-y { background: var(--yellow); color: var(--ink); }
.k-k { background: var(--ink); }
.k-folder { background: none; color: var(--ink); width: 40px; height: 30px; }

/* Share links list */
.link-row { grid-template-columns: 44px minmax(0, 1fr) auto auto; }
.link-main, .user-main { display: grid; gap: 2px; min-width: 0; }
.link-main .file-meta, .user-main .file-meta { white-space: normal; overflow-wrap: anywhere; }
.link-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .875rem; color: var(--muted); justify-content: flex-end; }
.is-expired .file-name { color: var(--muted); }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--line-soft); color: var(--ink); vertical-align: 2px; }
.tag-off { background: #fdecee; color: var(--danger); }

/* Clients page */
.split { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 24px; align-items: start; }
.user-row { grid-template-columns: minmax(0, 1fr) auto; }
.user-row.is-off .file-name { color: var(--muted); }
.cred { margin-bottom: 24px; border-left: 4px solid var(--green); }
.cred textarea { margin: 8px 0 12px; font-family: var(--font); background: var(--paper); }
.more { position: relative; }
.more summary { list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; min-width: 170px;
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(22, 24, 29, .14); padding: 6px;
}
.more-menu form { margin: 0; }
.more-menu button { width: 100%; text-align: left; padding: 9px 10px; border: 0; background: none; font: 500 .9rem var(--font); cursor: pointer; border-radius: 4px; }
.more-menu button:hover { background: var(--paper); }
.more-menu .danger { color: var(--danger); }
.client-only[hidden] { display: none; }
.client-only { display: grid; gap: 10px; }

/* ── Dialogs ─────────────────────────────── */
.dialog {
  width: min(480px, calc(100vw - 32px)); border: 0; border-radius: 10px; padding: 28px;
  color: var(--ink); box-shadow: 0 24px 60px rgba(22, 24, 29, .3);
}
.dialog::backdrop { background: rgba(22, 24, 29, .55); }
.dialog[open] { animation: rise .18s ease-out; }
.dialog-close { position: absolute; right: 12px; top: 12px; margin: 0; }
.dialog h2 { padding-right: 28px; }
.dialog .stack { margin-top: 16px; }
.linkbox { display: flex; gap: 8px; margin: 16px 0 12px; }
.linkbox input { font-size: .9rem; }
.picker { max-height: 320px; overflow-y: auto; margin: 12px 0 16px; }
.picker li { border-top: 1px solid var(--line-soft); }
.picker li:first-child { border-top: 0; }
.picker button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 14px; border: 0; background: none; font: 500 .95rem var(--font); text-align: left; cursor: pointer; }
.picker button:hover { background: var(--paper); }
.picker .none { padding: 14px; color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Login, share pages: a sheet with crop marks ── */
.bare { background: var(--paper); }
.main-bare { min-height: 100vh; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 48px 20px; }
.login-sheet, .single-file {
  position: relative; width: min(420px, 100%);
  background: var(--sheet); padding: 40px 36px 32px;
  box-shadow: 0 1px 2px rgba(22, 24, 29, .06);
}
.login-sheet.wide { width: min(480px, 100%); }
.login-sheet h1 { font-size: 1.6rem; margin-top: 8px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-variation-settings: "wdth" 115; margin-bottom: 20px; }
.login-brand .brand-logo { max-height: 44px; }
.crop { position: absolute; width: 22px; height: 22px; pointer-events: none; }
.crop::before, .crop::after { content: ""; position: absolute; background: var(--ink); }
.crop::before { width: 16px; height: 1px; }
.crop::after { width: 1px; height: 16px; }
.crop.tl { left: -26px; top: -26px; } .crop.tl::before { right: 0; bottom: 0; } .crop.tl::after { right: 0; bottom: 0; }
.crop.tr { right: -26px; top: -26px; } .crop.tr::before { left: 0; bottom: 0; } .crop.tr::after { left: 0; bottom: 0; }
.crop.bl { left: -26px; bottom: -26px; } .crop.bl::before { right: 0; top: 0; } .crop.bl::after { right: 0; top: 0; }
.crop.br { right: -26px; bottom: -26px; } .crop.br::before { left: 0; top: 0; } .crop.br::after { left: 0; top: 0; }

.share-page { max-width: 860px; margin: 0 auto; padding: 28px 24px 60px; }
.share-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 48px; }
.share-head .login-brand { margin: 0; }
.single-file { margin: 40px auto; text-align: center; padding: 48px 36px 40px; width: min(460px, 100%); }
.single-file .kind { width: 64px; height: 46px; font-size: .95rem; margin: 0 auto 18px; border-radius: 4px; }
.single-name { font-size: 1.4rem; overflow-wrap: anywhere; }
.single-file .btn-big { margin-top: 12px; }
.share-foot { margin-top: 40px; }

/* ── Small screens ───────────────────────── */
@media (max-width: 800px) {
  .split { grid-template-columns: 1fr; }
  .topbar { height: auto; flex-wrap: wrap; gap: 8px 16px; padding: 12px 16px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .signout { margin-left: auto; }
  .signout .btn-text { font-size: 0; }
  .signout .btn-text::before { content: "Sign out"; font-size: .875rem; }
}
@media (max-width: 640px) {
  .main { padding: 20px 16px 60px; }
  .page-head { grid-template-columns: 1fr; }
  .page-head .head-actions { grid-column: 1; grid-row: auto; margin-top: 12px; flex-wrap: wrap; }
  .toolbar { flex-direction: column; }
  .file-row, .link-row { grid-template-columns: 44px minmax(0, 1fr); padding: 12px; }
  .file-meta { white-space: normal; }
  .file-row .file-meta, .link-facts { grid-column: 2; justify-content: flex-start; }
  .file-actions { grid-column: 2; }
  .user-row { grid-template-columns: 1fr; }
  .login-sheet { padding: 32px 22px 26px; }
  .crop { display: none; }
  .linkbox { flex-direction: column; }
  .share-head { margin-bottom: 24px; flex-direction: column; align-items: flex-start; gap: 6px; }
}
@media (prefers-reduced-motion: reduce) { .dialog[open] { animation: none; } }
