.app-shell {
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 460px) minmax(0, 1fr);
  background: var(--surface);
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 7vw, 80px);
  border-right: 1px solid var(--line);
}

.login-context {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: clamp(32px, 6vw, 80px);
  color: #fff;
  background: url("../img/gyogytornapont-hero.webp") center / cover no-repeat #102528;
}

.login-context::before {
  position: absolute;
  inset: 0;
  content: "";
  background: rgb(16 37 40 / 82%);
}

.login-context__copy {
  position: relative;
  z-index: 1;
  max-width: 620px;
}

.login-context h1 {
  max-width: 580px;
  margin: 0 0 12px;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: 0;
}

.login-context p {
  max-width: 520px;
  margin: 0;
  color: #d8e9e5;
  font-size: 17px;
  line-height: 1.55;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 42px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid currentColor;
  border-radius: 50%;
  color: var(--brand-strong);
  font-weight: 800;
}

.brand-name {
  font-size: 18px;
  font-weight: 750;
}

.brand-subtitle {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.login-panel h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.login-panel > p {
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.5;
}

.login-panel > .login-rights {
  margin: auto 0 0;
  padding-top: 22px;
  color: #7e9691;
  font-size: 9px;
  line-height: 1.4;
}

.portal-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 248px;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  color: #fff;
  background: var(--sidebar);
}

.sidebar .brand-lockup {
  margin: 2px 8px 28px;
}

.sidebar .brand-mark {
  color: var(--highlight);
}

.sidebar .brand-subtitle {
  color: var(--sidebar-muted);
}

.nav-label {
  margin: 0 10px 8px;
  color: #809b95;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--sidebar-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}

.nav-link:hover,
.nav-link[aria-current="page"] {
  color: #fff;
  background: rgb(76 206 208 / 14%);
}

.nav-link[aria-current="page"] {
  box-shadow: inset 3px 0 0 var(--highlight);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 10px 2px;
  border-top: 1px solid rgb(255 255 255 / 11%);
}

.software-rights {
  margin: 10px 0 0;
  padding-top: 9px;
  border-top: 1px solid rgb(255 255 255 / 8%);
  color: #7e9691;
  font-size: 7px;
  line-height: 1.35;
}

.sidebar-user {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--brand-strong);
  background: #bfe3dd;
  font-weight: 800;
}

.sidebar-user small {
  display: block;
  margin-top: 2px;
  color: var(--sidebar-muted);
}

.main-column {
  grid-column: 2;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 68px;
  padding: 12px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(10px);
}

.icon-button.mobile-menu {
  display: none;
}

.topbar-search {
  position: relative;
  flex: 1;
  max-width: 520px;
}

.topbar-search input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-subtle);
}

.topbar-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.page {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 30px clamp(18px, 4vw, 44px) 52px;
}

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

.page-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.page-header p {
  margin: 7px 0 0;
  color: var(--muted);
}

.page-actions,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.button:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
}

.button--primary {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.button--primary:hover {
  color: #fff;
  background: var(--brand-strong);
}

.button--compact {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 11px;
}

.button--danger {
  border-color: #e4bebe;
  color: var(--danger);
  background: var(--danger-soft);
}

.button--quiet {
  border-color: transparent;
  color: inherit;
  background: transparent;
}

.button[disabled] {
  opacity: .55;
  cursor: not-allowed;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  min-height: 118px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat__label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.stat__value {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat__detail {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel + .panel {
  margin-top: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 54px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 16px;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 18px;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  background: var(--surface-subtle);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.data-table tbody tr:hover {
  background: #f9fbfa;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.table-link {
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.table-link:hover {
  color: var(--brand);
  text-decoration: underline;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--surface-subtle);
  font-size: 11px;
  font-weight: 750;
}

.status--active,
.status--finalized,
.status--granted {
  color: var(--success);
  background: var(--success-soft);
}

.status--draft,
.status--missing {
  color: var(--warning);
  background: var(--warning-soft);
}

.status--closed,
.status--inactive {
  color: var(--muted);
  background: #edf0ef;
}

.timeline {
  display: grid;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  min-height: 76px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-time {
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.timeline-item h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.timeline-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.notice {
  padding: 12px 14px;
  border-left: 4px solid var(--warning);
  color: #60430f;
  background: var(--warning-soft);
  font-size: 13px;
  line-height: 1.5;
}

.notice--info {
  border-color: var(--brand);
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.empty-state {
  padding: 42px 20px;
  color: var(--muted);
  text-align: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px 16px;
}

.field {
  grid-column: span 6;
  min-width: 0;
}

.field--third {
  grid-column: span 4;
}

.field--quarter {
  grid-column: span 3;
}

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

.field label,
.fieldset-title {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 750;
}

.required::after {
  content: " *";
  color: var(--danger);
}

.field input,
.field select,
.field textarea,
.search-input {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.45;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-input:focus {
  border-color: var(--brand);
}

.field-hint {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.date-input {
  display: grid;
  grid-template-columns: minmax(72px, 1.3fr) auto minmax(50px, 0.8fr) auto minmax(50px, 0.8fr);
  align-items: center;
  gap: 6px;
  max-width: 260px;
}

.field .date-input input {
  min-width: 0;
  padding-inline: 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.date-input__separator {
  color: var(--muted);
  font-weight: 700;
}

.section-heading {
  grid-column: 1 / -1;
  margin: 10px 0 0;
  padding: 10px 0 7px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
}

.record-header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.record-header__identity {
  flex: 1;
}

.record-header h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 18px;
  color: var(--muted);
  font-size: 13px;
}

.warning-strip {
  margin-top: 14px;
  padding: 9px 11px;
  border-left: 3px solid var(--accent);
  color: #713b20;
  background: var(--accent-soft);
  font-size: 12px;
}

.tab-list {
  display: flex;
  overflow-x: auto;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tab-link {
  min-height: 42px;
  padding: 10px 16px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.tab-link[aria-current="page"] {
  border-color: var(--brand);
  color: var(--brand-strong);
}

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

.episode-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.episode-row h3 {
  margin: 0 0 5px;
  font-size: 15px;
}

.episode-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.episode-row__meta {
  min-width: 150px;
  text-align: right;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-subtle);
}

.metric__label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.metric__value {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  font-weight: 800;
}

.measurement-editor {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.measurement-row {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr .8fr .8fr .8fr 42px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.measurement-row:last-child {
  border-bottom: 0;
}

.measurement-row .field {
  grid-column: auto;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-subtle);
}

.segmented button {
  min-height: 32px;
  padding: 5px 10px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  color: var(--brand-strong);
  background: #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 9%);
}

.demo-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 8px;
  border: 1px solid #dcae8c;
  border-radius: 999px;
  color: #743e22;
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 750;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr);
  gap: 18px;
  align-items: start;
}

.admin-grid > * {
  min-width: 0;
}

.admin-grid > .panel + .panel {
  margin-top: 0;
}

.admin-editor {
  position: sticky;
  top: 86px;
}

.user-identity {
  display: grid;
  gap: 3px;
  min-width: 150px;
}

.user-identity strong,
.user-identity small {
  display: block;
  overflow-wrap: anywhere;
}

.user-identity small {
  color: var(--muted);
  font-size: 11px;
}

.temporary-label {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 6px;
  color: #6b4b12;
  background: var(--accent-soft);
  font-size: 9px;
  font-weight: 750;
}

.permissions-panel {
  margin-top: 18px;
}

.permission-table th:not(:first-child),
.permission-table td:not(:first-child) {
  width: 160px;
  text-align: center;
}

.permission-marker {
  display: inline-block;
  min-width: 42px;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 750;
}

.permission-marker--yes {
  color: var(--success);
  background: var(--success-soft);
}

.permission-marker--no {
  color: var(--muted);
  background: #edf1f0;
}

.permission-note {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.credential-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 80px rgb(16 37 40 / 28%);
}

.credential-dialog::backdrop {
  background: rgb(16 37 40 / 58%);
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.dialog-header {
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
  font-size: 17px;
}

.dialog-body {
  padding: 16px;
}

.dialog-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.credential-list {
  margin: 16px 0 0;
}

.credential-list > div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.credential-list dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.credential-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.credential-list code {
  font-size: 15px;
  font-weight: 800;
  user-select: all;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: grid;
  gap: 8px;
  max-width: min(360px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  color: #fff;
  background: #243d39;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast--error {
  border-color: #ff8f8f;
  background: #603333;
}

.spinner {
  width: 28px;
  height: 28px;
  margin: 56px auto;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1050px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .measurement-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .admin-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-editor {
    position: static;
  }
}

@media (max-width: 760px) {
  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-panel {
    min-height: 65vh;
    border: 0;
  }

  .login-context {
    min-height: 35vh;
  }

  .login-context h1 {
    font-size: 32px;
  }

  .portal-layout {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgb(0 0 0 / 24%);
  }

  .main-column {
    grid-column: auto;
  }

  .icon-button.mobile-menu {
    display: inline-grid;
  }

  .topbar-meta {
    display: none;
  }

  .page {
    padding-top: 20px;
  }

  .page-header,
  .record-header {
    flex-direction: column;
  }

  .page-actions {
    width: 100%;
  }

  .form-actions {
    position: static;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .field,
  .field--third,
  .field--quarter {
    grid-column: 1 / -1;
  }

  .episode-row {
    grid-template-columns: 1fr;
  }

  .episode-row__meta {
    text-align: left;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .measurement-row {
    grid-template-columns: 1fr 1fr;
  }

}

@media (max-width: 460px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 10px;
  }

  .page-header h1,
  .record-header h1 {
    font-size: 23px;
  }

  .measurement-row {
    grid-template-columns: 1fr;
  }

  .credential-list > div {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}
