/* TicketMeister – baserat på EasyCashiers designsystem (navy #2F435D, cyan #04AAE4, Roboto + Roboto Slab). */

:root, [data-theme="dark"] {
  --bg: #16212F; --surface: #1F2E42; --surface2: #283A51; --border: #2E425A; --field: #3C5375; --input: #192638;
  --text: #E4EBF3; --strong: #FFFFFF; --muted: #A3B1C4; --accent: #04AAE4; --accent-tint: rgba(4,170,228,.16);
  --accent-text: #5CCBF1; --navy: #04AAE4; --on-navy: #1F2E42; --rod: #F2847C; --gron: #4FC994; --gul: #F2B65A;
  --row-alt: rgba(255,255,255,.025); --sel: rgba(4,170,228,.13); --bar1: #3C5375; --bar2: #0388B8; --bar3: #04AAE4;
  --hair: rgba(255,255,255,.08); color-scheme: dark;
}
[data-theme="light"] {
  --bg: #F4F7FA; --surface: #FFFFFF; --surface2: #ECF1F6; --border: #E1E7EE; --field: #CBD5E1; --input: #FFFFFF;
  --text: #2F435D; --strong: #1F2E42; --muted: #56657B; --accent: #04AAE4; --accent-tint: #E5F6FC;
  --accent-text: #026F95; --navy: #2F435D; --on-navy: #FFFFFF; --rod: #C8413B; --gron: #1E7F55; --gul: #9A6212;
  --row-alt: #F8FAFC; --sel: #E5F6FC; --bar1: #CBD5E1; --bar2: #04AAE4; --bar3: #2F435D;
  --hair: rgba(31,46,66,.10); color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Roboto', -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif; font-size: 14px;
  color: var(--text); background: var(--bg); min-height: 100vh;
}
a { color: var(--accent-text); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
input, textarea { font: inherit; color: var(--text); }
:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(4,170,228,.45); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.h { font-family: 'Roboto Slab', Georgia, serif; font-weight: 700; color: var(--strong); letter-spacing: -.3px; margin: 0; }
.label { font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 5px; }
.row { display: flex; align-items: center; gap: 8px; }

/* ─── Fält och knappar ─── */
.field { height: 34px; width: 100%; border: 1px solid var(--field); border-radius: 3px; background: var(--input); padding: 0 10px; outline: none; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(4,170,228,.32); }
.field::placeholder { color: var(--muted); opacity: .8; }
.field.code { height: 50px; font-size: 24px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, Consolas, monospace; }

button { transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 160ms cubic-bezier(.23,1,.32,1); }
.btn { height: 36px; padding: 0 18px; border-radius: 999px; border: 2px solid transparent; background: transparent; font-weight: 500;
       display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.primary { background: #04AAE4; color: #1F2E42; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #3BBDEB; }
.btn.update { background: #D98A1F; color: #1F2E42; font-weight: 700; }
.btn.update:hover { background: #E59D3B; }
.btn.ghost { border-color: var(--field); }
.btn.ghost:hover:not(:disabled) { background: var(--accent-tint); border-color: var(--accent); }
.btn.cancel { background: #C8413B; color: #FFFFFF; }
.btn.danger { border-color: var(--rod); color: var(--rod); }
.btn.danger:hover { background: rgba(200,65,59,.08); }
.icon { width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
        display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.icon.sm { width: 28px; height: 28px; }
.icon.bare { border: 0; background: transparent; width: 26px; height: 26px; }
.icon:hover:not(:disabled) { background: var(--accent-tint); border-color: var(--accent); }
.linkbtn { border: 0; background: transparent; padding: 0; color: var(--accent-text); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; align-self: flex-start; }
.btn:active, .icon:active, .typ:active, .tab:active, .nav:active, .segb:active, .dot:active, .swatch:active { transform: scale(.97); }

.card { background: var(--surface); border-radius: 8px; box-shadow: 0 0 0 1px var(--hair), 0 1px 2px rgba(17,24,33,.04); }
.badge { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.badge.c { background: var(--accent-tint); color: var(--accent-text); }
.badge.warn { color: var(--gul); }
.info { min-height: 20px; font-size: 13px; font-weight: 500; }
.info.err { color: var(--rod); } .info.ok { color: var(--gron); } .info.edit, .info.warn { color: var(--gul); }

/* ─── Sidhuvud ─── */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { height: 26px; width: auto; display: block; }
.brand .sep { width: 1px; height: 22px; background: var(--border); }
.nav { height: 34px; padding: 0 14px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); font-weight: 500; }
.nav:hover { color: var(--text); background: var(--surface2); }
.nav.on { color: var(--accent-text); background: var(--accent-tint); }
.prof { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid transparent; background: transparent; text-align: left; }
.prof:hover, .prof[aria-expanded="true"] { background: var(--surface2); }
.avatar { width: 30px; height: 30px; border-radius: 999px; color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); width: 270px; background: var(--surface); border-radius: 10px;
        box-shadow: 0 0 0 1px var(--hair), 0 8px 24px rgba(0,0,0,.18); padding: 6px; z-index: 41; transform-origin: top right;
        transition: opacity 150ms cubic-bezier(.23,1,.32,1), transform 150ms cubic-bezier(.23,1,.32,1); }
@starting-style { .menu { opacity: 0; transform: scale(.97); } }
.mi { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-size: 13px; }
.mi:hover, .mi:focus-visible { background: var(--surface2); box-shadow: none; }
.backdrop { position: fixed; inset: 0; background: transparent; border: 0; z-index: 40; cursor: default; }
.backdrop:focus-visible { box-shadow: none; }

/* ─── Formulär ─── */
main.wide { display: flex; flex-wrap: wrap; gap: 20px; padding: 20px 24px 32px; max-width: 1560px; margin: 0 auto; align-items: flex-start; }
main.narrow { max-width: 1200px; margin: 0 auto; padding: 20px 24px 48px; display: flex; flex-direction: column; gap: 20px; }
.form { flex: 1 1 380px; max-width: 470px; padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.typgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.typ { height: 34px; border: 1px solid var(--field); border-radius: 3px; background: var(--input); font-size: 13px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.typ:hover { border-color: var(--accent); }
.typ.on { background: var(--navy); border-color: var(--navy); color: var(--on-navy); font-weight: 500; }
.pop { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--surface); border-radius: 8px;
       box-shadow: 0 0 0 1px var(--hair), 0 4px 16px rgba(0,0,0,.18); z-index: 30; padding: 4px 0; }
.sugg { display: block; width: 100%; text-align: left; padding: 6px 12px; border: 0; background: transparent; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: none; }
.sugg:hover, .sugg.hl { background: var(--accent-tint); color: var(--accent-text); }
.dot { width: 24px; height: 24px; border-radius: 999px; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--field); padding: 0; }
.dot.on { box-shadow: 0 0 0 2px var(--text); }

/* ─── Lista ─── */
.list { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.tab { height: 30px; padding: 0 10px 0 12px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--muted); font-weight: 500; display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.tab:hover { color: var(--text); background: var(--surface2); }
.tab.on { background: var(--accent-tint); color: var(--accent-text); border-color: var(--accent); }
.count { font-size: 11px; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--surface2); color: var(--muted); text-align: center; }
.tab.on .count { background: var(--surface); color: var(--accent-text); }
.periodbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--row-alt); }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--field); border-radius: 999px; background: var(--surface); gap: 2px; }
.segb { height: 26px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.segb:hover { color: var(--text); background: var(--surface2); }
.segb.on { background: var(--navy); color: var(--on-navy); }
.search { position: relative; flex: 0 1 260px; min-width: 180px; margin-left: auto; }
.search svg { position: absolute; left: 10px; top: 9px; color: var(--muted); }
.search .field { padding-left: 30px; height: 32px; }
.rows { flex: 1; overflow: auto; max-height: 640px; min-height: 440px; padding: 4px 0; }
.trow { display: flex; gap: 10px; align-items: center; width: 100%; min-height: 23px; padding: 3px 14px; border: 0; background: transparent; text-align: left; font-size: 13px; line-height: 17px; white-space: nowrap; transition: none; }
.trow.alt { background: var(--row-alt); }
.trow:hover { background: var(--surface2); }
.trow.sel { background: var(--sel); box-shadow: inset 3px 0 0 var(--accent); }
.trow .t { font-variant-numeric: tabular-nums; flex: none; width: 84px; opacity: .85; }
.trow .t.long { width: 132px; }
.trow .who { flex: none; width: 92px; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; overflow: hidden; }
.trow .main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dotsm { width: 8px; height: 8px; border-radius: 999px; flex: none; display: inline-block; }
.detail { padding: 8px 14px 10px 108px; background: var(--sel); white-space: pre-line; font-size: 13px; line-height: 1.55; border-bottom: 1px solid var(--border); }
.footer { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--border); }
.empty { margin: 40px 0; text-align: center; color: var(--muted); }

/* ─── Statistik ─── */
.tile { position: absolute; border: 1px solid var(--surface); padding: 6px 8px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; font-size: 12px; line-height: 1.25; }
.th { text-align: right; padding: 6px 12px; font-weight: 500; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--border); }
.td { text-align: right; padding: 6px 12px; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--border); }
.td.cur, .th.cur { background: var(--accent-tint); color: var(--accent-text); font-weight: 700; }

/* ─── Admin ─── */
.adm-grid { max-width: 1200px; margin: 0 auto; padding: 20px 24px 48px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr)); gap: 20px; align-items: start; }
.adm-row { display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-bottom: 1px solid var(--border); font-size: 13px; min-height: 40px; }
.swatch { width: 28px; height: 28px; border-radius: 999px; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--hair); padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }

/* ─── Dialoger, paneler, notiser ─── */
.scrim { position: fixed; inset: 0; background: rgba(17,24,33,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; transition: opacity 200ms ease; }
@starting-style { .scrim { opacity: 0; } }
.dialog { width: 420px; max-width: 100%; padding: 22px; display: flex; flex-direction: column; gap: 12px;
          transition: opacity 200ms cubic-bezier(.23,1,.32,1), transform 200ms cubic-bezier(.23,1,.32,1); }
@starting-style { .dialog { opacity: 0; transform: scale(.95); } }
.sheet { position: fixed; top: 8px; right: 8px; bottom: 8px; width: 420px; max-width: calc(100vw - 16px); background: var(--surface); border-radius: 12px; z-index: 56;
         display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 0 0 1px var(--hair), 0 16px 48px rgba(0,0,0,.24);
         transition: transform 420ms cubic-bezier(.32,.72,0,1); }
@starting-style { .sheet { transform: translateX(calc(100% + 16px)); } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 14px 20px; border-bottom: 1px solid var(--border); }
.sheet-body { flex: 1; overflow: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); }
.toast { position: fixed; right: 24px; bottom: 24px; width: 356px; max-width: calc(100vw - 32px); background: var(--surface); color: var(--strong);
         border-radius: 8px; padding: 12px 12px 12px 16px; display: flex; align-items: center; gap: 12px; z-index: 60; font-size: 13px;
         box-shadow: 0 0 0 1px var(--hair), 0 4px 12px rgba(0,0,0,.12); transition: opacity 400ms ease, transform 400ms ease; }
@starting-style { .toast { opacity: 0; transform: translateY(100%); } }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; padding: 14px 16px; border-radius: 8px; background: var(--row-alt); font-size: 14px; color: var(--strong); }
.rules { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.rules li { display: flex; align-items: center; gap: 8px; }

/* ─── Inloggning ─── */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.auth-inner { width: 410px; max-width: 100%; display: flex; flex-direction: column; gap: 22px; }
.auth-card { padding: 26px 24px 22px; display: flex; flex-direction: column; gap: 16px; }
.steps { display: flex; gap: 6px; }
.steps span { flex: 1; height: 4px; border-radius: 999px; background: var(--surface2); }
.steps span.on { background: var(--accent); }
.qr { align-self: center; padding: 12px; background: #FFFFFF; border-radius: 8px; box-shadow: 0 0 0 1px var(--hair); line-height: 0; }
.qr svg { width: 180px; height: 180px; display: block; }

.loading { min-height: 60vh; display: grid; place-items: center; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .toast, .dialog, .sheet, .menu { transition: opacity 200ms ease; }
  @starting-style { .toast, .dialog, .sheet, .menu { transform: none; opacity: 0; } }
}

@media print {
  .noprint { display: none !important; }
  body { background: #fff; }
  [data-theme] { --bg: #fff; }
  .sec { break-after: page; box-shadow: none; }
}
