:root {
  /* MuoviTech: svart bakgrund (logon syns bäst så), grafit och logons grå */
  color-scheme: dark;
  --bg: #000000; --card: #141414; --text: #ededed; --muted: #a3a3a1; --line: #2a2a2a;
  --brand: #f2f2f2; --brand-ink: #000000; --brand-soft: #242424;
  --open: #ef4444; --open-bg: #3b0d0f; --working: #eab308; --working-bg: #3a2f05;
  --solved: #22c55e; --solved-bg: #0b3a1f; --danger: #f97066;
  --radius: 12px; --shadow: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 40px; }
header.top {
  align-items: flex-start !important;
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 12px) 0 10px;
  display: flex; align-items: center; gap: 12px;
}
header.top .brand { flex: 1; min-width: 0; }
header.top .wordmark { display: block; height: 34px; width: auto; max-width: 100%; margin-bottom: 4px; }

header.top h1 { font-size: 18px; margin: 0; }
header.top .sub { margin: 0; color: var(--muted); font-size: 13px; font-weight: 400; }
select, input, textarea, button { font: inherit; color: inherit; }
select.lang { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }

.tabs { display: flex; gap: 6px; background: var(--card); padding: 4px; border-radius: 12px; border: 1px solid var(--line); margin: 6px 0 14px; }
.tabs button { flex: 1; border: 0; background: none; padding: 9px 8px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--brand); color: var(--brand-ink); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); font-size: 12px; line-height: 20px; }
.tabs button[aria-selected="true"] .count { background: var(--brand-ink); color: var(--brand); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 5px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=password], textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { min-height: 96px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-top: 14px; }
.check input { width: 20px; height: 20px; }

.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 600; cursor: pointer; background: var(--brand); color: var(--brand-ink); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.block { width: 100%; margin-top: 16px; padding: 13px; font-size: 17px; }
.btn.ghost { background: var(--brand-soft); color: var(--text); }
.btn.green { background: var(--solved); color: #000; }
.btn.small { padding: 7px 11px; font-size: 14px; }
.btn.danger { background: none; color: var(--danger); }
.link { background: none; border: 0; color: var(--text); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; padding: 0; font-size: 13px; }

.notice { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; }
.notice.info { background: var(--card); border: 1px solid var(--line); }
.notice.ok { background: var(--solved-bg); color: var(--solved); font-weight: 600; }
.notice.err { background: #3a1412; color: #fca5a5; }
.notice button { margin-top: 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.hint button { font-size: 13px; }

.ticket { cursor: pointer; display: block; }
.ticket:hover { border-color: var(--muted); }
.ticket h3 { margin: 6px 0 4px; font-size: 16px; }
.ticket p.body { margin: 0; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.pill { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; }
.pill.open { background: var(--open); color: #000; }
.pill.working { background: var(--working); color: #000; }
.pill.solved { background: var(--solved); color: #000; }
/* Hela kortet färgas efter status: röd = aktuellt, gul = IT jobbar, grön = löst */
.card.st-open { background: var(--open-bg); border-color: var(--open); }
.card.st-working { background: var(--working-bg); border-color: var(--working); }
.card.st-solved { background: var(--solved-bg); border-color: var(--solved); }
.card.st-open .meta, .card.st-working .meta, .card.st-solved .meta,
.card.st-open p.body, .card.st-working p.body, .card.st-solved p.body { color: rgb(255 255 255 / .72); }
.card[class*="st-"] .msg.user { background: rgb(0 0 0 / .35); border-color: rgb(255 255 255 / .12); }
.card[class*="st-"] .msg.admin { background: rgb(255 255 255 / .08); }
.card[class*="st-"] textarea, .card[class*="st-"] .btn.ghost { background: rgb(0 0 0 / .4); }
.ticket.selected { outline: 2px solid var(--text); outline-offset: 2px; }
.tag { font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--brand-soft); color: var(--text); font-weight: 600; }
.foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.metoo[aria-pressed="true"] { background: var(--solved-bg); color: var(--solved); }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

.detail h2 { margin: 10px 0 6px; font-size: 20px; }
.detail .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.thread { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .who { font-size: 12px; font-weight: 700; margin-bottom: 2px; opacity: .8; }
.msg.admin { background: var(--brand-soft); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: var(--bg); border: 1px solid var(--line); align-self: flex-end; border-bottom-right-radius: 4px; }
.replybox { margin-top: 14px; }
.replybox textarea { min-height: 70px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filters button { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.filters button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.ticket.unseen { border-left-width: 6px; }
.hidden { display: none !important; }

/* ---------- Dator ---------- */
h2.section { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 6px 0 12px; display: flex; align-items: center; gap: 6px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
.split aside { position: sticky; top: 96px; }
@media (min-width: 900px) {
  .wrap { max-width: 1100px; padding: 0 32px 60px; }
  header.top { align-items: center !important; padding: 22px 0 18px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
  header.top .brand { display: flex; align-items: center; gap: 20px; }
  header.top .wordmark { height: 46px; margin: 0; }
  header.top h1 { font-size: 22px; padding-left: 20px; border-left: 1px solid var(--line); }
  #notif .notice { display: inline-flex; align-items: center; gap: 12px; }
  .ticket { padding: 18px 20px; }
  .ticket h3 { font-size: 17px; }
}

.split.admin { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); }
.split.admin .detail-pane { position: sticky; top: 96px; max-height: calc(100vh - 110px); overflow-y: auto; }

/* ---------- Arkiv & statistik ---------- */
.tabs.nav { margin-top: 0; }
.viz-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.viz-filters .seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.viz-filters .seg button { border: 0; background: none; color: var(--muted); padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.viz-filters .seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.viz-filters input.search { flex: 1 1 220px; min-width: 0; width: auto; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.viz-filters select { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.viz-bar { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 10px; }
.table-wrap { overflow-x: auto; padding: 0; }
table.archive { width: 100%; border-collapse: collapse; font-size: 14px; }
table.archive th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.archive td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.archive tbody tr:last-child td { border-bottom: 0; }
.card table.archive tbody tr { cursor: pointer; }
.card table.archive tbody tr:hover td { background: var(--brand-soft); }
table.archive td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.archive td.nowrap { white-space: nowrap; }
table.archive td.title { min-width: 220px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { margin: 0; }
.tile-label { color: var(--muted); font-size: 13px; }
.tile-value { font-size: 28px; font-weight: 650; margin-top: 4px; font-variant-numeric: proportional-nums; }
.tile .now { display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; margin-top: 4px; }
.viz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.viz-grid .viz-card { margin: 0; }
.viz-card { margin-bottom: 12px; }
.viz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.viz-head h3 { margin: 0; font-size: 16px; }
svg.viz { display: block; overflow: visible; max-width: 100%; }
svg.viz .grid { stroke: var(--line); stroke-width: 1; }
svg.viz .axis { fill: var(--muted); font-size: 12px; }
svg.viz .label { fill: var(--text); font-size: 13px; }
svg.viz .value { fill: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
svg.viz .mark { fill: #3987e5; }
svg.viz g:hover .mark { fill: #5598e7; }
svg.viz .empty-cell { fill: #1f1f1f; }
svg.viz rect[fill]:hover { stroke: var(--text); stroke-width: 1.5; }
.ramp-legend { display: flex; align-items: center; gap: 3px; margin-top: 10px; }
.ramp-legend i { width: 22px; height: 10px; border-radius: 3px; display: inline-block; }
.ramp-legend .hint { margin: 0 6px; }
.viz-tip { position: fixed; z-index: 50; pointer-events: none; display: none; background: #262626; border: 1px solid #3a3a3a; border-radius: 8px; padding: 7px 10px; font-size: 13px; box-shadow: 0 6px 20px rgb(0 0 0 / .5); }
.viz-tip .k { color: var(--muted); }
.viz-tip .v { color: var(--text); font-weight: 600; }
.catpick { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.catpick select { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; color: var(--text); }
.hbars { display: flex; flex-direction: column; gap: 2px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; align-items: center; gap: 10px; padding: 4px 0; border-radius: 6px; }
.hbar:hover { background: var(--brand-soft); }
.hbar-label { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.hbar-track { display: block; height: 18px; }
.hbar-track i { display: block; height: 100%; background: #3987e5; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar:hover .hbar-track i { background: #5598e7; }
.hbar-value { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; }
/* Obligatoriska fält: kraftigare ram */
input.required { border: 2px solid #8f8f8d; }
input.required:focus { border-color: var(--text); }
