:root {
  --green: #53AC45;
  --green-dark: #3F8D3C;
  --text: #182018;
  --muted: #59635b;
  --line: #dfe7dc;
  --bg: #f6f8f5;
  --card: #ffffff;
  --soft: #eef6ee;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(83, 172, 69, .10), transparent 30%),
    var(--bg);
  color: var(--text);
}

.page {
  min-height: 100vh;
  padding: 48px 20px;
  display: grid;
  place-items: center;
}

.card,
.portal {
  width: min(1120px, 100%);
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,.07);
}

.login-card {
  max-width: 520px;
  padding: 42px;
}

.brand {
  color: var(--green);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 13px;
}

h1 {
  margin: 12px 0;
  font-size: clamp(34px, 5vw, 56px);
  line-height: .98;
  letter-spacing: -.04em;
}

.lead {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
  margin: 0 0 26px;
}

.form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 650;
  font-size: 14px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 15px;
  color: var(--text);
  background: white;
}

input:focus {
  outline: 3px solid rgba(83,172,69,.18);
  border-color: var(--green);
}

button {
  border: 0;
  border-radius: 12px;
  padding: 13px 18px;
  background: var(--green);
  color: white;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
}

button:hover {
  background: var(--green-dark);
}

button.secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--line);
}

button.secondary:hover {
  background: var(--soft);
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 18px;
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 14px;
}

.portal {
  padding: 34px;
}

.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 26px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.toolbar input {
  max-width: 520px;
}

#countText {
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}

th {
  color: var(--text);
  background: var(--soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

td {
  color: var(--muted);
}

td strong {
  color: var(--text);
}

.status {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e9f7e7;
  color: #2f7c2e;
  font-weight: 800;
  font-size: 12px;
}

.link-btn {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.mobile-list {
  display: none;
}

@media (max-width: 760px) {
  .page {
    padding: 20px 14px;
    align-items: start;
  }

  .login-card,
  .portal {
    padding: 24px;
    border-radius: 16px;
  }

  h1 {
    font-size: 38px;
    line-height: 1;
  }

  .lead {
    font-size: 15px;
    line-height: 1.42;
  }

  .portal-header {
    display: grid;
  }

  .toolbar {
    display: grid;
  }

  .toolbar input {
    max-width: none;
  }

  .table-wrap {
    display: none;
  }

  .mobile-list {
    display: grid;
    gap: 12px;
  }

  .report-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    background: white;
  }

  .report-card h2 {
    margin: 0 0 8px;
    font-size: 18px;
  }

  .report-card dl {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 6px 10px;
    margin: 12px 0;
    color: var(--muted);
    font-size: 13px;
  }

  .report-card dt {
    color: var(--text);
    font-weight: 700;
  }

  .report-card dd {
    margin: 0;
  }
}

.doc-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* 4zure certificate portal polish */
.table-wrap {
  margin-top: 18px;
  border: 1px solid rgba(54, 95, 67, 0.18);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

thead th {
  background: #edf6ef;
  color: #07130c;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 800;
  padding: 16px 16px;
  border-bottom: 1px solid rgba(54, 95, 67, 0.14);
  white-space: nowrap;
}

tbody td {
  padding: 18px 16px;
  vertical-align: top;
  border-bottom: 1px solid rgba(54, 95, 67, 0.10);
  font-size: 14px;
  line-height: 1.45;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(75, 175, 70, 0.035);
}

td:nth-child(2) {
  font-weight: 800;
  color: #07130c;
  min-width: 210px;
}

td:nth-child(4) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  color: #37443b;
}

td:nth-child(5) {
  max-width: 150px;
}

.status,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e8f7e7;
  color: #11751f;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
}

.doc-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}

.link-btn {
  min-width: 92px;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid rgba(15, 40, 24, 0.16);
  background: #ffffff;
  color: #07130c;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}

.link-btn:hover {
  border-color: rgba(75, 175, 70, 0.55);
  background: #f6fbf6;
}

.cert-btn {
  background: #2f983d;
  border-color: #2f983d;
  color: #ffffff;
}

.cert-btn:hover {
  background: #277f33;
  border-color: #277f33;
}

.search-row,
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 30px;
  margin-bottom: 14px;
}

.search-row input,
.toolbar input,
#searchInput {
  max-width: 520px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(15, 40, 24, 0.18);
  padding: 0 14px;
  font-size: 14px;
}

.report-count,
#reportCount {
  color: #37443b;
  font-size: 14px;
  white-space: nowrap;
}

.portal-note,
small,
.footer-note {
  color: #37443b;
  font-size: 13px;
  line-height: 1.5;
}

/* Mobile: make each device easier to read */
@media (max-width: 760px) {
  .table-wrap {
    border: none;
    background: transparent;
    overflow: visible;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead {
    display: none;
  }

  tbody tr {
    background: #ffffff;
    border: 1px solid rgba(54, 95, 67, 0.16);
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: 0 10px 24px rgba(12, 28, 17, 0.05);
  }

  tbody td {
    border-bottom: none;
    padding: 8px 0;
    display: grid;
    grid-template-columns: 112px 1fr;
    gap: 10px;
    align-items: start;
  }

  tbody td::before {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 800;
    color: #5a675f;
  }

  tbody td:nth-child(1)::before { content: "Dato"; }
  tbody td:nth-child(2)::before { content: "Enhet"; }
  tbody td:nth-child(3)::before { content: "Type"; }
  tbody td:nth-child(4)::before { content: "Serienummer"; }
  tbody td:nth-child(5)::before { content: "Metode"; }
  tbody td:nth-child(6)::before { content: "Status"; }
  tbody td:nth-child(7)::before { content: "Dokumenter"; }

  td:nth-child(2) {
    min-width: 0;
  }

  .doc-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .link-btn {
    width: 100%;
  }

  .search-row,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .search-row input,
  .toolbar input,
  #searchInput {
    max-width: none;
    width: 100%;
  }
}

/* Full BitRaser field table */
.portal-card {
  max-width: 1280px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  min-width: 1180px;
}

thead th {
  white-space: nowrap;
}

tbody td {
  vertical-align: top;
}

tbody td small {
  display: block;
  margin-top: 3px;
  color: #4c5a52;
  font-size: 12px;
}

.doc-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.refresh-btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid rgba(15, 40, 24, 0.18);
  background: #ffffff;
  color: #07130c;
  font-weight: 800;
  cursor: pointer;
}

.refresh-btn:hover {
  background: #f6fbf6;
  border-color: rgba(75, 175, 70, 0.55);
}

.refresh-btn:disabled,
button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.is-loading {
  opacity: 0.82;
  pointer-events: none;
}

.is-error {
  color: #a40000;
}

.status-ok {
  background: #e8f7e7;
  color: #11751f;
}

.status-warn {
  background: #fff3d6;
  color: #7a4d00;
}

@media (max-width: 900px) {
  table {
    min-width: 0;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead {
    display: none;
  }

  tbody tr {
    margin-bottom: 16px;
    padding: 16px;
    border: 1px solid rgba(54, 95, 67, 0.16);
    border-radius: 16px;
    background: #ffffff;
  }

  tbody td {
    display: grid;
    grid-template-columns: 145px 1fr;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(54, 95, 67, 0.08);
  }

  tbody td:last-child {
    border-bottom: none;
  }

  tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 800;
    color: #5a675f;
  }

  .doc-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .doc-actions .link-btn {
    width: 100%;
  }
}

/* Wider portal layout */
.page {
  max-width: none;
  width: 100%;
  padding-left: 24px;
  padding-right: 24px;
}

.portal {
  width: min(96vw, 1760px);
  max-width: none;
  margin-left: auto;
  margin-right: auto;
}

.card,
.login-card {
  max-width: 560px;
}

.portal .table-wrap {
  width: 100%;
  overflow-x: auto;
}

.portal table {
  width: max-content;
  min-width: 1480px;
}

.portal th,
.portal td {
  white-space: nowrap;
}

.portal td:nth-child(9),
.portal td:nth-child(11) {
  white-space: normal;
  min-width: 180px;
}

.portal-header {
  gap: 24px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

#searchInput {
  width: min(520px, 100%);
}

@media (max-width: 900px) {
  .page {
    padding-left: 12px;
    padding-right: 12px;
  }

  .portal {
    width: 100%;
  }

  .portal table {
    width: 100%;
    min-width: 0;
  }

  .portal th,
  .portal td {
    white-space: normal;
  }
}

.sort-btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  white-space: nowrap;
}

.sort-btn:hover {
  color: #2f983d;
}

thead th {
  user-select: none;
}

/* Force true full-width portal */
html,
body {
  width: 100%;
  min-width: 100%;
}

body {
  overflow-x: hidden;
}

.page {
  width: 100vw !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 24px !important;
  box-sizing: border-box;
  display: block !important;
}

.portal {
  width: calc(100vw - 48px) !important;
  max-width: none !important;
  margin: 0 auto !important;
  box-sizing: border-box;
}

.portal.card,
.portal {
  border-radius: 18px;
}

.login-card {
  max-width: 560px !important;
  margin: 40px auto !important;
}

.portal .table-wrap {
  width: 100% !important;
  max-width: none !important;
  overflow-x: auto !important;
  border-radius: 14px;
}

.portal table {
  width: 100% !important;
  min-width: 1660px !important;
  table-layout: auto;
}

.portal th,
.portal td {
  white-space: nowrap;
  overflow: visible;
}

.portal th:last-child,
.portal td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background: #ffffff;
  box-shadow: -10px 0 16px rgba(10, 30, 18, 0.06);
}

.portal th:last-child {
  background: #edf6ef;
  z-index: 3;
}

.action-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  text-decoration: none;
  background: #fff;
  border: 1px solid rgba(15, 40, 24, 0.16);
}

.action-eye:hover {
  background: #f6fbf6;
  border-color: rgba(75, 175, 70, 0.55);
}

.doc-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  flex-wrap: nowrap;
}

.doc-actions .link-btn {
  min-width: 94px;
}

#countText {
  white-space: nowrap;
}

@media (max-width: 900px) {
  .page {
    width: 100% !important;
    padding: 12px !important;
  }

  .portal {
    width: 100% !important;
  }

  .portal table {
    min-width: 0 !important;
  }

  .portal th:last-child,
  .portal td:last-child {
    position: static;
    box-shadow: none;
  }

  .doc-actions {
    flex-direction: column;
  }
}

/* Full height portal layout */
html,
body {
  min-height: 100%;
}

body {
  min-height: 100vh;
}

.page {
  min-height: 100vh !important;
  padding-top: 24px !important;
  padding-bottom: 24px !important;
  background: linear-gradient(135deg, #f3faf4 0%, #ffffff 45%, #f7fbf7 100%);
}

.portal {
  min-height: calc(100vh - 48px) !important;
  display: flex;
  flex-direction: column;
}

.portal .table-wrap {
  flex: 1 1 auto;
}

/* Cleaner table interactions */
tbody tr:hover {
  background: #fbfdfb !important;
}

.sort-btn:hover {
  color: #07130c !important;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

thead th {
  background: #eef7f0 !important;
}

/* Keep documents always visible */
.portal th:last-child,
.portal td:last-child {
  position: sticky !important;
  right: 0 !important;
  z-index: 5 !important;
  background: #ffffff !important;
  box-shadow: -14px 0 18px rgba(10, 30, 18, 0.08) !important;
}

.portal th:last-child {
  background: #eef7f0 !important;
  z-index: 6 !important;
}

.doc-actions {
  justify-content: flex-start;
}

.link-btn:hover {
  background: #ffffff !important;
  color: #07130c !important;
  border-color: rgba(15, 40, 24, 0.32) !important;
}

.cert-btn:hover {
  background: #2f983d !important;
  border-color: #2f983d !important;
  color: #ffffff !important;
}

.report-btn:hover {
  background: #f8fbf8 !important;
}

/* Make the Actions eye less strange */
.action-eye {
  color: #07130c !important;
  font-size: 15px;
}

.action-eye:hover {
  background: #f8fbf8 !important;
}

/* Better spacing when only a few rows */
.portal .hint {
  margin-top: 18px;
}

/* Final portal height/layout correction */
html,
body {
  min-height: 100vh !important;
}

body {
  margin: 0 !important;
}

.page {
  min-height: 100vh !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
}

.portal {
  min-height: calc(100vh - 48px) !important;
  padding-top: 28px !important;
  padding-bottom: 28px !important;
}

.portal-header {
  margin-bottom: 32px !important;
}

.toolbar {
  margin-top: 0 !important;
}

/* Keep documents visually stable */
.portal th:last-child,
.portal td:last-child {
  min-width: 230px !important;
}

.doc-actions {
  min-width: 205px;
}

/* Remove odd green hover/header artifact */
.sort-btn:hover {
  background: transparent !important;
  color: #07130c !important;
}

thead th .sort-btn {
  background: transparent !important;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
}

.brand img {
  display: block;
  height: 26px;
  width: auto;
  max-width: 120px;
}

.login-card .brand img {
  height: 30px;
}

.portal-header .brand img {
  height: 26px;
}

/* 4zure logo */
.brand {
  display: inline-flex !important;
  align-items: center !important;
  min-height: 34px !important;
  color: transparent !important;
}

.brand img {
  display: block !important;
  width: auto !important;
  height: 34px !important;
  max-width: 180px !important;
  object-fit: contain !important;
}

.login-card .brand img {
  height: 38px !important;
}

.portal-header .brand img {
  height: 30px !important;
}

/* Actions column removed */
.action-eye {
  display: none !important;
}
