* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; margin: 0; background: #f5f5f4; color: #1c1917; }
main { max-width: 1400px; margin: 1.5rem auto; padding: 0 1rem 3rem; }
.card { background: #fff; border: 1px solid #e7e5e4; border-radius: 8px; padding: 1.25rem; margin-bottom: 1.25rem; }
h1 { font-size: 1.4rem; margin-top: 0; }
h2 { font-size: 1.05rem; margin-top: 0; text-transform: uppercase; letter-spacing: 0.03em; color: #44403c; }
h3 { font-size: 0.85rem; margin: 0 0 0.35rem; text-transform: uppercase; letter-spacing: 0.03em; color: #78716c; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 0.35rem 0.4rem; border-bottom: 1px solid #e7e5e4; white-space: nowrap; }
/* Varegruppe-overskrift i varebanken, se renderVarebankPage(). */
tr.group-row td { background: #f5f5f4; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; font-size: 0.78rem; color: #57534e; white-space: normal; }
input, select, textarea, button { font: inherit; padding: 0.35rem 0.5rem; border: 1px solid #d6d3d1; border-radius: 4px; }
textarea { white-space: pre-wrap; }
button { background: #1c1917; color: #fff; border-color: #1c1917; cursor: pointer; }
button.secondary { background: #fff; color: #1c1917; }
button.accent { background: #7a1f2e; border-color: #7a1f2e; }
button.danger { background: #b91c1c; border-color: #b91c1c; }
button.confirming { background: #b91c1c; border-color: #b91c1c; }
button.small { padding: 0.15rem 0.45rem; font-size: 0.8rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
/* "Sign in with Microsoft" per Microsoft's branding guidelines (light theme redlines):
   41px tall, 1px #8C8C8C border, square corners, 12px padding/gap, 21px logo,
   Segoe UI Semibold 15px in #5E5E5E. Logo colors and proportions must not be altered. */
button.ms-signin { display: inline-flex; align-items: center; gap: 12px; height: 41px; min-width: 215px; padding: 0 12px; box-sizing: border-box; background: #fff; color: #5e5e5e; border: 1px solid #8c8c8c; border-radius: 0; font-family: "Segoe UI", system-ui, sans-serif; font-size: 15px; font-weight: 600; line-height: 1; white-space: nowrap; }
button.ms-signin:hover { background: #f3f3f3; }
button.ms-signin svg { flex: none; display: block; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: end; }
.row > div { display: flex; flex-direction: column; gap: 0.2rem; }
label { font-size: 0.75rem; color: #57534e; }
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.75rem; vertical-align: middle; }
.badge.draft { background: #e0e7ff; color: #3730a3; }
.badge.sent { background: #fef3c7; color: #92400e; }
.badge.accepted { background: #dcfce7; color: #166534; }
.badge.lost { background: #fee2e2; color: #991b1b; }
.uncertain { color: #b45309; font-weight: 600; }
.error { color: #b91c1c; margin: 0.5rem 0; }
.muted { color: #78716c; font-size: 0.85rem; }
a.link { color: #1c1917; cursor: pointer; text-decoration: underline; }
/* Tilbudsoversikten - kolonneoverskrift med sorteringsmeny + filterrad med input/trakt-ikon, se showQuoteList(). */
table.quote-list thead tr:first-child th { background: #f5f5f4; }
table.quote-list th .th-head { display: flex; align-items: center; justify-content: space-between; gap: 0.3rem; }
table.quote-list th .col-menu { background: none; border: none; padding: 0 0.15rem; color: #a8a29e; cursor: pointer; font-weight: 700; font-size: 0.95rem; line-height: 1; border-radius: 3px; }
table.quote-list th .col-menu:hover, table.quote-list th .col-menu.active { color: #1c1917; }
table.quote-list tr.filter-row th, table.varebank-list tr.filter-row th { padding-top: 0.3rem; padding-bottom: 0.5rem; }
table.quote-list tr.filter-row .filter-cell, table.varebank-list tr.filter-row .filter-cell { display: flex; align-items: stretch; gap: 0.25rem; }
table.quote-list tr.filter-row input, table.quote-list tr.filter-row select,
table.varebank-list tr.filter-row input, table.varebank-list tr.filter-row select { width: 100%; box-sizing: border-box; min-width: 0; }
table.quote-list tr.filter-row .filter-icon, table.varebank-list tr.filter-row .filter-icon { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; padding: 0; background: #fff; color: #a8a29e; border: 1px solid #d6d3d1; }
table.quote-list tr.filter-row .filter-icon:hover, table.varebank-list tr.filter-row .filter-icon:hover { color: #57534e; }
table.quote-list tr.filter-row .filter-icon.active, table.varebank-list tr.filter-row .filter-icon.active { color: #7a1f2e; border-color: #7a1f2e; }
/* Tilbudsoversikten og varebanken: trakten ligger inne i tekstfilterfeltet, helt til venstre (klikk nullstiller fortsatt filteret).
   Knappen står etter feltet i DOM-en (clearQuoteFilter()/clearVarebankFilter() bruker previousElementSibling), så den legges oppå med posisjonering.
   Nedtrekksfiltre (select) har ingen trakt. */
table.quote-list tr.filter-row .filter-cell, table.varebank-list tr.filter-row .filter-cell { position: relative; }
table.quote-list tr.filter-row input, table.varebank-list tr.filter-row input { padding-left: 1.9rem; }
table.quote-list tr.filter-row .filter-icon, table.varebank-list tr.filter-row .filter-icon { position: absolute; left: 1px; top: 1px; bottom: 1px; width: 1.7rem; background: transparent; border: none; border-radius: 3px 0 0 3px; }

.topbar { position: sticky; top: 0; z-index: 10; background: #fff; border-bottom: 1px solid #e7e5e4; padding: 0.6rem 1.25rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.topbar .brand { display: flex; align-items: center; gap: 0.6rem; }
.topbar .brand .logo { height: 32px; width: auto; flex-shrink: 0; }
.topbar .brand span.sub { color: #78716c; font-size: 0.8rem; margin-left: 0.4rem; }
#topbar-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.tabbox { background: #fff; border: 1px solid #e7e5e4; border-radius: 8px; margin-bottom: 1.25rem; }
.tabbar { display: flex; gap: 0.25rem; padding: 0 0.75rem; border-bottom: 1px solid #e7e5e4; flex-wrap: wrap; }
button.tab { background: none; color: #57534e; border: none; border-bottom: 3px solid transparent; border-radius: 0; padding: 0.7rem 1.1rem; font-weight: 600; }
button.tab:hover { color: #1c1917; }
button.tab.active { color: #7a1f2e; border-bottom-color: #7a1f2e; }
.tabpanes { padding: 1.25rem; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.tabpanes .card { border: none; padding: 0; margin-bottom: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.6rem; }
.stat { background: #fafaf9; border-radius: 6px; padding: 0.5rem 0.7rem; }
.stat label { display: block; font-size: 0.72rem; color: #78716c; }
.stat strong { display: block; font-size: 1.05rem; }
.stat.hi-green { background: #dcfce7; }
.stat.hi-red { background: #fee2e2; }

.warnings { margin-top: 0.75rem; background: #fef3c7; border: 1px solid #fde68a; border-radius: 6px; padding: 0.6rem 0.9rem; font-size: 0.85rem; }
.warnings ul { margin: 0.35rem 0 0; padding-left: 1.1rem; }

.dropzone { border: 2px dashed #d6d3d1; border-radius: 6px; padding: 1.5rem; text-align: center; color: #78716c; cursor: pointer; }
.dropzone.drag { border-color: #7a1f2e; color: #7a1f2e; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.6rem; margin-top: 0.6rem; }
.image-thumb { border: 1px solid #e7e5e4; border-radius: 6px; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.image-thumb img { width: 100%; height: 100px; object-fit: cover; border-radius: 4px; background: #f5f5f4; }
.image-thumb img:not([src]) { font-size: 0; color: transparent; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: flex-start; justify-content: center; padding: 3rem 1rem; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 8px; padding: 1.5rem; max-width: 950px; width: 100%; }
.picker-row { padding: 0.3rem 0; border-bottom: 1px solid #f0efed; }

.line-search { position: relative; }
.line-search-results { position: absolute; top: 100%; left: 0; margin-top: 0.2rem; background: #fff; border: 1px solid #d6d3d1; border-radius: 4px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); max-height: 16rem; overflow-y: auto; min-width: 20rem; z-index: 20; padding: 0 0.5rem; }
.line-search-results .picker-row:last-child { border-bottom: none; }

.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%) translateY(150%); background: #1c1917; color: #fff; padding: 0.6rem 1rem; border-radius: 6px; transition: transform 0.2s, opacity 0.2s; opacity: 0; pointer-events: none; z-index: 100; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error-toast { background: #b91c1c; }
