/* Card Factory Rip'n Ship – mørkt kontrollpanel for widescreen og nettbrett */
:root {
  --bg: #0d0f12;
  --panel: #161a20;
  --panel-2: #1d222a;
  --line: #2a313b;
  --text: #e9edf2;
  --muted: #8d97a5;
  --accent: #f5c518;      /* gull – "hits" */
  --accent-ink: #1a1500;
  --blue: #4da3ff;
  --green: #3ecf8e;
  --orange: #ff9f43;
  --red: #ff5d5d;
  --purple: #b48cff;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ---------- topplinje ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  background: rgba(13, 15, 18, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brand img { height: 34px; width: auto; display: block; }
.brand span { font-weight: 700; letter-spacing: .02em; font-size: 15px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  position: relative;
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 600;
}
.tab:hover { background: var(--panel); color: var(--text); }
.tab.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.tab .count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px;
  border-radius: 10px; background: var(--line); color: var(--text); font-size: 12px; text-align: center;
}
.tab .count.hot { background: var(--accent); color: var(--accent-ink); }
.spacer { flex: 1; }
.session-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line);
  font-weight: 600; font-size: 13.5px; cursor: pointer;
}
.session-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.session-pill.live .dot { background: var(--red); box-shadow: 0 0 0 0 rgba(255, 93, 93, .7); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,93,93,.6);} 70% { box-shadow: 0 0 0 9px rgba(255,93,93,0);} 100% { box-shadow: 0 0 0 0 rgba(255,93,93,0);} }
.icon-btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 6px 10px; cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.conn.ok { background: var(--green); }

/* ---------- generelt ---------- */
main { padding: 20px 24px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
h2 { margin: 0 0 12px; font-size: 18px; letter-spacing: .01em; }
h3 { margin: 0 0 8px; font-size: 15px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: transform .05s, background .15s, border-color .15s;
}
.btn:hover { border-color: #3a4350; background: #232934; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #ffd43b; }
.btn.blue { background: #1f3a5c; border-color: #2c5687; }
.btn.blue:hover { background: #24466f; }
.btn.green { background: #173d2e; border-color: #23664a; color: #c9f5e1; }
.btn.green:hover { background: #1c4a38; }
.btn.purple { background: #2e2350; border-color: #4a3a80; color: #e4d9ff; }
.btn.purple:hover { background: #382a62; }
.btn.danger { background: #4a1d1d; border-color: #7a2c2c; color: #ffd6d6; }
.btn.ghost { background: transparent; }
.btn.big { padding: 12px 20px; font-size: 16px; border-radius: 11px; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.input, textarea.input {
  width: 100%; background: #0f1216; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; outline: none;
}
.input:focus { border-color: var(--blue); }
textarea.input { resize: vertical; min-height: 64px; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .02em;
  background: var(--line); color: var(--text);
}
.badge.ship { background: #3d2a0c; color: #ffcf8a; border: 1px solid #7a5418; }
.badge.note { background: #2b2410; color: var(--accent); }
.badge.manual { background: #22283a; color: #b7c4ff; }
.badge.blue { background: #16304d; color: #9dccff; }
.badge.green { background: #143426; color: #9ef0c8; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- varsler ---------- */
.alerts { display: grid; gap: 8px; margin-bottom: 16px; }
.alert {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px; background: #3a2a0b; border: 1px solid #8a6415; color: #ffe2a8;
}
.alert .msg { flex: 1; }

/* ---------- live kø ---------- */
.live-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .live-grid { grid-template-columns: 1fr; } }

.spotlight {
  position: relative; overflow: hidden;
  border-radius: 16px; padding: 22px 24px; margin-bottom: 20px;
  background: radial-gradient(1200px 300px at 0% 0%, rgba(245, 197, 24, .16), transparent 60%), var(--panel);
  border: 1px solid #4b3f12;
  box-shadow: var(--shadow);
}
.spotlight.empty-spot { border-color: var(--line); background: var(--panel); }
.spot-label { text-transform: uppercase; letter-spacing: .16em; font-size: 12px; font-weight: 800; color: var(--accent); }
.spot-name { font-size: 44px; font-weight: 800; line-height: 1.1; margin: 6px 0 4px; letter-spacing: -.01em; }
.spot-meta { color: var(--muted); font-size: 15px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.spot-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; margin-top: 16px; }
@media (max-width: 900px) { .spot-body { grid-template-columns: 1fr; } }
.spot-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.items li { display: flex; gap: 10px; align-items: baseline; padding: 7px 10px; background: rgba(255,255,255,.03); border-radius: 8px; }
.items .qty { font-weight: 800; color: var(--accent); min-width: 34px; }
.items .ord { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.prepaid-banner {
  margin-top: 14px; padding: 10px 14px; border-radius: 10px;
  background: #3d2a0c; border: 1px solid #a8701c; color: #ffd598; font-weight: 700;
}

.queue { display: grid; gap: 10px; }
.qcard {
  display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  animation: slidein .35s ease-out;
}
.qcard.prepaid { border-color: #7a5418; box-shadow: inset 4px 0 0 var(--orange); }
@keyframes slidein { from { transform: translateY(-6px); } to { transform: none; } }
.qpos { width: 40px; height: 40px; border-radius: 10px; background: var(--panel-2); display: grid; place-items: center; font-weight: 800; color: var(--muted); }
.qname { font-size: 19px; font-weight: 800; cursor: pointer; }
.qname:hover { text-decoration: underline; }
.qinfo { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.qitems { color: #c3cbd6; font-size: 13px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qactions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.side { display: grid; gap: 16px; position: sticky; top: 76px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel-2); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 24px; }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- korthotell og pakkeliste ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input { max-width: 340px; }
.cust-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.ccard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.ccard header { display: flex; align-items: flex-start; gap: 10px; }
.ccard header .who { flex: 1; min-width: 0; }
.ccard .name { font-size: 18px; font-weight: 800; cursor: pointer; }
.ccard .name:hover { text-decoration: underline; }
.ccard .orders { display: flex; gap: 6px; flex-wrap: wrap; }
.order-chip { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; padding: 2px 8px; border-radius: 6px; background: #10141a; border: 1px solid var(--line); }
.order-chip.ship { border-color: #7a5418; color: #ffcf8a; }
.entry-block { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 6px; }
.entry-block .head { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.addr { font-size: 13.5px; line-height: 1.5; background: #10141a; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.pii-warning { margin-bottom: 14px; padding: 10px 14px; border-radius: 10px; background: #2a1518; border: 1px solid #6b2a33; color: #ffc2c8; font-weight: 600; }
.notes-input { min-height: 54px; font-size: 14px; }
.saved-hint { font-size: 12px; color: var(--green); opacity: 0; transition: opacity .3s; }
.saved-hint.show { opacity: 1; }

/* ---------- tabeller ---------- */
table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--panel-2); }
table.list tr:last-child td { border-bottom: 0; }
.res-ripnship, .res-both { color: var(--green); font-weight: 700; }
.res-shipping { color: var(--orange); font-weight: 700; }
.res-ignored, .res-ignored_pos, .res-duplicate { color: var(--muted); }
.res-rejected, .res-error { color: var(--red); font-weight: 700; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal { width: min(760px, 100%); max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; box-shadow: var(--shadow); }
.modal header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.modal header h2 { margin: 0; flex: 1; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; margin-bottom: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--blue); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; animation: slidein .25s ease-out; }
.toast.ok { border-left-color: var(--green); }
.toast.warn { border-left-color: var(--orange); }
.toast.err { border-left-color: var(--red); }

/* ---------- innlogging ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); text-align: center; }
.login-card img { width: 220px; max-width: 80%; margin: 4px auto 18px; display: block; }
.login-card .err { color: var(--red); min-height: 20px; margin: 8px 0; font-size: 14px; }

/* ---------- utskrift av pakkeliste ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  .topbar, .alerts, .toolbar .input, .toolbar .btn, .pii-warning, .ccard header .btn, .btn, .saved-hint, .toasts { display: none !important; }
  .view { display: none !important; }
  #view-ready { display: block !important; }
  main { padding: 0; }
  .cust-grid { display: block; }
  .ccard { break-inside: avoid; border: 1px solid #999; background: #fff; color: #000; margin-bottom: 10px; }
  .addr, .order-chip, .items li, textarea.input { background: #fff !important; color: #000 !important; border-color: #bbb !important; }
  .muted, .items .ord { color: #444 !important; }
  .items .qty { color: #000; }
  textarea.input { border: 0 !important; padding: 0; min-height: 0; resize: none; }
}

/* ---------- Live-oppsett: normal skjerm vs. superwide 49" (3840×1080 / 5120×1440) ---------- */
.live-layout { grid-template-areas: "spot side" "queue side"; grid-template-columns: minmax(0, 1fr) 360px; }
.area-spot { grid-area: spot; }
.area-queue { grid-area: queue; }
.area-side { grid-area: side; align-self: start; }
@media (max-width: 1100px) {
  .live-layout { grid-template-areas: "spot" "queue" "side"; grid-template-columns: 1fr; }
}
@media (min-width: 2300px) {
  body { font-size: 16px; }
  .live-layout { grid-template-areas: "spot queue side"; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) 400px; gap: 24px; }
  .area-spot .spotlight { margin-bottom: 0; min-height: calc(100vh - 120px); padding: 32px 36px; }
  .spot-name { font-size: 72px; }
  .spot-meta { font-size: 18px; }
  .spot-body { grid-template-columns: 1fr; }
  .items li { font-size: 17px; padding: 9px 12px; }
  .notes-input { font-size: 16px; }
  .area-queue .queue { max-height: calc(100vh - 150px); overflow: auto; padding-right: 4px; }
  .qname { font-size: 21px; }
  .cust-grid { grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); }
}
@media (min-width: 4000px) {
  body { font-size: 17px; }
  .live-layout { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 440px; }
  .spot-name { font-size: 88px; }
}
