:root {
    --bg: #f5f6f8;
    --card: #fff;
    --line: #dfe2e7;
    --text: #1f2933;
    --muted: #6b7280;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --red: #b42318;
    --green: #1a7f37;
}

* { box-sizing: border-box; }

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

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

.brand { font-weight: 600; color: var(--text); text-decoration: none; }

.workspace-switch {
    flex: 1;
    min-width: 0;
    max-width: 260px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--card);
    font: inherit;
}

.usermenu { position: relative; margin-left: auto; }
.usermenu summary { cursor: pointer; color: var(--muted); font-size: 14px; list-style: none; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu-panel {
    position: absolute;
    right: 0;
    top: 28px;
    z-index: 10;
    min-width: 180px;
    padding: 6px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
}
.usermenu-panel a, .linklike {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    background: none;
    font: inherit;
    text-align: left;
    color: var(--text);
    text-decoration: none;
    border-radius: 4px;
    cursor: pointer;
}
.usermenu-panel a:hover, .linklike:hover { background: var(--bg); }

.subnav { display: flex; gap: 4px; padding: 6px 16px; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; }
.subnav a { padding: 6px 10px; border-radius: 4px; color: var(--text); text-decoration: none; white-space: nowrap; }
.subnav a:hover { background: var(--bg); }

.content { padding: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 20px; }
.card.narrow { max-width: 420px; margin: 24px auto; }
h1 { font-size: 1.3rem; margin: 0 0 16px; }

label { display: block; margin: 14px 0 4px; font-size: 14px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
input:not([type=checkbox]) {
    width: 100%;
    height: 42px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
}
input:focus, select:focus { outline: 2px solid #bfd3fb; border-color: var(--blue); }

button.primary {
    width: 100%;
    height: 42px;
    margin-top: 18px;
    border: 0;
    border-radius: 6px;
    background: var(--blue);
    color: #fff;
    font: inherit;
    cursor: pointer;
}
button.primary:hover { background: var(--blue-dark); }

.error { color: var(--red); font-size: 14px; }
.ok { color: var(--green); }

.embed { width: 100%; height: calc(100vh - 140px); min-height: 400px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.meta { color: var(--muted); font-size: 14px; margin: 0 0 8px; }

/* Mail-workspace */
.mail-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.mail-head .meta { margin: 4px 0 0; }
button.secondary { height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font: inherit; cursor: pointer; white-space: nowrap; }
button.secondary:hover { background: var(--bg); }
.maillist { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.mailrow { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.mailrow-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mailrow-date { margin-left: auto; }
.mailrow-subject { margin: 6px 0 2px; font-weight: 600; overflow-wrap: anywhere; }
.mailrow .meta { margin: 0; overflow-wrap: anywhere; }
.mailrow-bottom { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 8px; }
.correct select { height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font: inherit; font-size: 14px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; background: #eef0f3; color: var(--text); }
.badge-invoice { background: #e6efff; color: #1d4ed8; }
.badge-order { background: #e4f4ea; color: #1a7f37; }
.badge-delete { background: #f1f1f1; color: #6b7280; }
.badge-unsure { background: #fdf2dc; color: #8a5a00; }

/* Mail: regler og opfølgning */
.card.narrow.wide { max-width: 560px; }
select { width: 100%; height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font: inherit; }
.correct select { width: auto; }
.button-link { display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); text-decoration: none; white-space: nowrap; }
.button-link:hover { background: var(--bg); }
.button-link.small, button.secondary.small { padding: 5px 10px; height: auto; font-size: 14px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.actions form { margin: 0; }
.tabs { display: flex; gap: 6px; margin: 16px 0 0; }
.tabs a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); text-decoration: none; font-size: 14px; }
.tabs a.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.note { font-size: 13px; padding: 2px 8px; border-radius: 6px; background: #fdf2dc; color: #8a5a00; font-weight: 600; }
.mailrow.inactive { opacity: .6; }
.hint { margin: 16px 0 0; }
.cancel { display: block; margin-top: 12px; text-align: center; color: var(--muted); }

/* Lær systemet */
.badge-keep { background: #e8f0f0; color: #2f5f5f; }
.choice { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); cursor: pointer; }
.choice input[type=radio] { margin-top: 4px; }
.choice .meta { margin: 2px 0 0; }
.learn-mail { overflow-wrap: anywhere; }
