/* ===== FÄRGTEMAN ===== */
:root,
[data-theme="forest"] {
  --brand-primary: #1b4d3e;
  --brand-dark: #12352b;
  --brand-accent: #2b7a60;
  --brand-soft: #eaf3ef;
  --brand-border: #c5ded4;
}

[data-theme="ocean"] {
  --brand-primary: #184a70;
  --brand-dark: #0f314b;
  --brand-accent: #256ea6;
  --brand-soft: #eaf1f7;
  --brand-border: #c4d8e8;
}

[data-theme="burgundy"] {
  --brand-primary: #691f30;
  --brand-dark: #47131f;
  --brand-accent: #942d45;
  --brand-soft: #f7ecef;
  --brand-border: #e3c5cd;
}

[data-theme="slate"] {
  --brand-primary: #2d3642;
  --brand-dark: #1d232b;
  --brand-accent: #47586e;
  --brand-soft: #eef0f3;
  --brand-border: #cfd5de;
}

:root {
  --page-bg: #f1f3f5;
  --surface: #ffffff;
  --surface-subtle: #f8f9fa;
  --border-color: #dee2e6;
  --border-strong: #ced4da;
  --text-main: #212529;
  --text-muted: #6c757d;
  --radius-md: 8px;
  --radius-sm: 5px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px 16px 36px;
  background-color: var(--page-bg);
  color: var(--text-main);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
}

a {
  color: var(--brand-accent);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  background: var(--surface-subtle);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

/* ===== PORTALRAM ===== */
.portal-shell {
  max-width: 1040px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

/* ===== HEADER & MENY ===== */
.portal-header {
  background-color: var(--brand-primary);
  color: #ffffff;
  padding: 14px 20px 12px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.brand-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
  margin: 0;
}

.brand-subtitle {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  opacity: 0.78;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-select {
  font-family: inherit;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: var(--brand-dark);
  color: #ffffff;
  cursor: pointer;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px 10px 4px 5px;
  border-radius: 999px;
}

.user-avatar-sm {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
}

.header-role-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.logout-btn {
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  text-decoration: none;
}

.primary-nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  gap: 12px;
}

.primary-tabs,
.header-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.primary-tabs a,
.header-tools > button {
  display: inline-flex;
  align-items: center;
  padding: 6px 13px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.86);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.primary-tabs a:hover,
.header-tools > button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  text-decoration: none;
}

.primary-tabs a.active {
  background: #ffffff;
  color: var(--brand-dark);
  font-weight: 600;
}

.header-tools > button {
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(255, 255, 255, 0.18);
  font-size: 12.5px;
}

.header-tools .star-btn {
  padding: 6px 10px;
  color: rgba(255, 255, 255, 0.65);
}

.header-tools .star-btn.is-bookmarked {
  color: #ffd43b;
  background: rgba(0, 0, 0, 0.28);
}

.bookmarks-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 250px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 10px 12px;
  z-index: 50;
  color: var(--text-main);
}

.bookmarks-dropdown.open {
  display: block;
}

.bookmarks-dropdown ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bookmarks-dropdown li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 12.5px;
}

.bookmarks-dropdown li:last-child {
  border-bottom: none;
}

/* ===== UNDERMENY & SÖK ===== */
.subnav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  gap: 16px;
}

.sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.sub-tabs a {
  display: block;
  padding: 12px 2px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.sub-tabs a:hover {
  color: var(--text-main);
  text-decoration: none;
}

.sub-tabs a.active {
  color: var(--brand-primary);
  font-weight: 600;
  border-bottom-color: var(--brand-primary);
}

.search-box {
  display: flex;
  align-items: center;
  margin: 7px 0;
}

.search-box input {
  width: 220px;
  height: 30px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12.5px;
  border: 1px solid var(--border-strong);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--surface);
  outline: none;
}

.search-box input:focus {
  border-color: var(--brand-accent);
}

.search-box button {
  height: 30px;
  padding: 0 11px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12.5px;
}

.search-box button:hover {
  background: var(--brand-soft);
  color: var(--brand-primary);
}

/* ===== HUVUDYTA & PANELER ===== */
.portal-body {
  padding: 24px 24px 32px;
}

.content-card {
  min-height: 440px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 36px;
}

.tab-panel.single-col.active {
  display: block;
}

/* ===== VÄLKOMST & KORT ===== */
.welcome-header {
  margin-bottom: 16px;
}

.welcome-heading {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
}

.meta-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.code-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  color: var(--brand-primary);
  font-weight: 600;
  font-size: 11.5px;
}

.intro-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 26px;
}

.avatar-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand-soft);
  border: 2px solid var(--brand-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-primary);
  font-weight: 700;
  font-size: 19px;
  flex-shrink: 0;
}

.section-block {
  margin-bottom: 26px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 12px;
  gap: 12px;
}

.section-header h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--brand-primary);
}

.btn-classic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.btn-classic:hover {
  background: var(--surface-subtle);
  border-color: #adb5bd;
  text-decoration: none;
}

.btn-primary {
  color: #ffffff;
  background: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #ffffff;
}

.btn-danger {
  color: #c92a2a;
  border-color: #ffa8a8;
  background: #fff5f5;
}

.btn-danger:hover {
  background: #ffe3e3;
  color: #a61e1e;
}

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-color);
}

.item-title {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 2px;
}

.item-meta {
  font-size: 12px;
  color: var(--text-main);
}

.item-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.more-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 12.5px;
}

.shortcut-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.tile-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  text-align: center;
}

.tile-btn:hover {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-primary);
  text-decoration: none;
}

.tile-icon {
  font-size: 20px;
  line-height: 1;
}

.link-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.link-list li {
  margin-bottom: 6px;
  padding-left: 16px;
  position: relative;
}

.link-list li::before {
  content: "›";
  position: absolute;
  left: 2px;
  top: -1px;
  color: var(--brand-accent);
  font-weight: 700;
  font-size: 15px;
}

.info-card {
  padding: 10px 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 12.5px;
}

.info-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.role-tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-primary);
}

/* ===== TABELLER & FILTER ===== */
.toolbar-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
}

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

.input-classic,
.select-classic {
  height: 32px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12.5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.input-classic:focus,
.select-classic:focus {
  border-color: var(--brand-accent);
  outline: none;
}

.portal-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.portal-table th {
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border-strong);
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
}

.portal-table td {
  border-bottom: 1px solid var(--border-color);
  padding: 9px 12px;
  vertical-align: middle;
}

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

.portal-table tbody tr:hover {
  background-color: var(--brand-soft);
}

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill.online {
  background: #d3f9d8;
  color: #2b8a3e;
}

.status-pill.maintenance {
  background: #fff3bf;
  color: #b07908;
}

.status-pill.offline {
  background: #ffe3e3;
  color: #c92a2a;
}

.cred-box {
  margin-top: 6px;
  padding: 6px 8px;
  background: var(--surface-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
}

/* ===== FORMULÄR & KPI ===== */
.classic-form {
  max-width: 560px;
}

.form-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.form-row label {
  font-weight: 600;
  font-size: 12.5px;
}

.entity-form-card {
  max-width: 780px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px 22px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field.full-width {
  grid-column: 1 / -1;
}

.form-field label {
  font-weight: 600;
  font-size: 12.5px;
}

.form-field .input-classic,
.form-field .select-classic {
  width: 100%;
  height: 34px;
}

.textarea-classic {
  width: 100%;
  min-height: 82px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12.5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  resize: vertical;
}

.textarea-classic:focus {
  border-color: var(--brand-accent);
  outline: none;
}

.form-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
  gap: 10px;
}

.notice-banner {
  display: none;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-sm);
  color: var(--brand-primary);
  font-weight: 500;
  font-size: 12.5px;
}

.notice-banner.visible {
  display: block;
}

.error-banner {
  display: none;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: #fff5f5;
  border: 1px solid #ffc9c9;
  border-radius: var(--radius-sm);
  color: #c92a2a;
  font-size: 12.5px;
  font-weight: 500;
}

.error-banner.visible {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-box {
  background: var(--surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--brand-primary);
  line-height: 1.1;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== INLOGGNING ===== */
.login-page-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.07);
  overflow: hidden;
}

.login-card-header {
  background: var(--brand-primary);
  color: #ffffff;
  padding: 18px 22px;
}

.login-card-body {
  padding: 22px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.login-field label {
  font-weight: 600;
  font-size: 12.5px;
}

.login-field .input-classic {
  width: 100%;
  height: 36px;
}

.login-submit-btn {
  width: 100%;
  height: 38px;
  font-size: 13.5px;
  font-weight: 600;
}

.demo-box {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
}

.demo-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.portal-footer {
  max-width: 1040px;
  margin: 14px auto 0;
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 820px) {
  .header-top,
  .primary-nav-row,
  .subnav-bar,
  .portal-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .tab-panel.active,
  .kpi-grid,
  .shortcut-tiles,
  .form-row,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}