:root {
  /* NMG identity: RAL 1007 (daffodil yellow) as primary + the logo's dark red as accent */
  --brand: #e58100; --brand-2: #c26d00; --accent: #a71222; --accent-dark: #c26d00;
  --bg: #f7f4ef; --card: #fff; --line: #e6ddd0; --text: #241d15; --muted: #77694f;
  --ok: #1f8f4e; --warn: #c9791b; --bad: #b83232; --eco: #2b5f9e;
  --radius: 8px; --shadow: 0 1px 3px rgba(0,0,0,.08);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 6px 12px; }
button.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button.primary:hover { background: var(--brand-2); }
button.danger { color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
button.mini { padding: 1px 6px; font-size: 11px; }
input, select, textarea { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; width: 100%; }
input:read-only, textarea:read-only, select:disabled { background: #f0f2f4; color: #444; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* layout */
header.top { background: var(--brand); color: #fff; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 52px; }
header.top .logo { font-weight: 700; letter-spacing: .3px; font-size: 17px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
header.top .logo img { height: 40px; display: block; }
header.top .logo .expand { font-weight: 400; font-size: 13px; color: #fff3e2; letter-spacing: .2px; }
header.top .logo .expand b { font-weight: 700; color: #fff; }
header.top .ver { font-size: 10px; color: #ffdcae; align-self: flex-end; padding-bottom: 7px; }
header.top nav a { color: #ffe6c4; text-decoration: none; padding: 16px 10px; display: inline-block; border-bottom: 3px solid transparent; border-radius: 6px 6px 0 0; transition: background .15s, color .15s; }
header.top nav a:hover { color: #fff; background: rgba(255,255,255,.16); border-bottom-color: rgba(255,255,255,.5); }
header.top nav a.active { color: #fff; border-bottom-color: var(--accent); }
header.top .spacer { flex: 1; }
header.top .user { font-size: 13px; color: #ffe6c4; }
header.top .user b { color: #fff; }
header.top .user a { transition: background .15s; border-radius: 5px; padding: 3px 5px; color: #ffe6c4; }
header.top .user a:hover { background: rgba(255,255,255,.18); text-decoration: none; color: #fff; }
main { padding: 18px 20px; max-width: 1700px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 0 0 auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 14px; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 15px; margin: 18px 0 8px; color: var(--brand); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
h2.eco { color: var(--eco); } h2.ejerskab { color: var(--accent-dark); } h2.status { color: var(--ok); }
h2.placering { color: var(--accent); }

/* login */
.login { max-width: 380px; margin: 80px auto; }
.login h1 { text-align: center; }
.login .field { margin-bottom: 12px; }
.login .logo-big { display: block; margin: 0 auto 10px; height: 64px; }
.error { color: var(--bad); font-size: 13px; margin: 6px 0; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; cursor: pointer; }
.tile.active { outline: 2px solid var(--brand); }
.tile .n { font-size: 24px; font-weight: 700; }
.tile .l { font-size: 12px; color: var(--muted); }

/* table */
.tablewrap { overflow-x: auto; }
#tbl.tablewrap { overflow: auto; max-height: calc(100vh - 205px); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f7f9fb; position: sticky; top: 0; z-index: 3; font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none; box-shadow: 0 1px 0 var(--line); }
th.sorted::after { content: " ▲"; font-size: 10px; } th.sorted.desc::after { content: " ▼"; }
th.g-Stamdata { border-top: 3px solid var(--brand-2); }
th.g-Placering { border-top: 3px solid var(--accent); }
th.g-Ejerskab { border-top: 3px solid var(--accent-dark); }
th.g-Økonomi { border-top: 3px solid var(--eco); }
th.g-Status { border-top: 3px solid var(--ok); }
tbody tr:hover { background: #f1f6fa; cursor: pointer; }
td.num, th.num { text-align: right; }
td.neg { color: var(--bad); font-weight: 600; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.chip.ok { background: #e2f3e8; color: var(--ok); } .chip.warn { background: #fbeedd; color: var(--warn); }
.chip.bad { background: #fbe3e3; color: var(--bad); } .chip.info { background: #e3edf7; color: var(--eco); }
.chip.grey { background: #eceff2; color: var(--muted); }

/* drawer */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(860px, 96vw); background: var(--card); z-index: 21; box-shadow: -4px 0 20px rgba(0,0,0,.2); display: flex; flex-direction: column; }
.drawer .head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.drawer .head h1 { margin: 0; font-size: 17px; flex: 1; }
.drawer .body { padding: 6px 18px 18px; overflow-y: auto; flex: 1; }
.drawer .foot { padding: 10px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; }
.tabs button.active { border-bottom-color: var(--brand); font-weight: 600; }
.history td { font-size: 12px; }

/* permissions matrix */
.perm td select { width: auto; }
.perm .ov { background: #fff8e1; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: #eceff2; }
.pw { font-family: ui-monospace, Menlo, monospace; background: #fff8e1; padding: 8px 10px; border: 1px dashed var(--accent); border-radius: 6px; display: inline-block; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 50; }
#toast div { background: #1d2430; color: #fff; padding: 10px 16px; border-radius: 6px; margin-top: 6px; box-shadow: var(--shadow); }
#toast div.bad { background: var(--bad); }
.tablewrap::-webkit-scrollbar { height: 14px; width: 14px; }
.tablewrap::-webkit-scrollbar-thumb { background: #b8c4d0; border-radius: 6px; }
@media (max-width: 700px) { main { padding: 10px; } header.top { padding: 0 10px; gap: 8px; } }
