:root {
  color-scheme: light;
  font-family: Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
}

body {
  margin: 0;
  background: #f5f7fb;
  color: #1f2937;
  overflow-x: hidden;
}

body.menu-open {
  overflow: hidden;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

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

.mobile-app-bar,
.menu-backdrop,
.menu-close {
  display: none;
}

.sidebar {
  width: 260px;
  flex: 0 0 260px;
  background: #102a43;
  color: white;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-header {
  display: block;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .15);
}

.sidebar-user-text {
  min-width: 0;
}

.sidebar-user-text strong,
.sidebar-user-text .muted {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #1f4e79;
  font-weight: 700;
  overflow: hidden;
}

.sidebar-menu {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 20px;
}

.sidebar-nav,
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-footer {
  margin-top: auto;
}

.sidebar a {
  color: white;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 6px;
}

.sidebar a:hover,
.sidebar a:focus-visible {
  background: rgba(255, 255, 255, .12);
  outline: none;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 24px;
}

.button-link {
  color: white;
  background: #1f4e79;
  padding: 10px 14px;
  border-radius: 6px;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.button-link.secondary {
  background: #0f766e;
}

.card,
.field,
.section-header {
  background: white;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-header h1 {
  margin: 0;
}

label {
  display: block;
  margin: 8px 0 4px;
  font-weight: 600;
}

input,
select,
button {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  margin-bottom: 10px;
  font: inherit;
}

button {
  background: #1f4e79;
  color: white;
  cursor: pointer;
}

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

.checkbox-row input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.inline-row {
  display: flex;
  gap: 8px;
}

.inline-row > * {
  min-width: 0;
}

.login-card {
  max-width: 380px;
  margin: 80px auto;
  padding: 24px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

.error {
  color: #b91c1c;
}

.muted {
  color: #64748b;
}

.sidebar .muted {
  color: #cbd5e1;
}

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

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

th,
td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px;
  text-align: left;
  overflow-wrap: anywhere;
}

.record-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.record-actions form {
  margin: 0;
}

.danger-button {
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 8px 10px;
  background: #b91c1c;
  border-color: #b91c1c;
}

.danger-button:hover,
.danger-button:focus-visible {
  background: #991b1b;
  border-color: #991b1b;
}

.group-box {
  border: 1px solid #e5e7eb;
  padding: 10px;
  border-radius: 6px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  max-width: 100%;
}

.tab {
  padding: 10px 14px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #102a43;
  text-decoration: none;
  text-align: center;
}

.tab.active {
  background: #1f4e79;
  color: white;
}

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

.hero-card h1 {
  font-size: 1.8rem;
  line-height: 1.2;
  margin-bottom: 8px;
}

.profile-card {
  max-width: 680px;
}

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

.profile-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-large {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #1f4e79;
  color: white;
  font-size: 2.2rem;
  font-weight: 700;
  object-fit: cover;
  overflow: hidden;
}

.avatar-large.placeholder {
  background: #0f766e;
}

.group-editor {
  border: 1px solid #e5e7eb;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  margin-bottom: 12px;
}

.group-editor .group-row {
  border: 1px solid #e2e8f0;
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 8px;
  background: white;
}

.group-editor .group-child-list {
  margin: 8px 0 8px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.group-editor .inline-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.group-editor .inline-row input {
  margin-bottom: 0;
}

.group-editor button.secondary,
.group-editor .add-child-btn {
  background: #0f766e;
  width: auto;
  padding: 8px 12px;
}

.group-editor .remove-group-row,
.group-editor .remove-child-row {
  width: auto;
  background: #e11d48;
  color: white;
  border: none;
  padding: 8px 10px;
}

@media (max-width: 1024px) {
  .sidebar {
    width: 220px;
    flex-basis: 220px;
  }

  .content {
    padding: 20px;
  }

  .inline-row {
    flex-wrap: wrap;
  }

  .inline-row > * {
    flex: 1 1 180px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    min-height: 100vh;
  }

  .mobile-app-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    min-height: 56px;
    padding: 8px 16px;
    background: #102a43;
    box-shadow: 0 2px 12px rgba(15, 23, 42, .18);
  }

  .menu-toggle {
    width: auto;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, .4);
    background: rgba(255, 255, 255, .1);
    color: white;
  }

  .menu-toggle-icon {
    position: relative;
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 999px;
  }

  .menu-toggle-icon::before,
  .menu-toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 999px;
  }

  .menu-toggle-icon::before {
    top: -6px;
  }

  .menu-toggle-icon::after {
    top: 6px;
  }

  .menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: block;
    pointer-events: none;
    background: rgba(15, 23, 42, .45);
    opacity: 0;
    transition: opacity .2s ease;
  }

  .menu-backdrop.is-open {
    pointer-events: auto;
    opacity: 1;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(300px, 84vw);
    min-height: 100vh;
    padding: 20px 16px;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 12px 0 24px rgba(15, 23, 42, .22);
    overflow-y: auto;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

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

  .sidebar-user {
    flex: 1;
    padding-bottom: 0;
    border-bottom: 0;
  }

  .menu-close {
    width: 40px;
    min-height: 40px;
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .35);
    background: rgba(255, 255, 255, .1);
    color: white;
    font-size: 1.5rem;
    line-height: 1;
  }

  .sidebar-menu {
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, .15);
  }

  .sidebar-footer {
    margin-top: 0;
  }

  .sidebar a {
    padding: 10px 12px;
  }

  .content {
    width: 100%;
    padding: 16px;
  }

  h1 {
    font-size: 1.45rem;
    line-height: 1.2;
  }

  .hero-card h1 {
    font-size: 1.45rem;
  }

  .card,
  .field,
  .section-header {
    padding: 14px;
    margin-bottom: 12px;
  }

  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .actions,
  .inline-row,
  .group-editor .inline-row {
    flex-direction: column;
  }

  .button-link,
  .actions .button-link,
  .group-editor button.secondary,
  .group-editor .add-child-btn,
  .group-editor .remove-group-row,
  .group-editor .remove-child-row {
    width: 100%;
  }

  .tabs {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .tab {
    flex: 0 0 auto;
  }

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

  table {
    background: transparent;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
  }

  td {
    display: grid;
    grid-template-columns: minmax(96px, 38%) 1fr;
    gap: 12px;
    align-items: start;
    padding: 9px 0;
    border-bottom: 1px solid #e5e7eb;
    text-align: right;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: #475569;
    font-weight: 700;
    text-align: left;
  }

  td a,
  td .record-actions {
    justify-self: end;
  }

  .record-actions {
    justify-content: flex-end;
  }

  .danger-button {
    width: auto;
  }

  .login-card {
    max-width: none;
    margin: 32px 16px;
    padding: 20px;
  }

  .profile-card {
    max-width: none;
  }

  .group-editor .group-child-list {
    margin-left: 0;
  }
}
