:root {
  --bg: #f4f8fb;
  --panel: #ffffff;
  --ink: #0f2a3d;
  --muted: #5c7383;
  --accent: #0c7a6b;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --line: #d5e0e8;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #eef6fb 0%, #f8fbfd 35%, #f2f7f5 100%);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(5px);
  position: sticky;
  top: 0;
  z-index: 50;
}


.brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 700;
  letter-spacing: 0.3px;
  text-align: center;
  white-space: nowrap;
}


.nav {
  position: absolute;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 4px 8px;
}

.container {
  width: calc(100vw - 32px);
  margin: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1 0 auto;
  box-sizing: border-box;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 8px 26px rgba(8, 33, 55, 0.06);
  width: 100%;
}

.medicin-page-panel {
  width: 100%;
}

.panel-small {
  max-width: 560px;
  margin: 0 auto;
}

h1,
h2,
h3 {
  margin-top: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fbfdff;
}

.stat h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.stat p {
  margin: 8px 0 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.form-grid {
  display: grid;
  gap: 8px;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

input,
select,
button,
.button-link,
a {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.search-row input {
  flex: 1 1 280px;
}

button,
.button-link {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 10px;
  padding: 9px 13px;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}

button:hover,
.button-link:hover {
  filter: brightness(0.95);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

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

th {
  vertical-align: middle;
}

.th-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.th-sort {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.th-sort.active {
  color: var(--accent);
}

.th-filter-dropdown {
  position: relative;
}

.th-filter-dropdown summary {
  list-style: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  user-select: none;
}

.th-filter-dropdown summary::-webkit-details-marker {
  display: none;
}

.th-filter-dropdown[open] summary {
  color: var(--accent);
}

.th-filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  min-width: 180px;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(8, 33, 55, 0.14);
  padding: 6px;
}

.th-filter-menu a {
  display: block;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}

.th-filter-menu a:hover {
  background: #eef6fb;
}

.th-filter-menu a.active {
  background: #e2f2ef;
  color: #0a5a4e;
  font-weight: 700;
}

tbody tr.row-low-stock td {
  background: #FFF3C4;
}

.cd-marked-cell {
  background: #e8f6ea;
  color: #1e5b34;
  font-weight: 700;
  text-align: center;
}

.cd-marked-input {
  background: #e8f6ea;
  color: #1e5b34;
  font-weight: 700;
}

tbody tr.row-expiring td {
  background: #FFD59A;
}

tbody tr.row-expired td {
  background: #FFCDD2;
}

.actions a {
  margin-right: 10px;
}

.error {
  color: var(--danger);
  font-weight: 600;
}

.warn {
  color: #7a4f01;
  font-weight: 600;
}

.success {
  color: #086247;
  font-weight: 600;
}

.muted-note {
  color: var(--muted);
  margin-top: 0;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row-actions form {
  margin: 0;
}

.calendar-alert {
  border: 1px solid #f0d58a;
  border-radius: 10px;
  background: #fff8df;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.calendar-alert h3 {
  margin: 0 0 8px;
}

.calendar-alert ul {
  margin: 0;
  padding-left: 18px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.calendar-nav h2 {
  margin: 0;
}

.calendar-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
}

.calendar-grid-wrap {
  overflow-x: auto;
}

.calendar-grid {
  width: 100%;
  table-layout: fixed;
}

.calendar-grid th,
.calendar-grid td {
  text-align: center;
  vertical-align: middle;
}

.calendar-grid td {
  padding: 0;
  height: 82px;
}

.calendar-grid td.empty {
  background: #f7fbff;
}

.calendar-grid td.today {
  background: #eef6fb;
}

.calendar-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: var(--ink);
}

.calendar-day:hover {
  background: #f4faf9;
}

.calendar-day.selected {
  background: #e2f2ef;
  font-weight: 700;
}

.calendar-day.has-events .day-number {
  color: #0a5a4e;
  font-weight: 700;
}

.day-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.calendar-side {
  display: grid;
  gap: 12px;
}

.calendar-event-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  resize: vertical;
}

.row-actions form button,
.row-actions a.button-link {
  margin: 0;
}

.medicin-preparat-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.medicin-preparat-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.top-actions {
  flex-wrap: wrap;
  overflow-x: visible;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  justify-content: center;
}

.top-actions > * {
  flex: 0 0 auto;
}

.inline-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  flex: 0 0 auto;
}

.inline-action input[type="text"] {
  width: 280px;
}

.inline-action button,
.inline-action .button-link {
  margin: 0;
}

.file-picker {
  display: none;
}

.inline-cell-input {
  width: 110px;
  min-width: 90px;
  padding: 6px 8px;
}

.inline-cell-input.inline-center {
  text-align: center;
}

.inline-center-text {
  text-align: center;
}

.max-min-group-row th {
  border-bottom: none;
  padding: 4px 8px 2px;
}

.max-min-group-row th:not(.max-min-group) {
  color: transparent;
}

.max-min-group {
  text-align: center;
  border: none;
  background: transparent;
  padding: 2px 0 4px;
  vertical-align: middle;
}

.max-min-group-text {
  display: inline-block;
  margin: 0 auto;
  padding: 6px 10px;
  border: 1px solid #f0d58a;
  border-radius: 8px;
  background: #fff8df;
  color: #5f4600;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
  max-width: 100%;
  transform: translateX(-5ch);
}

.search-line {
  margin-top: 10px;
  margin-bottom: 12px;
  justify-content: center;
}

.filter-shell {
  display: grid;
  gap: 12px;
}

.column-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.filter-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
}

.filter-card-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.filter-card-label .btn-icon {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
  max-width: 14px;
  max-height: 14px;
  margin-right: 0;
  vertical-align: middle;
}

.select-col {
  width: 34px;
  text-align: center;
}

.select-col input {
  width: auto;
}

.table-scroll {
  width: 100%;
  max-height: min(68vh, 760px);
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll .column-header-row th {
  position: sticky;
  top: 0;
  z-index: 25;
  background: #fff;
}

.table-scroll.table-scroll-with-top-row .max-min-group-row th {
  position: sticky;
  top: 0;
  z-index: 26;
  background: #fff;
}

.table-scroll.table-scroll-with-top-row .column-header-row th {
  top: 44px;
}

.front-logo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 280px;
}

.search-row.search-line input {
  text-align: center;
}

.panel.panel-small {
  margin-left: auto;
  margin-right: auto;
}

.front-logo {
  width: 440px;
  max-width: min(90vw, 440px);
  height: auto;
  object-fit: contain;
}

.login-panel {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.login-brand-frame {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 0 16px;
  padding: 16px 14px;
  border: 2px solid #6ea8dc;
  border-radius: 14px;
  background: linear-gradient(180deg, #eef7ff 0%, #f8fbff 100%);
}

.login-logo {
  width: min(100%, 680px);
  height: auto;
  object-fit: contain;
}

.btn-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  max-width: 20px;
  max-height: 20px;
  object-fit: contain;
  display: inline-block;
}

button .btn-icon,
.button-link .btn-icon,
.nav button .btn-icon,
.nav a .btn-icon {
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  min-height: 24px !important;
  max-width: 24px !important;
  max-height: 24px !important;
  object-fit: contain;
  display: inline-block;
  margin-right: 6px;
  vertical-align: -5px;
}

.site-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  width: 100%;
  color: var(--muted);
  padding: 18px 12px 22px;
  font-size: 0.92rem;
}

.user-accordion {
  display: grid;
  gap: 10px;
}

.user-accordion-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  overflow: hidden;
}

.user-accordion-item summary {
  list-style: none;
  cursor: pointer;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.user-accordion-item summary::-webkit-details-marker {
  display: none;
}

.user-summary-main {
  font-weight: 700;
}

.user-summary-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.user-accordion-item[open] summary {
  border-bottom: 1px solid var(--line);
  background: #f3f8fc;
}

.user-accordion-body {
  padding: 12px;
}

.user-last-login {
  margin-top: 0;
}

.user-reset-form {
  margin-top: 10px;
}

.simple-chart-list {
  display: grid;
  gap: 10px;
}

.simple-chart-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fbfdff;
}

.simple-chart-row header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.simple-chart-row header span {
  color: var(--muted);
  font-size: 0.92rem;
}

.bar-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #e6eef4;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.bar-consumption {
  background: linear-gradient(90deg, #0c7a6b 0%, #16a085 100%);
}

.bar-medicin {
  background: #3b82f6;
}

.bar-varer {
  background: #8b5cf6;
}

.bar-cd {
  background: #16a34a;
}

.bar-kritisk {
  background: #dc2626;
}

.simple-metric-grid {
  display: grid;
  gap: 8px;
}

.simple-metric-item {
  display: grid;
  gap: 4px;
}

.simple-metric-item span {
  color: var(--muted);
  font-size: 0.9rem;
}


@media (max-width: 760px) {
  .topbar {
    justify-content: center;
    align-items: center;
    padding-bottom: 10px;
  }

  .brand {
    position: static;
    transform: none;
    width: 100%;
  }

  .nav {
    position: static;
    width: 100%;
    justify-content: center;
    margin-top: 6px;
  }

  .column-filter-grid {
    grid-template-columns: 1fr;
  }

  .calendar-layout {
    grid-template-columns: 1fr;
  }

  .user-summary-meta {
    line-height: 1.4;
  }

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

  thead {
    display: none;
  }

  .table-scroll {
    max-height: none;
    overflow-y: visible;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 8px;
    background: #fff;
  }

  td {
    border-bottom: none;
    padding: 4px 0;
  }
}
.login-panel {
  max-width: 420px;
  margin: 0 auto;
}
