/* Tillegg for innlogging, skjema, moduler, bemanningsplan og superadmin */
.left-bodies { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.left-bodies .tab-body { flex: 1; }
.row.wrap, .wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--bad); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.input.sm { width: auto; padding: 4px 6px; font-size: 12px; }
textarea.input { resize: vertical; font: inherit; }
.alert { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 4px; cursor: pointer; }
.x:hover { color: var(--bad); }
code.pw { background: #f1f5f9; padding: 4px 8px; border-radius: 6px; font-size: 15px; user-select: all; }
.gallery.one { grid-template-columns: 1fr; }
.photo-big { max-height: 65vh; object-fit: contain; background: #0f172a; }

/* Innlogging */
.login { position: fixed; inset: 0; background: linear-gradient(135deg, #111827, #1f2937 60%, #7c2d12); display: grid; place-items: center; padding: 16px; z-index: 60; }
.login-card { background: #fff; border-radius: 14px; padding: 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.login-card label, .stack label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.brand.big { font-size: 24px; color: var(--ink); }

/* Brukermeny */
.user { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.user-menu { position: absolute; right: 0; top: 44px; background: #fff; color: var(--ink); border-radius: 10px; box-shadow: var(--shadow); min-width: 240px; overflow: hidden; z-index: 30; }
.user-menu .um-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.user-menu button { display: block; width: 100%; text-align: left; border: 0; background: #fff; padding: 10px 14px; }
.user-menu button:hover { background: #fff7ed; }

/* Toast */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 99px; box-shadow: var(--shadow); font-size: 13px; transition: opacity .4s; }
.toast.err { background: #b91c1c; }
.toast.out { opacity: 0; }

/* Modal */
/* Lukkeknapp utenfor hjørnet, så den aldri dekker knapper i dialogen. Innholdet scroller inne i kortet. */
.modal-card { overflow: visible; padding: 0; }
#modal-body { max-height: 90vh; overflow: auto; padding: 18px; border-radius: 12px; }
#modal-close { top: -14px; right: -14px; width: 34px; height: 34px; border-radius: 50%; background: #fff; color: var(--ink);
  font-size: 22px; font-weight: 600; display: grid; place-items: center; padding: 0 0 2px; z-index: 2; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.35); border: 2px solid var(--line); }
#modal-close:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
@media (max-width: 600px) { #modal-close { top: 6px; right: 6px; } #modal-body { padding-top: 44px; } }
.modal-card.wide { max-width: 980px; }
.modal-card.xwide { max-width: 1400px; }
.modal-card .formgrid label { color: var(--muted); }
.modal-card h2 { margin-bottom: 10px; }

/* Modulkort */
.modgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 8px; }
.mod { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: block; cursor: default; position: relative; }
label.mod { cursor: pointer; }
.mod.on { border-color: var(--accent); background: #fff7ed; }
.mod input { position: absolute; top: 10px; right: 10px; accent-color: var(--accent); }
.mod b { display: block; padding-right: 20px; color: var(--ink); }

.formgrid > .full { grid-column: 1 / -1; }

/* Brukertabell */
table.users { display: block; overflow-x: auto; }
table.users td { vertical-align: middle; }
table.users .num { white-space: nowrap; }

/* Segmentknapper */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 5px 10px; font-size: 12px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: #fff; }

/* Bemanningsplan */
.pb { border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 64vh; position: relative; }
.pb-row { display: flex; border-bottom: 1px solid var(--line); min-width: 760px; }
.pb-head { position: sticky; top: 0; background: #f8fafc; z-index: 3; height: 38px; }
.pb-name { width: 180px; flex: none; padding: 6px 10px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; background: #fff; position: sticky; left: 0; z-index: 2; cursor: pointer; }
.pb-head .pb-name { background: #f8fafc; cursor: default; }
.pb-name .chip { align-self: flex-start; }
.pb-track { flex: 1; position: relative; cursor: copy; min-height: 32px; }
.pb-head .pb-track { cursor: default; }
.pb-track.unavail { background: repeating-linear-gradient(45deg, #fff, #fff 6px, #fef2f2 6px, #fef2f2 12px); }
.pb-week { position: absolute; top: 0; bottom: 0; padding: 4px 6px; font-size: 11px; font-weight: 600; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.pb-week span { font-weight: 400; color: var(--muted); }
.pb-body { position: relative; }
.pb-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: #f1f5f9; z-index: 0; pointer-events: none; }
.pb-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); z-index: 2; pointer-events: none; opacity: .7; }
.pb-bar { position: absolute; height: 20px; border-radius: 5px; color: #fff; font-size: 11px; font-weight: 600; padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; z-index: 1; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.pb-bar:hover { filter: brightness(1.1); }
.pb-bar.conflict { outline: 2px solid var(--bad); outline-offset: 1px; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.0), rgba(255,255,255,.0) 6px, rgba(220,38,38,.45) 6px, rgba(220,38,38,.45) 12px) !important; }
.pb-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; }
.pb-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -2px; }

/* Maskinstatus-markører */
.mk.machine.Service { background: #f87171; color: #fff; }
.mk.machine.Tomgang { background: #fcd34d; }

/* Superadmin */
.admin { position: fixed; inset: 0; background: var(--bg); overflow: auto; }
.admin .topbar { position: sticky; }
.admin .grow { flex: 1; }
.sa-main { display: grid; grid-template-columns: 380px 1fr; gap: 16px; padding: 72px 16px 24px; max-width: 1400px; margin: 0 auto; }
.sa-list, .sa-detail { background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 16px; align-self: start; }
.kpis.three { grid-template-columns: repeat(3, 1fr); margin-bottom: 10px; }
@media (max-width: 900px) { .sa-main { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .uname { display: none; } }
