:root {
  --ink: #25302f;
  --muted: #66736f;
  --line: #dce5e2;
  --paper: #ffffff;
  --bg: #f5f8f7;
  --teal: #0f9da8;
  --teal-dark: #08747c;
  --coral: #e86f4d;
  --green: #21885f;
  --amber: #b47a25;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

img,
svg {
  max-width: 100%;
}

.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  padding: 18px;
  color: #fff;
  background: #263432;
  overflow-y: auto;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  color: #fff;
  text-decoration: none;
  min-width: 0;
}

.admin-brand strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-brand span,
.login-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  color: #fff;
  font-weight: 900;
  background: var(--teal);
  border-radius: var(--radius);
}

.admin-sidebar nav {
  display: grid;
  gap: 6px;
}

.admin-sidebar nav a {
  padding: 11px 12px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
  text-decoration: none;
  border-radius: 6px;
}

.admin-sidebar nav a:hover,
.admin-sidebar nav a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.admin-menu-button,
.admin-menu-backdrop {
  display: none;
}

.admin-menu-button {
  width: 42px;
  height: 42px;
  padding: 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.admin-menu-button span {
  display: block;
  width: 100%;
  height: 2px;
  margin: 4px 0;
  background: var(--ink);
  border-radius: 999px;
}

.admin-shell {
  min-height: 100vh;
  margin-left: 250px;
  min-width: 0;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 88px;
  padding: 18px clamp(18px, 4vw, 42px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.admin-topbar > div {
  min-width: 0;
}

.admin-topbar p,
.admin-topbar h1 {
  margin: 0;
}

.admin-topbar p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-topbar h1 {
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-user span,
.admin-user a {
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.admin-main {
  padding: clamp(18px, 4vw, 42px);
  min-width: 0;
}

.admin-panel,
.stat-grid article,
.message-card,
.login-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(37, 48, 47, 0.08);
}

.admin-panel {
  padding: 20px;
  min-width: 0;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr);
  gap: 20px;
  align-items: start;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-grid article {
  padding: 18px;
}

.stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-grid strong {
  display: block;
  margin-top: 6px;
  color: var(--teal-dark);
  font-size: 34px;
  line-height: 1;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 20px;
}

.panel-heading a {
  color: var(--teal-dark);
  font-weight: 900;
  text-decoration: none;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

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

.table-actions a,
.table-actions button,
.message-actions button,
.message-actions select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 10px;
  color: var(--ink);
  background: #eef5f3;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.table-actions form,
.message-actions form {
  display: inline-flex;
  gap: 8px;
  margin: 0;
}

.thumb-cell {
  width: 92px;
}

.thumb-cell img,
.image-preview-row img {
  width: 76px;
  height: 54px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.image-preview-row img {
  width: min(260px, 100%);
  height: 150px;
}

.settings-section {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.settings-section h2 {
  margin: 0;
  font-size: 20px;
}

.settings-section p {
  margin: 4px 0 0;
  color: var(--muted);
}

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

.form-grid.compact {
  align-self: start;
}

.span-2 {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
}

textarea {
  resize: vertical;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

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

.admin-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  color: var(--ink);
  background: #eef5f3;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

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

.admin-notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-weight: 800;
}

.admin-notice.success {
  color: #17613f;
  background: #e8f7ee;
  border: 1px solid #aee3c2;
}

.admin-notice.error {
  color: #8d2b18;
  background: #fff0eb;
  border: 1px solid #efb8a7;
}

.info-list {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}

.info-list div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.info-list dt {
  color: var(--muted);
  font-weight: 900;
}

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

.status {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.status.new {
  color: #8d2b18;
  background: #fff0eb;
}

.status.read {
  color: #17613f;
  background: #e8f7ee;
}

.status.archived {
  color: #5f6066;
  background: #eceff1;
}

.message-list {
  display: grid;
  gap: 14px;
}

.message-card {
  padding: 18px;
}

.message-card header,
.message-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.message-card h2,
.message-card p {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.message-card header p,
.message-card time {
  color: var(--muted);
}

.message-actions {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(38, 52, 50, 0.90), rgba(38, 52, 50, 0.55)),
    url('../img/hero-duse-kabin.png') center / cover no-repeat;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 26px;
}

.install-card {
  width: min(760px, 100%);
}

.login-card h1 {
  margin: 0;
  font-size: 28px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.login-form,
.login-links {
  display: grid;
  gap: 14px;
}

.login-site-link {
  color: var(--teal-dark);
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

@media (max-width: 1100px) {
  .admin-layout,
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  body.admin-menu-open {
    overflow: hidden;
  }

  .admin-menu-button {
    display: inline-block;
  }

  .admin-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: block;
    padding: 0;
    background: rgba(37, 48, 47, 0.48);
    border: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

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

  .admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(286px, 84vw);
    height: 100vh;
    padding: 16px;
    box-shadow: 18px 0 34px rgba(37, 48, 47, 0.24);
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }

  body.admin-menu-open .admin-sidebar {
    transform: translateX(0);
  }

  .admin-brand {
    margin-bottom: 16px;
  }

  .admin-brand strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .admin-sidebar nav {
    display: grid;
    gap: 8px;
    overflow-x: visible;
    padding-bottom: 0;
  }

  .admin-sidebar nav a {
    min-height: 42px;
    white-space: normal;
  }

  .admin-shell {
    margin-left: 0;
  }

  .admin-topbar,
  .admin-layout,
  .form-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    min-height: auto;
    padding: 16px;
  }

  .admin-topbar h1 {
    font-size: 24px;
  }

  .admin-user {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .admin-user span,
  .admin-user a {
    display: inline-flex;
    justify-content: center;
    min-width: 0;
    text-align: center;
    overflow-wrap: anywhere;
  }

  .admin-main {
    padding: 14px;
  }

  .admin-panel,
  .message-card,
  .login-card {
    padding: 16px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .form-actions,
  .message-actions,
  .message-actions form {
    width: 100%;
  }

  .form-actions .admin-button,
  .message-actions button,
  .message-actions select {
    flex: 1 1 140px;
  }

  .message-card header,
  .message-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .info-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .table-wrap {
    overflow-x: visible;
  }

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

  table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

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

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

  td {
    display: grid;
    grid-template-columns: minmax(92px, 36%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
  }

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

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }

  td[data-label=""]::before {
    display: none;
  }

  td[data-label=""] {
    grid-template-columns: 1fr;
  }

  td.table-actions {
    grid-template-columns: 1fr;
  }

  td.table-actions::before,
  td.table-actions a,
  td.table-actions form {
    grid-column: 1;
  }

  td.table-actions form {
    display: grid;
  }

  .thumb-cell {
    width: auto;
  }

  .thumb-cell img {
    width: min(160px, 100%);
    height: auto;
    aspect-ratio: 4 / 3;
  }
}

@media (max-width: 520px) {
  .admin-sidebar {
    padding: 10px;
  }

  .admin-brand span,
  .login-mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .admin-topbar h1 {
    font-size: 22px;
  }

  .admin-user {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    gap: 10px;
  }

  .stat-grid article {
    padding: 14px;
  }

  .stat-grid strong {
    font-size: 30px;
  }

  .table-actions,
  .table-actions form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .table-actions a,
  .table-actions button {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  table {
    min-width: 0;
  }
}
