/* Fluent 2-design (Microsoft) – farver og værdier fra Fluent 2's design tokens */
:root {
  /* Brand (blå) */
  --brand: #0f6cbd;          /* colorBrandBackground */
  --brand-hover: #115ea3;    /* colorBrandBackgroundHover */
  --brand-pressed: #0c3b5e;  /* colorBrandBackgroundPressed */
  --brand-fg: #0f6cbd;       /* colorBrandForeground1 */
  --brand-fg2: #115ea3;
  --brand-bg2: #ebf3fc;      /* colorBrandBackground2 */
  --brand-stroke: #b4d6fa;   /* colorBrandStroke2 */
  --header: #0f548c;         /* mørkere brand til topbjælken */

  /* Neutrale */
  --canvas: #f5f5f5;         /* colorNeutralBackground3 */
  --surface: #ffffff;        /* colorNeutralBackground1 */
  --surface-2: #fafafa;      /* colorNeutralBackground2 */
  --surface-hover: #f5f5f5;
  --fg1: #242424;            /* colorNeutralForeground1 */
  --fg2: #424242;
  --fg3: #616161;
  --stroke1: #d1d1d1;        /* colorNeutralStroke1 */
  --stroke2: #e0e0e0;
  --stroke-access: #616161;  /* colorNeutralStrokeAccessible */

  --danger: #c50f1f;         /* colorPaletteRedBackground3 */
  --danger-hover: #b10e1c;
  --success-bg: #f1faf1;
  --success-fg: #0e700e;

  --r-m: 4px;                /* borderRadiusMedium */
  --r-l: 8px;                /* borderRadiusLarge */
  --shadow4: 0 0 2px rgba(0,0,0,.12), 0 2px 4px rgba(0,0,0,.14);
  --shadow8: 0 0 2px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.14);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px; line-height: 20px;
  background: var(--canvas);
  color: var(--fg1);
  -webkit-font-smoothing: antialiased;
}

/* Topbjælke + sidemenu (som i Microsoft 365) */
.appbar {
  position: sticky; top: 0; z-index: 20;
  height: 48px; padding: 0 20px;
  background: var(--header); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow4);
}
.appbar .brand { font-weight: 600; font-size: 16px; }
.appbar .who { opacity: .9; }

.layout { display: flex; align-items: flex-start; }
.sidebar {
  position: sticky; top: 48px;
  width: 232px; flex-shrink: 0;
  height: calc(100vh - 48px);
  background: var(--surface-2);
  border-right: 1px solid var(--stroke2);
  padding: 12px 8px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; height: 100%; }
.sidebar a, .sidebar .navbtn {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 40px; padding: 8px 12px;
  color: var(--fg2); background: none; border: 0; border-radius: var(--r-m);
  font: inherit; font-weight: 400; text-align: left; text-decoration: none; cursor: pointer;
}
.sidebar a:hover, .sidebar .navbtn:hover { background: #ebebeb; color: var(--fg1); }
.sidebar a.active { background: var(--brand-bg2); color: var(--brand-fg2); font-weight: 600; }
.sidebar a.active::before {   /* Fluent: blå markering ved aktivt menupunkt */
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px;
  width: 3px; border-radius: 2px; background: var(--brand);
}
.sidebar .ico { flex-shrink: 0; }
.sidebar .logout { margin-top: auto; border-top: 1px solid var(--stroke2); padding-top: 8px; }
.layout main { flex: 1; min-width: 0; }

main { max-width: 1600px; margin: 0 auto; padding: 24px 28px 48px; }
h1 { font-size: 28px; line-height: 36px; font-weight: 600; margin: 0 0 20px; }   /* Title 2 */
h2 { font-size: 16px; line-height: 22px; font-weight: 600; margin: 24px 0 8px; color: var(--fg1); }  /* Subtitle 2 */

/* Kort (Fluent Card) */
.card {
  background: var(--surface);
  border-radius: var(--r-l);
  box-shadow: var(--shadow4);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.narrow { max-width: 440px; }

/* Felter (Fluent Input / Dropdown / Textarea) */
label { display: block; margin-bottom: 16px; font-weight: 600; color: var(--fg1); }
label small { display: block; font-weight: 400; color: var(--fg3); margin-top: 4px; font-size: 12px; line-height: 16px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px;
  min-height: 32px; padding: 5px 10px;
  font: inherit; font-weight: 400; color: var(--fg1);
  background: var(--surface);
  border: 1px solid var(--stroke1);
  border-bottom-color: var(--stroke-access);
  border-radius: var(--r-m);
  transition: border-color .1s, box-shadow .1s;
}
textarea { resize: vertical; padding-top: 6px; }
input:hover, select:hover, textarea:hover { border-color: #c7c7c7; border-bottom-color: var(--fg2); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-bottom-color: var(--brand);
  box-shadow: inset 0 -1px 0 0 var(--brand);  /* Fluent: blå understregning ved fokus */
}

/* Knapper (Fluent Button) */
button, .button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 32px; padding: 5px 16px;
  font: inherit; font-weight: 600;
  border: 1px solid transparent; border-radius: var(--r-m);
  background: var(--brand); color: #fff;
  cursor: pointer; text-decoration: none;
  transition: background .1s;
}
button:hover, .button:hover { background: var(--brand-hover); }
button:active, .button:active { background: var(--brand-pressed); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--fg1); outline-offset: 2px; }
button.link { background: none; border: 0; min-height: 0; font-weight: 400; }
button.danger { background: var(--danger); }
button.danger:hover { background: var(--danger-hover); }
a.button { background: var(--surface); color: var(--fg1); border-color: var(--stroke1); }   /* Secondary */
a.button:hover { background: var(--surface-hover); border-color: #c7c7c7; }

.inline { display: inline; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 16px; }
.inline-form label, .inline-form input, .inline-form select { margin: 0; width: auto; display: inline-block; }
.inline-form label { display: flex; align-items: center; gap: 8px; }

/* Ny registrering */
.entry .row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 12px; align-items: start; }
.duration { margin-bottom: 16px; font-weight: 600; }
.duration span { display: block; }
.duration output {
  display: flex; align-items: center; margin-top: 4px;
  min-height: 32px; padding: 5px 10px;
  background: var(--brand-bg2); color: var(--brand-fg2);
  border: 1px solid var(--brand-stroke); border-radius: var(--r-m);
  font-weight: 600;
}
#ugenr { color: var(--brand-fg); font-weight: 600; }

/* Summer */
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; }
.totals .card { margin: 0; border-left: 4px solid var(--brand-stroke); }
.totals .card:first-child { border-left-color: var(--brand); }
.totals span { display: block; color: var(--fg3); font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.totals strong { display: block; font-size: 28px; line-height: 36px; font-weight: 600; margin-top: 4px; }
.totals .card:first-child strong { color: var(--brand-fg); }

/* Månedsnavigation */
.monthnav { display: flex; justify-content: space-between; align-items: center; margin: 24px 0 12px; }
.monthnav a { color: var(--brand-fg); text-decoration: none; font-weight: 600; padding: 6px 12px; border-radius: var(--r-m); }
.monthnav a:hover { background: var(--brand-bg2); }
.monthnav strong { font-size: 20px; line-height: 28px; font-weight: 600; }

/* Tabel (Fluent DataGrid) */
table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface);
  border-radius: var(--r-l); box-shadow: var(--shadow4);
  overflow: hidden; margin-bottom: 20px;
}
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--stroke2); vertical-align: middle; }
thead th { background: var(--surface); color: var(--fg2); font-weight: 600; border-bottom: 1px solid var(--stroke1); }
tbody tr:hover td { background: var(--surface-hover); }
tbody td a { color: var(--brand-fg); font-weight: 600; text-decoration: none; }
tbody td a:hover { text-decoration: underline; }
tr.weekhead td {
  background: var(--brand-bg2); color: var(--brand-fg2);
  font-weight: 600; padding: 6px 12px; border-bottom-color: var(--brand-stroke);
}
tr.weekhead span { font-weight: 400; color: var(--fg2); margin-left: 8px; }
tr.weeksum td { background: var(--surface-2); font-weight: 600; color: var(--fg1); }
tr.weekhead:hover td { background: var(--brand-bg2); }
tr.weeksum:hover td { background: var(--surface-2); }
tfoot th { background: var(--brand); color: #fff; border-bottom: 0; font-size: 16px; }
.nowrap { white-space: nowrap; }

/* Beskeder (Fluent MessageBar) */
.muted { color: var(--fg3); }
.flash, .error { padding: 8px 12px; border-radius: var(--r-m); margin-bottom: 16px; border: 1px solid; }
.flash { background: var(--success-bg); color: var(--success-fg); border-color: #9fd89f; }
.error { background: #fdf3f4; color: #b10e1c; border-color: #eeacb2; }

@media (max-width: 640px) {
  main { padding: 16px 12px 32px; }
  h1 { font-size: 24px; line-height: 32px; }
  input, select, textarea, button, .button { min-height: 40px; }   /* større touch-flader */
  .entry .row { grid-template-columns: 1fr 1fr; }
  .duration output { min-height: 40px; }
  .totals { gap: 10px; }
  .totals strong { font-size: 22px; line-height: 28px; }
  th, td { padding: 8px 8px; font-size: 13px; }
  table { display: block; overflow-x: auto; }
}

/* Login: centreret vandret og lodret */
body.login main {
  min-height: 100vh; max-width: none; padding: 24px 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
body.login h1 { text-align: center; margin-bottom: 16px; }
body.login .card { width: 100%; max-width: 380px; padding: 24px; box-shadow: var(--shadow8); }
body.login .card button { width: 100%; margin-top: 4px; }
body.login .flash, body.login .error { width: 100%; max-width: 380px; }
.login-brand { color: var(--brand-fg); font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.login-link { margin: 16px 0 0; }
.login-link a { color: var(--brand-fg); text-decoration: none; font-weight: 600; }
.login-link a:hover { text-decoration: underline; }

/* Mobil: sidemenuen bliver til en vandret menu under topbjælken */
@media (max-width: 760px) {
  .layout { display: block; }
  .sidebar {
    position: sticky; top: 48px; z-index: 15;
    width: auto; height: auto; padding: 6px;
    border-right: 0; border-bottom: 1px solid var(--stroke2);
    overflow-x: auto;
  }
  .sidebar nav { flex-direction: row; height: auto; gap: 4px; }
  .sidebar a, .sidebar .navbtn { width: auto; white-space: nowrap; min-height: 36px; padding: 6px 10px; }
  .sidebar a.active::before { left: 10px; right: 10px; top: auto; bottom: 0; width: auto; height: 3px; }
  .sidebar .logout { margin: 0 0 0 auto; border: 0; padding: 0; }
  .appbar .who { display: none; }
}
.sidebar .navbtn { justify-content: flex-start; }

/* Håndværkerliste */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.search { display: flex; gap: 8px; flex: 1; min-width: 260px; max-width: 640px; }
.search input { margin: 0; flex: 1; }
a.button.primary { background: var(--brand); color: #fff; border-color: transparent; }
a.button.primary:hover { background: var(--brand-hover); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.craftsman { margin: 0; display: flex; flex-direction: column; }
.craftsman header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.craftsman h3 { margin: 0; font-size: 16px; line-height: 22px; font-weight: 600; }
.craftsman p { margin: 4px 0; }
.craftsman a { color: var(--brand-fg); text-decoration: none; }
.craftsman a:hover { text-decoration: underline; }
.craftsman .contact { color: var(--fg2); }
.craftsman .note { color: var(--fg3); font-size: 13px; line-height: 18px; margin-top: 8px; white-space: normal; }
.craftsman footer { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--stroke2); text-align: right; }
.craftsman footer a { font-weight: 600; }
.badge { flex-shrink: 0; background: var(--brand-bg2); color: var(--brand-fg2); border: 1px solid var(--brand-stroke); border-radius: 999px; padding: 0 10px; font-size: 12px; line-height: 20px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; max-width: 720px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid .actions { display: flex; gap: 8px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* Lejligheder */
.totals.four { grid-template-columns: repeat(4, 1fr); margin-top: 0; }
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 12px; }
.pill { padding: 4px 14px; border-radius: 999px; border: 1px solid var(--stroke1); background: var(--surface); color: var(--fg2); text-decoration: none; font-weight: 600; }
.pill:hover { background: var(--surface-hover); }
.pill.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tablewrap { overflow-x: auto; border-radius: var(--r-l); box-shadow: var(--shadow4); margin-bottom: 20px; }
.tablewrap table { box-shadow: none; margin: 0; }
table.apts td, table.apts th { padding: 8px 10px; }
table.apts .num { text-align: right; }
table.apts .c { text-align: center; color: var(--brand-fg); font-weight: 700; }
table.apts td.note { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg2); }
table.apts tbody { scroll-margin-top: 60px; }
.chip { display: inline-block; padding: 0 9px; border-radius: 999px; font-size: 12px; line-height: 22px; font-weight: 500; border: 1px solid transparent; white-space: nowrap; }
.chip.round { min-width: 24px; text-align: center; padding: 0 6px; }
.chip.blue, .chip.b1, .chip.e1 { background: #ebf3fc; color: #115ea3; border-color: #cfe4fa; }
.chip.green, .chip.b2, .chip.e3 { background: #f1faf1; color: #0e700e; border-color: #c9eac9; }
.chip.yellow, .chip.b3, .chip.e5 { background: #fefbf4; color: #8a3707; border-color: #fdeacb; }
.chip.b0, .chip.e0 { background: #f9f0fd; color: #6b2d8b; border-color: #ead6f5; }
.chip.e2 { background: #fdf3f4; color: #b10e1c; border-color: #f6d1d5; }
.chip.e4 { background: #e9f8fa; color: #00666d; border-color: #c4ecf0; }
.form-grid label.check { display: flex; align-items: center; gap: 8px; margin-top: 28px; }
.form-grid label.check input { width: auto; margin: 0; min-height: 0; }
@media (max-width: 900px) { .totals.four { grid-template-columns: 1fr 1fr; } }
body.wide main { max-width: 1600px; }
.totals.four strong { font-size: 22px; line-height: 28px; white-space: nowrap; }
.wide-note { max-width: 420px !important; }
.linkcard { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; } .linkcard p { margin: 0 0 4px; }
table.apts th.c { color: var(--fg2); } thead + * .toolbar, .totals + .toolbar { margin-top: 20px; }
table.apts td.residents { min-width: 150px; }
table.apts td.residents a { font-weight: 600; }
table.plain { box-shadow: none; border-radius: 0; margin: 0; }
table.plain th, table.plain td { padding: 8px 10px; }
table.plain thead th { background: none; }
table.plain a { color: var(--brand-fg); text-decoration: none; }
tr.former td { color: var(--fg3); }
.chip:not([class*=" "]) { background: #f0f0f0; color: var(--fg2); border-color: #e0e0e0; }
a.chip { text-decoration: none; font-weight: 600; } a.chip:hover { filter: brightness(.96); }

/* Dokumenter */
.doclink { display: inline-flex; align-items: center; gap: 10px; color: var(--fg1) !important; font-weight: 600; text-decoration: none; }
.doclink:hover { color: var(--brand-fg) !important; text-decoration: underline; }
.ext { flex-shrink: 0; display: inline-block; min-width: 38px; text-align: center; padding: 1px 4px; border-radius: 4px; font-size: 10px; line-height: 16px; font-weight: 700; color: #fff; background: #616161; }
.ext-pdf { background: #c50f1f; }
.ext-doc, .ext-docx, .ext-odt { background: #185abd; }
.ext-xls, .ext-xlsx, .ext-ods, .ext-csv { background: #107c41; }
.ext-ppt, .ext-pptx { background: #c43e1c; }
.ext-jpg, .ext-jpeg, .ext-png, .ext-gif, .ext-webp, .ext-heic { background: #8764b8; }
label.checkrow { display: flex; align-items: center; gap: 10px; font-weight: 400; margin-bottom: 10px; cursor: pointer; }
label.checkrow input[type=checkbox] { display: inline-block; width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; flex: none; accent-color: var(--brand); }

/* Stamdata */
.stamdata { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: stretch; max-width: 1200px; }
.stamdata .card { margin: 0; }
.stamdata h3 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
.stamdata dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); column-gap: 16px; row-gap: 8px; margin: 0; align-items: baseline; }
.stamdata dt { color: var(--fg3); white-space: nowrap; }
.stamdata dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.stamdata dd a { color: var(--brand-fg); text-decoration: none; }
@media (max-width: 1100px) { .stamdata { grid-template-columns: 1fr; max-width: 560px; } }
.stamdata .mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; user-select: all; }
.search input[type=search] { max-width: 560px; }
@media (max-width: 560px) {
  .stamdata dl { grid-template-columns: 1fr; row-gap: 2px; }
  .stamdata dt { font-size: 12px; margin-top: 8px; }
  .stamdata dt:first-child { margin-top: 0; }
  .stamdata dd { overflow-wrap: normal; }
}
[hidden] { display: none !important; }
table.apts td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 120px; }
table.garages td.wrap a { white-space: nowrap; }
table.garages th:nth-child(5), table.garages td:nth-child(5) { width: 40%; }
table.apts td.smalltext { font-size: 13px; line-height: 18px; color: var(--fg2); }
table.aptlist td, table.aptlist th { padding: 8px 7px; }
table.aptlist td.wrap { min-width: 110px; }
.craftsman header h3 { min-width: 0; overflow-wrap: anywhere; }
.craftsman .badge { max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Skift mellem kort- og listevisning */
[data-views][data-current="kort"] .view-liste,
[data-views][data-current="liste"] .view-kort { display: none; }
.viewtoggle { display: inline-flex; border: 1px solid var(--stroke1); border-radius: var(--r-m); overflow: hidden; background: var(--surface); }
.viewtoggle button { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 12px; background: var(--surface); color: var(--fg2); border: 0; border-radius: 0; font-weight: 600; }
.viewtoggle button + button { border-left: 1px solid var(--stroke1); }
.viewtoggle button:hover { background: var(--surface-hover); }
.viewtoggle button[aria-pressed="true"] { background: var(--brand-bg2); color: var(--brand-fg2); }
input[type=email] { text-transform: lowercase; }
