:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --border: #e2e5ea;
  --primary: #2457d6;
  --primary-hover: #1c46ad;
  --danger: #c62828;
  --ok: #1e7d43;
  --warn: #a15c00;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
a { color: var(--primary); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); margin: .5rem 0 0; min-height: 0; }
.error:empty { display: none; }
.warn { color: var(--warn); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Formularer og knapper ---------- */

label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .85rem;
  font-weight: 600;
  color: #374151;
}

input, select {
  font: inherit;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }

button, .btn {
  font: inherit;
  font-weight: 600;
  padding: .55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: #f0f2f5; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-hover); }
button.danger { color: var(--danger); }
button.small { padding: .3rem .65rem; font-size: .85rem; }
button.link {
  background: none; border: none; padding: 0; font-weight: 500;
  color: var(--primary); cursor: pointer;
}
button.link:hover { text-decoration: underline; background: none; }
button.link.danger { color: var(--danger); }

/* ---------- Login ---------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 1rem; }
.login-card h1 { text-align: center; }
.login-card p { margin: 0; }

/* ---------- Layout ---------- */

.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .75rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 1.1rem; }
.tabs { display: flex; gap: .25rem; }
.tabs button, .subtabs button { border: none; background: none; color: var(--muted); }
.tabs button.active, .subtabs button.active { background: #e8eefc; color: var(--primary); }
.user { margin-left: auto; display: flex; gap: 1rem; align-items: center; font-size: .9rem; }

.container { max-width: 1050px; margin: 0 auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.subtabs { display: flex; gap: .25rem; }
.month-pick { flex-direction: row; align-items: center; gap: .5rem; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
#admin-body { display: flex; flex-direction: column; gap: 1.25rem; }
#admin-body .toolbar { margin-bottom: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex; flex-direction: column;
}
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat.highlight { background: var(--primary); border-color: var(--primary); color: #fff; }
.stat.highlight span { color: #dbe5ff; }

.row-form { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.row-form .grow { flex: 1 1 200px; }

/* ---------- Tabeller ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; border-bottom: none; }
table.clickable tbody tr[data-user] { cursor: pointer; }
table.clickable tbody tr[data-user]:hover, table.clickable tr.open { background: #f3f6fd; }
tr.detail > td { background: #fafbfc; padding: .5rem 1rem 1rem; }

input.inline, select.inline { padding: .35rem .5rem; width: 100%; }
select.inline { min-width: 140px; }
input.wage { max-width: 110px; text-align: right; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: #e3f4ea; color: var(--ok); }
.badge.wait { background: #fff3e0; color: var(--warn); }

/* ---------- Dialog og toast ---------- */

dialog { border: none; border-radius: var(--radius); padding: 1.5rem; width: min(400px, 92vw); box-shadow: 0 20px 50px rgba(0,0,0,.2); }
dialog.wide { width: min(560px, 94vw); }
dialog p { margin: 0; }
code { font-family: ui-monospace, Consolas, monospace; background: #f0f2f5; padding: .1rem .35rem; border-radius: 4px; }
code.big { font-size: 1.25rem; letter-spacing: .08em; padding: .2rem .5rem; }
dl.invite { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; margin: 0; align-items: center; }
dl.invite dt { color: var(--muted); font-size: .9rem; }
dl.invite dd { margin: 0; font-weight: 600; word-break: break-all; }
dialog h3 { margin: .5rem 0 0; font-size: 1rem; }
label.check { flex-direction: row; align-items: flex-start; gap: .5rem; font-weight: 400; }
label.check input { margin-top: .2rem; }
dialog::backdrop { background: rgba(15, 20, 30, .4); }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.stack h2 { margin: 0; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem);
  background: #1d2330; color: #fff; padding: .7rem 1.1rem; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); }

@media (max-width: 640px) {
  .topbar { padding: .75rem 1rem; gap: .75rem; }
  .user { margin-left: 0; width: 100%; }
  .container { padding: 1rem; }
  .row-form > * { flex: 1 1 100%; }
}
