/* Standardvärden (HBAB). Varje kund kan skriva över variablerna i brands/<kund>/brand.json. */
:root {
  --navy: #192954;
  --navy-deep: #0f1a38;
  --sky: #8ed8f8;
  --steel: #acbcc3;
  --bg: #eff1f2;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #5f6b7a;
  --border: #dde2e6;
  --danger: #b42318;
  --ok: #067647;
  --radius: 14px;
  --accent-rgb: 142, 216, 248;
  --tint: #e6f6fd;
  --overlay: rgba(230, 246, 253, .94);
  --btn: #192954;
  --btn-hover: #24397a;
  --lead: #d6e0e5;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-heading: var(--font-body);
  --heading-transform: none;
  --heading-spacing: -0.01em;
  font-family: var(--font-body);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); display: flex; flex-direction: column; min-height: 100vh; }
main { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px 48px; flex: 1; }
h1, h2 { margin: 0 0 16px; letter-spacing: var(--heading-spacing); font-family: var(--font-heading);
  text-transform: var(--heading-transform); }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
a { color: var(--navy); }

/* ---------- Sidhuvud ---------- */

.topbar { background: var(--navy-deep); color: #fff; }
.topbar-inner {
  max-width: 1040px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand-name { font-weight: 800; font-size: 1.35rem; letter-spacing: 0.02em; line-height: 1; }
.brand-sub { display: block; font-size: .72rem; font-weight: 500; color: var(--steel); letter-spacing: .12em; text-transform: uppercase; margin-top: 4px; }

.topbar nav { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.topbar nav a { color: #fff; text-decoration: none; font-weight: 600; padding: 4px 0; border-bottom: 2px solid transparent; }
.topbar nav a:hover, .topbar nav a.active { border-bottom-color: var(--sky); }
.who { color: var(--steel); font-size: .9rem; }
.topbar button.link { color: var(--sky); font-weight: 600; }

/* ---------- Sidrubrik (hero) ---------- */

.hero {
  background:
    linear-gradient(115deg, rgba(var(--accent-rgb), .10) 0 18%, transparent 18% 100%),
    linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
}
.hero-inner { max-width: 1040px; margin: 0 auto; padding: 40px 20px 72px; }
.eyebrow { color: var(--steel); text-transform: uppercase; letter-spacing: .14em; font-size: .8rem; font-weight: 600; margin: 0 0 10px; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0; }
.hero p.lead { color: var(--lead); margin: 10px 0 0; max-width: 620px; }
.hero + main { margin-top: -44px; }

/* ---------- Kort och formulär ---------- */

.card {
  background: var(--card); border-radius: var(--radius); padding: 24px; margin-bottom: 24px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

.stack { display: grid; gap: 16px; }
.stack label { display: grid; gap: 6px; font-size: .9rem; font-weight: 600; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.tight { flex-wrap: nowrap; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }

input:not([type=checkbox]) {
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; font: inherit; min-width: 0;
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
input:not([type=checkbox]):focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .55); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--navy); }

button {
  padding: 11px 22px; border: 0; border-radius: 999px; background: var(--btn); color: #fff;
  font: inherit; font-weight: 700; cursor: pointer; transition: background .15s, transform .05s;
}
button:hover { background: var(--btn-hover); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
button.link { background: none; color: var(--navy); padding: 0; border-radius: 0; font-weight: 600; }
button.link:hover { text-decoration: underline; }
button.link.danger { color: var(--danger); }
form { margin: 0; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; background: var(--tint); border-left: 4px solid var(--sky); }
.flash.error { background: #fdecea; color: var(--danger); border-left-color: var(--danger); }

/* ---------- Inloggning ---------- */

body.auth {
  background:
    linear-gradient(115deg, rgba(var(--accent-rgb), .10) 0 22%, transparent 22% 100%),
    linear-gradient(115deg, transparent 0 78%, rgba(var(--accent-rgb), .06) 78% 100%),
    linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
}
body.auth .topbar { background: transparent; }
body.auth main { display: grid; place-items: center; padding-top: 24px; }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-wrap .eyebrow { text-align: center; }
.auth-title { text-align: center; font-size: clamp(1.8rem, 5vw, 2.4rem); font-weight: 800; margin: 0 0 28px; }
.auth-wrap .card { color: var(--text); padding: 32px; }
.auth-wrap button[type=submit] { width: 100%; margin-top: 4px; }
body.auth footer { color: var(--steel); border-top-color: rgba(255, 255, 255, .1); background: transparent; }

/* ---------- Uppladdning ---------- */

.dropzone {
  display: grid; gap: 6px; place-items: center; text-align: center; padding: 44px 16px;
  border: 2px dashed #c3ccd3; border-radius: var(--radius); cursor: pointer; color: var(--muted);
  background: #f8fafb; transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--navy); }
.dropzone svg { width: 44px; height: 44px; color: var(--navy); margin-bottom: 4px; }
.dropzone strong { color: var(--text); font-size: 1.05rem; }
.dropzone.over { border-color: var(--navy); background: var(--tint); }

.uploads { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.uploads li { display: grid; grid-template-columns: 1fr 180px 120px; gap: 12px; align-items: center; font-size: .9rem; }
.uploads .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.uploads progress { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 999px; background: var(--border); overflow: hidden; }
.uploads progress::-webkit-progress-bar { background: var(--border); border-radius: 999px; }
.uploads progress::-webkit-progress-value { background: var(--btn); border-radius: 999px; }
.uploads progress::-moz-progress-bar { background: var(--btn); border-radius: 999px; }
.uploads li.done progress::-webkit-progress-value { background: var(--ok); }
.uploads li.done progress::-moz-progress-bar { background: var(--ok); }
.uploads li.done .status { color: var(--ok); font-weight: 600; }
.uploads li.error .status { color: var(--danger); }

/* ---------- Tabeller ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td:first-child { white-space: normal; word-break: break-word; min-width: 160px; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:hover { background: #f8fafb; }
tbody tr:last-child td { border-bottom: 0; }
td a { font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--bg); color: var(--muted); }
.badge.admin { background: var(--tint); color: var(--navy); }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 24px 0 8px; }

.actions { display: flex; gap: 16px; align-items: center; justify-content: flex-end; }

/* ---------- Mappar ---------- */

.crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px;
  color: var(--steel); font-size: .85rem; font-weight: 600; letter-spacing: .04em; }
.crumbs a { color: var(--sky); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs [aria-current] { color: #fff; }

.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 16px 20px; }

.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.folder {
  display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-radius: var(--radius);
  background: var(--card); color: var(--text); text-decoration: none; font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  transition: transform .1s, box-shadow .15s;
}
.folder:hover { transform: translateY(-1px); box-shadow: 0 0 0 2px var(--sky), 0 8px 24px rgba(16, 24, 40, .08); }
.folder svg { color: var(--navy); flex: none; }
.folder span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; font: inherit; background: #fff;
  max-width: 220px;
}
.small-btn { padding: 7px 14px; font-size: .85rem; }

/* ---------- Listvy ---------- */

.hero.compact .hero-inner { padding: 28px 20px 64px; }
.hero.compact h1 { font-size: clamp(1.5rem, 3.5vw, 2rem); }

label.button, summary.button {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 22px; border-radius: 999px;
  background: var(--btn); color: #fff; font-weight: 700; cursor: pointer; user-select: none;
}
label.button:hover { background: var(--btn-hover); }
summary.button.secondary { background: #fff; color: var(--navy); box-shadow: inset 0 0 0 2px var(--navy); }
.button.small-btn, button.small-btn { padding: 7px 16px; font-size: .88rem; }

.browser { position: relative; padding: 0; overflow: visible; }
.browser-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.browser-head .summary { margin: 0; font-size: .9rem; }
.head-actions { gap: 8px; }
.new-folder { padding: 14px 20px; border-bottom: 1px solid var(--border); background: #f8fafb; }
.new-folder input[name=name] { flex: 1; max-width: 360px; }
.browser .uploads { margin: 0; padding: 0 20px; }
.browser .uploads:not(:empty) { padding: 14px 20px; border-bottom: 1px solid var(--border); }

.items { list-style: none; margin: 0; padding: 6px 0; }
.items > li + li { border-top: 1px solid #edf0f2; }
.item {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 100px 140px minmax(60px, auto);
  align-items: center; gap: 14px; padding: 12px 20px; color: var(--text); text-decoration: none;
}
.folder-item .meta.wide { grid-column: span 2; }
a.item:hover, .file-item:hover { background: #f5f8fa; }
.item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .name a { color: var(--text); text-decoration: none; }
.item .name a:hover { color: var(--navy); text-decoration: underline; }
.item .meta { color: var(--muted); font-size: .88rem; white-space: nowrap; }
.meta-mobile { display: none; }
.chev { color: var(--steel); font-size: 1.4rem; text-align: right; line-height: 1; }
a.item:hover .chev { color: var(--navy); }

.icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; }
.icon-folder { background: var(--tint); color: var(--navy); }
.icon-file { background: #eef1f4; color: var(--muted); font-size: .62rem; font-weight: 800; letter-spacing: .03em; }
.icon-file.kind-pdf { background: #fdecea; color: #b42318; }
.icon-file.kind-image { background: #e7f6ec; color: #067647; }
.icon-file.kind-video, .icon-file.kind-audio { background: #f1ecfd; color: #5b3cc4; }
.icon-file.kind-text { background: var(--tint); color: var(--navy); }

.item-actions { display: flex; gap: 14px; align-items: center; justify-content: flex-end; font-size: .88rem; white-space: nowrap; }
.item-actions a { color: var(--navy); font-weight: 600; text-decoration: none; }
.item-actions a:hover { text-decoration: underline; }
.item-actions button.link { font-size: .88rem; }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
summary.link { color: var(--navy); font-weight: 600; }
summary.link:hover { text-decoration: underline; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 260px; display: grid; gap: 14px;
  padding: 16px; background: #fff; border-radius: 12px; text-align: left; white-space: normal;
  box-shadow: 0 0 0 1px var(--border), 0 12px 32px rgba(16, 24, 40, .16);
}
.menu-panel select { max-width: none; width: 100%; }

.drop-hint { margin: 0; padding: 10px 20px 14px; font-size: .8rem; border-top: 1px solid #edf0f2; }
.drop-overlay {
  position: absolute; inset: 0; z-index: 10; display: none; align-content: start; justify-content: center;
  gap: 4px; padding-top: 96px; text-align: center;
  border: 2px dashed var(--navy); border-radius: var(--radius); background: var(--overlay); color: var(--muted);
  pointer-events: none;
}
.drop-overlay strong { color: var(--navy); font-size: 1.1rem; }
.browser.over .drop-overlay { display: grid; }
.browser .empty { padding: 28px 20px; }

@media (max-width: 1000px) and (min-width: 721px) {
  .item { grid-template-columns: 40px minmax(0, 1fr) 80px minmax(60px, auto); }
  .file-item .meta + .meta { display: none; }
  .folder-item .meta.wide { grid-column: span 1; }
}

@media (max-width: 720px) {
  .item { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .item .meta { display: none; }
  .meta-mobile { display: block; color: var(--muted); font-weight: 400; font-size: .8rem; margin-top: 2px; }
  .file-item { grid-template-columns: 40px minmax(0, 1fr); }
  .file-item .item-actions { grid-column: 2; justify-content: flex-start; flex-wrap: wrap; }
  .file-item .chev { display: none; }
  .menu-panel { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; min-width: 0; z-index: 50; }
}

/* ---------- Publika filer ---------- */

.badge.public { background: var(--tint); color: var(--btn); margin-left: 6px; vertical-align: 1px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; color: var(--text); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  position: relative; width: 34px; height: 20px; border-radius: 999px; background: #cfd5da; transition: background .15s; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--btn); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 3px solid rgba(var(--accent-rgb), .55); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }
.public-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 16px 20px; }
.public-panel p { margin: 0; font-size: .9rem; }

/* ---------- Visning ---------- */

.viewer { padding: 16px; text-align: center; }
.viewer img { max-width: 100%; max-height: 75vh; border-radius: 8px; user-select: none; -webkit-user-drag: none; }
.viewer iframe { width: 100%; height: 75vh; border: 0; border-radius: 8px; background: #fff; }
.viewer video { max-width: 100%; max-height: 75vh; border-radius: 8px; background: #000; }
.viewer audio { width: 100%; }
.viewer-actions { justify-content: space-between; }

/* ---------- QR-kod ---------- */

a.button {
  display: inline-block; padding: 11px 22px; border-radius: 999px; background: var(--btn); color: #fff;
  font-weight: 700; text-decoration: none;
}
button.secondary, a.button.secondary { background: #fff; color: var(--navy); box-shadow: inset 0 0 0 2px var(--navy); }
button.secondary:hover, a.button.secondary:hover { background: var(--tint); }
.qr-card { text-align: center; max-width: 520px; margin-left: auto; margin-right: auto; }
.qr svg { width: 100%; max-width: 320px; height: auto; }
.qr-link { word-break: break-all; font-size: .9rem; margin: 8px 0 20px; }
.qr-link a { color: var(--muted); }
.qr-buttons { justify-content: center; }
.qr-name { font-size: 1.3rem; font-weight: 700; margin: 0; }
.small { font-size: .85rem; margin: 18px 0 0; }
.print-only { display: none; }

@media print {
  .topbar, footer, .no-print { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; }
  .hero + main, main { margin-top: 0; padding-top: 40px; }
  .card { box-shadow: none; }
  .qr svg { max-width: 360px; }
}

/* ---------- Sidfot ---------- */

footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; }
footer .inner { max-width: 1040px; margin: 0 auto; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.part-of { height: 22px; width: auto; color: var(--navy); }
body.auth .part-of { color: #fff; }

@media (max-width: 640px) {
  .uploads li { grid-template-columns: 1fr; gap: 4px; }
  .topbar nav { gap: 14px; }
  .card { padding: 18px; }
  .row.tight { flex-wrap: wrap; }
}
