/* Erko Jobb. Ett gemensamt formspråk för admin och arbetarvyn. */

:root {
  --ink: #101418;
  --ink-2: #2B3138;
  --muted: #69717C;
  --faint: #9AA1AB;
  --line: #E7E9EC;
  --line-2: #D9DCE1;
  --bg: #F5F6F7;
  --card: #FFFFFF;
  --brand: #F25A22;
  --brand-ink: #C9440F;
  --brand-soft: #FFF1EA;
  --ok: #12B76A;
  --ok-soft: #E9F8F0;
  --warn: #B54708;
  --warn-soft: #FFF6E5;
  --bad: #D92D20;
  --bad-soft: #FEF0EF;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 20, 24, .04), 0 1px 3px rgba(16, 20, 24, .06);
  --shadow-lg: 0 12px 32px -8px rgba(16, 20, 24, .18), 0 2px 6px rgba(16, 20, 24, .06);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
svg { flex-shrink: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* Admin-ram */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--card); border-right: 1px solid var(--line);
  padding: 20px 14px;
}
.side .logo { display: block; padding: 4px 10px 22px; }
.side .logo img { height: 34px; width: auto; display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a svg { color: var(--faint); transition: color .15s; }
.nav a:hover { background: var(--bg); }
.nav a.on { background: var(--ink); color: #fff; }
.nav a.on svg { color: var(--brand); }
.side .foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.who { display: flex; align-items: center; gap: 10px; padding: 0 10px 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-ink);
  font-weight: 650; font-size: 13px;
}
.who b { display: block; font-weight: 600; font-size: 13px; }
.who span { font-size: 12px; color: var(--muted); }

.main { min-width: 0; padding: 28px 36px 64px; animation: rise .35s var(--ease); }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.top .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.mtop, .mnav { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .mtop {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20;
    padding: 12px 16px; background: rgba(255,255,255,.92);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--line);
  }
  .mtop img { height: 28px; }
  .mnav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mnav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 11px; font-weight: 500; color: var(--muted); padding: 6px 0;
  }
  .mnav a.on { color: var(--ink); }
  .mnav a.on svg { color: var(--brand); }
  .main { padding: 20px 16px 110px; }
  h1 { font-size: 20px; }
}

/* Knappar och fält */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink);
  font: 600 13.5px/1 var(--font); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.dark:hover { background: var(--ink-2); }
.btn.brand { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(242,90,34,.3); }
.btn.brand:hover { background: var(--brand-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg); color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 34px; padding: 0; }
.btn[disabled] { opacity: .5; pointer-events: none; }

label.f { display: block; }
label.f > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.in, select.in, textarea.in {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); font: 400 14px var(--font);
  transition: border-color .15s, box-shadow .15s;
}
textarea.in { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.in:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(16,20,24,.08); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stack { display: grid; gap: 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* Kort och listor */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card .hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.card .bd { padding: 18px; }
.card .ft { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }

.rows { list-style: none; margin: 0; padding: 0; }
.rows > li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.rows > li:last-child { border-bottom: 0; }
.rows .grow { flex: 1; min-width: 0; }
.rows .t { font-weight: 600; }
.rows .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: #FAFBFB;
}
.tbl td { padding: 12px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }

/* Zoner och märken */
.zone {
  display: inline-flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 10px 0 8px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--faint)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, #999) 18%, transparent); }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; background: var(--bg); color: var(--ink-2);
}
.badge.ok { background: var(--ok-soft); color: #067647; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.live { background: var(--brand-soft); color: var(--brand-ink); }
.badge.live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--brand);
  animation: pulse 1.6s infinite;
}
.prio { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bad); }

/* Zonflikar */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--card);
  font-weight: 600; font-size: 13px; color: var(--ink-2);
  transition: all .15s;
}
.tabs a .n { color: var(--faint); font-weight: 500; }
.tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs a.on .n { color: rgba(255,255,255,.6); }

/* Siffror */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { padding: 16px 18px; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat .v { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* Framsteg */
.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > i {
  display: block; height: 100%; border-radius: inherit;
  background: var(--c, var(--brand));
  width: 0; transition: width .9s var(--ease);
}

/* Teamkort på översikten */
.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.team { padding: 18px; position: relative; overflow: hidden; animation: rise .4s var(--ease) both; }
.team::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--c); }
.team .row1 { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.team .count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.team .count b { color: var(--ink); font-size: 18px; font-weight: 650; }
.team .now { margin-top: 14px; padding: 12px; border-radius: var(--radius-sm); background: var(--bg); }
.team .now .lbl { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.team .now .addr { font-weight: 600; margin-top: 2px; }
.team .people { display: flex; margin-top: 14px; }
.team .people .avatar { width: 26px; height: 26px; font-size: 11px; border: 2px solid #fff; margin-left: -6px; }
.team .people .avatar:first-child { margin-left: 0; }
.team.done::before { background: var(--ok); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; align-items: center; padding: 7px 0; font-size: 13px; }
.timeline .ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--line-2); background: #fff; }
.timeline li.klar .ic { background: var(--ok); border-color: var(--ok); color: #fff; }
.timeline li.pagar .ic { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.timeline li.klar .nm { color: var(--muted); }

/* Karta */
.map { height: 420px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: #EEF0F2; z-index: 0; }
.map.tall { height: calc(100vh - 160px); min-height: 420px; position: sticky; top: 24px; }
@media (max-width: 1100px) { .map.tall { height: 360px; position: static; } }
.pin {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--c); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3);
  display: grid; place-items: center;
}
.pin span { transform: rotate(45deg); color: #fff; font: 700 11px var(--font); }
.pin.klar { background: var(--ok); }
.pin.vantar { opacity: .85; }
.leaflet-container { font-family: var(--font) !important; }

/* Tomt läge */
.empty { text-align: center; padding: 48px 20px; }
.empty .ring {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px;
  display: grid; place-items: center; background: var(--bg); color: var(--muted);
}
.empty h2 { margin-bottom: 4px; }
.empty p { color: var(--muted); margin-bottom: 16px; }

/* Plan */
.plan-row { display: grid; grid-template-columns: 1fr 220px; gap: 16px; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.plan-row:last-child { border-bottom: 0; }
@media (max-width: 640px) { .plan-row { grid-template-columns: 1fr; } }

/* Dragbar lista */
.grip { cursor: grab; color: var(--faint); padding: 4px; display: grid; place-items: center; }
.grip:active { cursor: grabbing; }
.sortable-ghost { opacity: .4; background: var(--brand-soft); }
.seq {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c, var(--ink)); color: #fff; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.note { font-size: 12.5px; color: var(--warn); font-weight: 500; }

/* Dialog */
dialog {
  border: 0; padding: 0; border-radius: 16px; width: min(520px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg); color: var(--ink);
}
dialog::backdrop { background: rgba(16,20,24,.4); backdrop-filter: blur(2px); }
dialog[open] { animation: pop .25s var(--ease); }
dialog .hd { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog .bd { padding: 20px; }
dialog .ft { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* Notis */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 100; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 10px; background: var(--ink); color: #fff;
  font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toast 3.6s var(--ease) forwards;
}
.toast svg { color: var(--ok); }
.toast.bad svg { color: #FDA29B; }
@media (max-width: 900px) { .toast { bottom: 96px; width: calc(100% - 32px); } }

/* Inloggning */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, #fff 0%, var(--bg) 60%); }
.auth .box { width: 100%; max-width: 380px; animation: rise .5s var(--ease); }
.auth .box img { height: 44px; display: block; margin: 0 auto 28px; }
.auth .card { padding: 26px; }
.auth h1 { font-size: 18px; text-align: center; margin-bottom: 4px; }
.auth .sub { text-align: center; color: var(--muted); margin-bottom: 22px; }
.err { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: var(--radius-sm); font-weight: 500; font-size: 13px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(242,90,34,.5); } 70% { box-shadow: 0 0 0 7px rgba(242,90,34,0); } 100% { box-shadow: 0 0 0 0 rgba(242,90,34,0); } }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 12px); } 8%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, 6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Kartan i dämpad gråton så att zonfärgerna syns */
.leaflet-tile-pane { filter: grayscale(.9) contrast(.92) brightness(1.04); }
