:root {
  --navy: #1a3c5e;
  --navy-light: #eef3f8;
  --border: #dbe2e8;
  --text: #1a1a1a;
  --muted: #667;
  --danger: #b3261e;
  --ok: #1e7d32;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f5f7f9;
  color: var(--text);
  font-family: inherit;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
}
.topbar .brand { color: white; font-weight: 700; font-size: 1.1rem; display: inline-flex; align-items: center; gap: 10px; }
.brand-logo {
  display: inline-flex;
  align-items: center;
  background: white;
  border-radius: 6px;
  padding: 4px 8px;
  line-height: 0;
}
.brand-logo img { height: 22px; width: auto; display: block; }
.brand-text { white-space: nowrap; }
.topbar nav { display: flex; align-items: center; }
.topbar nav a { color: #dce8f5; }
.topbar nav a:hover { color: white; }

.nav-group { position: relative; margin-left: 6px; }
.nav-toggle {
  background: none;
  border: none;
  color: #dce8f5;
  font-size: 0.95rem;
  font-family: inherit;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 4px;
}
.nav-toggle::after { content: " \25BE"; font-size: 0.7em; }
.nav-toggle:hover, .nav-toggle.open { color: white; background: rgba(255,255,255,0.1); }
.nav-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 190px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  padding: 6px 0;
  z-index: 30;
}
.nav-menu.open { display: block; }
.topbar .nav-menu a {
  display: block;
  padding: 8px 14px;
  color: var(--text);
  font-size: 0.9rem;
}
.topbar .nav-menu a:hover { background: var(--navy-light); text-decoration: none; }

.user-menu-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 20px;
  padding: 4px 8px;
  border-radius: 20px;
  color: #dce8f5;
}
.user-menu-link:hover { background: rgba(255,255,255,0.1); color: white; text-decoration: none; }
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255,255,255,0.15);
}
.user-avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
}

.avatar-lg {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--navy-light);
  border: 1px solid var(--border);
}
.avatar-lg-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--navy);
}

.equipment-photo {
  width: 110px;
  height: 110px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--navy-light);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.equipment-photo-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.8rem;
  color: var(--navy);
  padding: 4px;
}

.photo-library-panel {
  margin-top: 10px;
  padding: 14px;
  border: 1px dashed #b9c6d3;
  border-radius: 8px;
  background: #fbfdff;
  display: none;
}
.photo-library-panel.show { display: block; }

.photo-library-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.photo-library-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
}

.photo-library-thumb:hover { border-color: var(--navy); }

.photo-library-thumb.selected {
  border-color: var(--ok);
  box-shadow: 0 0 0 2px var(--ok) inset;
}

.page {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 20px 60px;
}

.flash-stack { margin-bottom: 16px; }
.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.92rem;
}
.flash-success { background: #e6f4ea; color: var(--ok); border: 1px solid #b7dfc0; }
.flash-error { background: #fbeaea; color: var(--danger); border: 1px solid #eec3c0; }
.flash-info { background: var(--navy-light); color: var(--navy); border: 1px solid #c3d4e3; }

h1 { font-size: 1.5rem; margin: 0 0 6px 0; }
h2 { font-size: 1.1rem; color: var(--navy); }
.subtitle { color: var(--muted); margin-bottom: 20px; }

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar input, .toolbar select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.92rem;
}

table.list {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
table.list th, table.list td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
table.list th {
  background: var(--navy-light);
  color: var(--navy);
  font-weight: 600;
}
table.list tr:hover td { background: #fafcfe; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--navy-light);
  color: var(--navy);
  border: 1px solid #c3d4e3;
}
.badge.done { background: #e6f4ea; color: var(--ok); border-color: #b7dfc0; }
.badge.progress { background: #fff4e0; color: #9a6a00; border-color: #f0dba8; }

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 6px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: white;
  font-size: 0.92rem;
  cursor: pointer;
}
.btn:hover { background: #14304c; text-decoration: none; }
.btn.secondary {
  background: white;
  color: var(--navy);
}
.btn.secondary:hover { background: var(--navy-light); }

form .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
form .grid.full { grid-template-columns: 1fr; }
label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}
input[type=text], input[type=number], input[type=tel], input[type=date],
input[type=email], input[type=password],
textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.92rem;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 16px; }

.section-title {
  margin-top: 26px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  color: var(--navy);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Fljótandi (fluid) viðskiptavina-flettilisti */
.combo { position: relative; }
.combo-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  max-height: 260px;
  overflow-y: auto;
  display: none;
}
.combo-results.open { display: block; }
.combo-result {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}
.combo-result:hover, .combo-result.active { background: var(--navy-light); }
.combo-result .kt { color: var(--muted); font-size: 0.8rem; }
.combo-result.new-option { color: var(--navy); font-weight: 600; border-top: 1px solid var(--border); }
.combo-result.no-match { color: var(--muted); font-style: italic; cursor: default; }
.combo-result.no-match:hover { background: none; }

.selected-customer {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--navy-light);
  border: 1px solid #c3d4e3;
  border-radius: 6px;
  font-size: 0.85rem;
  display: none;
}
.selected-customer.show { display: block; }

.new-customer-panel {
  margin-top: 10px;
  padding: 14px;
  border: 1px dashed #b9c6d3;
  border-radius: 8px;
  background: #fbfdff;
  display: none;
}
.new-customer-panel.show { display: block; }
.new-customer-panel .grid { grid-template-columns: 1fr 1fr; }

.new-equipment-panel {
  margin-top: 10px;
  padding: 14px;
  border: 1px dashed #b9c6d3;
  border-radius: 8px;
  background: #fbfdff;
  display: none;
}
.new-equipment-panel.show { display: block; }
.new-equipment-panel .grid { grid-template-columns: 1fr 1fr; }

.new-department-panel {
  margin-top: 10px;
  padding: 14px;
  border: 1px dashed #b9c6d3;
  border-radius: 8px;
  background: #fbfdff;
  display: none;
  max-width: 320px;
}
.new-department-panel.show { display: block; }

.field.disabled { opacity: 0.5; pointer-events: none; }

.actions-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.muted { color: var(--muted); font-size: 0.85rem; }

.pdf-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--navy);
  border-radius: 6px;
  color: var(--navy);
  font-weight: 600;
}
.pdf-link:hover { background: var(--navy-light); text-decoration: none; }

.audit-list { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; }
.audit-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.audit-list .when { color: var(--muted); }

table.fields { width: 100%; border-collapse: collapse; }
table.fields td { padding: 5px 0; vertical-align: top; }
table.fields td.label { width: 180px; color: var(--muted); font-weight: 600; }

table.items-table {
  width: 100%;
  border-collapse: collapse;
}
table.items-table th, table.items-table td {
  padding: 6px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.items-table th {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}
table.items-table td input {
  margin-bottom: 0;
}
table.items-table td:nth-child(3) input,
table.items-table td:nth-child(4) input,
table.items-table td:nth-child(5) input {
  text-align: right;
}
table.items-table tfoot td {
  border-bottom: none;
  border-top: 2px solid var(--border);
  font-weight: 600;
}

/* Breytingaskrá: smellanlegar færslur með Áður / Eftir */
.audit-entry summary { cursor: pointer; list-style: revert; }
.audit-entry summary:hover { color: var(--navy); }
.audit-entry[open] summary { font-weight: 600; }
.audit-diff { width: 100%; border-collapse: collapse; margin: 10px 0 6px; font-size: 0.85rem; table-layout: fixed; }
.audit-diff th, .audit-diff td { text-align: left; vertical-align: top; padding: 6px 8px; border: 1px solid var(--border); }
.audit-diff th { background: var(--navy-light); font-weight: 600; }
.audit-diff th:first-child, .audit-diff td.field { width: 150px; }
.audit-diff td.old, .audit-diff td.new { white-space: pre-wrap; overflow-wrap: anywhere; }
.audit-diff td.old { background: #fdf3f2; }
.audit-diff td.new { background: #f1f8f2; }
.diff-del { color: var(--danger); text-decoration: line-through; background: #f9d9d6; }
.diff-ins { color: var(--ok); background: #cfe9d2; }
.audit-pdf { display: inline-block; margin-top: 4px; }
@media (max-width: 640px) {
  .audit-diff th:first-child, .audit-diff td.field { width: 90px; }
}

/* Yfirlit: reikningsdálkur lengst til hægri */
table.list th.invoice-col, table.list td.invoice-col { text-align: center; width: 90px; }
.invoice-mark { display: inline-flex; align-items: center; justify-content: center;
                width: 38px; height: 38px; border-radius: 8px; font-size: 1.6rem; font-weight: 800; line-height: 1; }
.invoice-mark.done { background: var(--ok); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.invoice-mark.missing { background: #fff4e0; color: #9a6a00; border: 2px dashed #e0b44a; font-size: 1.2rem; }
.invoice-no { display: block; margin-top: 3px; font-size: 0.75rem; color: var(--muted); white-space: nowrap; }

/* Tækjaeyðublað: valin mynd og viðvörun um tvískráð raðnúmer */
.photo-chosen { margin: 8px 0 0; color: var(--ok); font-weight: 600; font-size: 0.9rem; }
.field-warning { margin: 6px 0 0; color: var(--danger); font-size: 0.88rem; font-weight: 600; }
.field-warning a { color: var(--danger); text-decoration: underline; }

/* Uppástungur úr vörulista á efnislínum verkbeiðnar */
.items-table td { position: relative; }
.combo-results.item-suggest { min-width: 460px; right: auto; }

/* Valmynd í síma: ☰ hnappur, flokkar opnast sem listi undir hver öðrum */
.nav-burger { display: none; }
.nav-mobile-link { display: none; }
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; }
  .brand-text { display: none; }
  .nav-burger {
    display: inline-block;
    background: none;
    border: 1px solid rgba(255,255,255,0.35);
    color: white;
    font-size: 1.3rem;
    line-height: 1;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
  }
  .topbar nav { display: none; width: 100%; flex-direction: column; align-items: stretch; margin-top: 10px; }
  .topbar nav.open { display: flex; }
  .nav-group { margin-left: 0; }
  .nav-toggle { width: 100%; text-align: left; padding: 12px 10px; font-size: 1rem; }
  .nav-menu { position: static; min-width: 0; box-shadow: none; border: none; border-radius: 0; background: rgba(255,255,255,0.06); padding: 0; }
  .topbar .nav-menu a { color: #dce8f5; padding: 11px 26px; font-size: 0.98rem; }
  .topbar .nav-menu a:hover { background: rgba(255,255,255,0.1); }
  .nav-mobile-link { display: block; padding: 12px 10px; font-weight: 600; }
  .user-menu-link { margin-left: 0; padding: 10px; border-radius: 6px; }
  .topbar nav form { padding: 6px 10px 4px; }
  .page { margin-top: 14px; padding: 0 12px 40px; }
  table.list { display: block; overflow-x: auto; white-space: nowrap; }
  .card { padding: 14px; }
}
