:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e7e9ed;
  --line2: #f2f3f5;
  --ink: #1a1c22;
  --ink2: #3a3e48;
  --muted: #5b6270;
  --muted2: #8b909c;
  --muted3: #a2a6b0;

  --accent: #e5561d;
  --accent-dark: #c4460f;

  --green: #1f9d57;
  --green-ink: #1f7a46;
  --green-bg: #e7f5ec;
  --live: #28a35f;

  --red: #d8483a;
  --red-ink: #b3392c;
  --red-bg: #fbe9e6;
  --red-line: #edd3ce;

  --blue-ink: #2f5bd0;
  --blue-bg: #eaf0fe;
  --yellow-ink: #b6791f;
  --yellow-bg: #fbf3e2;
  --neutral-ink: #5b6270;
  --neutral-bg: #eef0f3;

  --avatar-bg: #f0e5df;
  --avatar-ink: #a8552e;

  --header: #15161a;
  --header-line: #34363d;
  --header-ink: #ffffff;
  --header-muted: #b7bac2;
  --header-muted2: #d6d8dd;

  --r-card: 16px;
  --r-btn: 12px;
  --r-input: 10px;
  --shadow: 0 1px 2px rgba(16, 18, 25, 0.04), 0 6px 20px rgba(16, 18, 25, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: #ffd9c7; }

.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }

@keyframes bzpulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.82); } }

/* ---------- Header ---------- */
header.topbar {
  background: var(--header);
  color: var(--header-ink);
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 30;
}
header.topbar .brand { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
header.topbar .brand span.dot { color: var(--accent); }
header.topbar .brand span.suffix { font-weight: 500; color: var(--header-muted); font-size: 14px; letter-spacing: 0; }
header.topbar .who { font-size: 13px; color: var(--header-muted2); display: flex; gap: 14px; align-items: center; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.user-chip .avatar { width: 30px; height: 30px; background: #2c2e35; color: #e7e8ec; }
.btn-header {
  background: transparent; border: 1px solid var(--header-line); color: var(--header-muted2);
  font-size: 13px; font-weight: 500; padding: 7px 13px; border-radius: 9px; cursor: pointer;
}
.btn-header:hover { background: #22242a; }

/* ---------- Layout ---------- */
.container { max-width: 960px; margin: 0 auto; padding: 24px 18px 60px; }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card.narrow { width: 100%; max-width: 400px; }
.card-label { font-size: 13px; font-weight: 600; color: var(--muted2); letter-spacing: 0.02em; text-transform: uppercase; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 16px; margin: 26px 0 12px; font-weight: 600; }
.subtitle { color: var(--muted2); margin: 0 0 20px; font-size: 14px; }

/* ---------- Inputs ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--ink2); }
input, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-input);
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input[type="date"], input[type="time"], input[type="datetime-local"] {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* ---------- Buttons ---------- */
button { font-family: inherit; font-weight: 600; cursor: pointer; border: none; border-radius: var(--r-btn); padding: 10px 15px; font-size: 14px; background: var(--header); color: #fff; transition: transform 0.08s, background 0.15s, opacity 0.15s; }
button:hover { background: #2a2c33; }
button:active { transform: scale(0.99); }
button:disabled { opacity: 0.5; cursor: default; }
button.ghost { background: #fff; color: var(--ink); border: 1px solid #d9dbe0; }
button.ghost:hover { background: #f5f6f8; }
button.accent { background: var(--accent); }
button.accent:hover { background: var(--accent-dark); }
button.green { background: var(--green); box-shadow: 0 6px 16px rgba(31, 157, 87, 0.28); }
button.red { background: var(--red); box-shadow: 0 6px 16px rgba(216, 72, 58, 0.28); }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 600; box-shadow: none; }
button.link:hover { background: none; text-decoration: underline; }
button.full { width: 100%; margin-top: 20px; }
button.big { width: 100%; height: 58px; border-radius: 14px; font-size: 17px; }

.msg { margin-top: 14px; font-size: 14px; min-height: 18px; }
.msg.error { color: var(--red-ink); }
.msg.success { color: var(--green-ink); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--line2); }
th { color: var(--muted3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.table-wrap { overflow-x: auto; }

/* ---------- Avatars ---------- */
.avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%;
  background: var(--avatar-bg); color: var(--avatar-ink);
  font-size: 11.5px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.name-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.name-cell .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

/* ---------- Pills / badges ---------- */
.pill, .badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill.green, .badge.on, .pill.godkjent { color: var(--green-ink); background: var(--green-bg); }
.pill.blue, .pill.kommer { color: var(--blue-ink); background: var(--blue-bg); }
.pill.yellow, .pill.venter { color: var(--yellow-ink); background: var(--yellow-bg); }
.pill.neutral, .pill.ferdig { color: var(--neutral-ink); background: var(--neutral-bg); }
.pill.red, .badge.off, .pill.avvist { color: var(--red-ink); background: var(--red-bg); }
.pill.ferie { color: var(--blue-ink); background: var(--blue-bg); }
.pill.sykdom { color: var(--red-ink); background: var(--red-bg); }
.pill.annet { color: var(--neutral-ink); background: var(--neutral-bg); }

/* ---------- Employee clock hero ---------- */
.clock-hero { border-radius: 18px; padding: 22px; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.hero-greet { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.hero-date { font-size: 13px; color: var(--muted); margin-top: 3px; }
.hero-clock { font-size: 15px; color: var(--ink2); font-weight: 500; }
.hero-center { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0 20px; }
.hero-status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 999px; }
.hero-status .dot { width: 8px; height: 8px; border-radius: 50%; }
.hero-status.in { color: var(--green-ink); background: var(--green-bg); }
.hero-status.in .dot { background: var(--live); animation: bzpulse 1.4s ease-in-out infinite; }
.hero-status.out { color: #6a6f7d; background: #f0f1f4; }
.hero-status.out .dot { background: #b6bac3; }
.hero-timer { font-size: 44px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.05; margin-top: 6px; color: #16181d; }
.hero-timer.idle { color: #c9ccd3; }
.hero-hint { font-size: 12.5px; color: var(--muted2); }

/* ---------- Employee stacked sections ---------- */
.stack { width: 100%; max-width: 472px; display: flex; flex-direction: column; gap: 15px; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line2); font-size: 14px; }
.list-item:last-child { border-bottom: none; }
.list-item .meta { color: var(--muted3); font-size: 12.5px; }

.progress { height: 9px; border-radius: 999px; background: var(--neutral-bg); overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; border-radius: 999px; background: var(--green); }

/* ---------- Admin dashboard shell ---------- */
.admin-layout { display: flex; align-items: stretch; min-height: calc(100vh - 58px); }
.sidebar { width: 224px; flex: 0 0 224px; background: #fff; border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar .side-label { font-size: 11px; font-weight: 600; color: var(--muted3); letter-spacing: 0.06em; text-transform: uppercase; padding: 6px 12px 8px; }
.sidebar button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; color: var(--muted); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; font-weight: 500; box-shadow: none;
}
.sidebar button:hover { background: #f6f5f4; }
.sidebar button .dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; flex: 0 0 6px; }
.sidebar button.active { background: #f4f0ee; color: var(--ink); font-weight: 600; }
.sidebar button.active .dot { background: var(--accent); }

.admin-main { flex: 1; min-width: 0; padding: 24px 30px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-sub { font-size: 13.5px; color: var(--muted2); margin-top: 4px; }
.page-clock { font-size: 13px; color: var(--muted2); display: flex; align-items: center; gap: 8px; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.kpi .kpi-label { font-size: 12.5px; color: var(--muted2); font-weight: 500; }
.kpi .kpi-num { font-size: 30px; font-weight: 600; margin-top: 6px; }
.kpi .kpi-sub { font-size: 12px; color: var(--muted3); margin-top: 2px; }

.panel-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.panel-card .ph { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #eff0f3; font-size: 15px; font-weight: 600; }
.live-tag { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted2); font-weight: 500; }
.live-tag .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); animation: bzpulse 1.4s ease-in-out infinite; }
.two-col { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.two-col .col-main { flex: 2 1 460px; }
.two-col .col-side { flex: 1 1 300px; }
.pc-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line2); }

/* ---------- Calendar (restyled) ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 12px 0; }
.cal-head .title { font-size: 16px; font-weight: 600; text-transform: capitalize; }
.cal-head button { background: #fff; color: var(--ink); border: 1px solid #e2e4e8; padding: 8px 14px; }
.cal-head button:hover { background: #f5f6f8; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted3); text-transform: uppercase; padding: 4px 0; }
.cal-cell { min-height: 92px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: border-color 0.15s; }
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.other { background: #fafafa; opacity: 0.55; }
.cal-cell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-daynum { font-size: 12px; font-weight: 600; color: var(--muted2); }
.cal-shift { font-size: 11px; font-family: "IBM Plex Mono", monospace; background: var(--blue-bg); color: var(--blue-ink); border-radius: 6px; padding: 2px 5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-absence { font-size: 11px; background: var(--blue-bg); color: var(--blue-ink); border-radius: 6px; padding: 2px 5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-absence.pending { background: var(--yellow-bg); color: var(--yellow-ink); border: 1px dashed #d9a441; }
.cal-cell.other .cal-shift, .cal-cell.other .cal-absence { display: none; }

/* ---------- Availability ---------- */
.avail-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line2); }
.avail-row:last-child { border-bottom: none; }
.avail-row .avail-day { flex: 1; margin: 0; font-weight: 500; display: flex; align-items: center; gap: 8px; color: var(--ink); }
.avail-row .avail-day input { width: auto; }
.avail-row input[type="time"] { width: 108px; flex: 0 0 auto; }
.avail-grid td.on { color: var(--green-ink); font-weight: 600; }
.avail-grid td.off { color: #cfd2d8; }

/* ---------- Misc ---------- */
.badge.on { color: var(--green-ink); background: var(--green-bg); }
.badge.off { color: var(--red-ink); background: var(--red-bg); }
.actions { display: flex; gap: 8px; }
.actions button { padding: 6px 10px; font-size: 13px; }
.hidden { display: none !important; }
.small { font-size: 13px; color: var(--muted2); }
.log-action { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--accent-dark); }

/* Status-big (login/fallbacks) */
.status-big { text-align: center; padding: 10px 0 24px; }
.status-big .name { font-size: 24px; font-weight: 700; }
.status-big .state { margin-top: 8px; font-size: 15px; color: var(--muted2); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(16, 18, 25, 0.42); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 24px; width: 100%; max-width: 420px; }
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal .shift-list { margin: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.modal .shift-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; }

.panel { margin-top: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); gap: 4px; }
  .sidebar .side-label { display: none; }
  .sidebar button { white-space: nowrap; }
  .admin-main { padding: 20px 16px 60px; }
}
