/* ==========================================================================
   Крайчинська Наталія Сергіївна — адмінка
   ========================================================================== */

:root {
  --ink: #17251f;
  --ink-soft: #4f5d55;
  --ink-muted: #5f6a61;
  --forest: #173f33;
  --forest-deep: #0d2a22;
  --forest-soft: #2f5b49;
  --sage: #e6ece2;
  --sage-mid: #b9c9b6;
  --cream: #f5f2ea;
  --paper: #fffdf8;
  --sand: #eadfce;
  --terracotta: #c96f4d;
  --terracotta-dark: #a85638;
  --gold: #d8af71;
  --danger: #b8462b;
  --danger-bg: #fff3ee;
  --line: rgba(23, 37, 31, 0.11);
  --line-strong: rgba(23, 37, 31, 0.2);
  --shadow-sm: 0 4px 16px rgba(23, 40, 32, 0.05);
  --shadow-md: 0 18px 55px rgba(18, 44, 34, 0.12);
  --shadow-lg: 0 30px 90px rgba(8, 26, 18, 0.28);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 30px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--cream);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.modal-open {
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

p,
h1,
h2,
h3,
h4,
ul,
ol {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

::selection {
  background: var(--terracotta);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 3px;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------- Buttons ---------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition:
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease,
    transform 180ms ease,
    opacity 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
  transform: none;
}

.button .icon {
  width: 16px;
  height: 16px;
}

.button-primary {
  background: var(--forest);
  color: var(--paper);
}

.button-primary:hover:not(:disabled) {
  background: var(--forest-deep);
}

.button-secondary {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink-soft);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--ink);
}

.button-ghost {
  background: transparent;
  color: var(--ink-soft);
}

.button-ghost:hover:not(:disabled) {
  background: rgba(23, 37, 31, 0.055);
  color: var(--ink);
}

.button-danger {
  border-color: rgba(184, 70, 43, 0.2);
  background: var(--danger-bg);
  color: var(--danger);
}

.button-danger:hover:not(:disabled) {
  border-color: rgba(184, 70, 43, 0.32);
  background: #ffe9e0;
}

.button-block {
  width: 100%;
}

.button-large {
  min-height: 48px;
  padding: 13px 20px;
  font-size: 0.82rem;
}

.button-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.38);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.button.is-busy span:not(.button-spinner),
.button.is-busy .icon {
  display: none;
}

.button.is-busy .button-spinner {
  display: inline-block;
}

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

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  flex: none;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  transition:
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease;
}

.icon-button:hover {
  background: rgba(23, 37, 31, 0.06);
  color: var(--ink);
}

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

.icon-button .icon {
  width: 17px;
  height: 17px;
}

/* -------------------------------- Login view -------------------------------- */

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(430px, 0.98fr);
}

.login-art {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(36px, 5vw, 70px);
  overflow: hidden;
  color: var(--paper);
  isolation: isolate;
}

.login-art-photo {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(155deg, rgba(13, 42, 34, 0.32) 0%, rgba(13, 42, 34, 0.82) 100%),
    linear-gradient(90deg, rgba(13, 42, 34, 0.45), transparent),
    url("/assets/images/tutor-alt.jpg") center 28% / cover no-repeat;
  transform: scale(1.01);
}

.login-art::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(216, 175, 113, 0.17), transparent 32%),
    radial-gradient(circle at 80% 85%, rgba(201, 111, 77, 0.18), transparent 36%);
  pointer-events: none;
}

.login-art::before {
  content: "";
  position: absolute;
  z-index: -1;
  right: -150px;
  bottom: -200px;
  width: 540px;
  height: 540px;
  border: 1px solid rgba(255, 253, 248, 0.13);
  border-radius: 50%;
  pointer-events: none;
}

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 8px 13px;
  border: 1px solid rgba(255, 253, 248, 0.22);
  border-radius: 99px;
  background: rgba(13, 42, 34, 0.3);
  color: rgba(255, 253, 248, 0.8);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
}

.login-badge .icon {
  width: 13px;
  height: 13px;
}

.login-art-content {
  max-width: 640px;
  margin-block: auto;
  padding-block: 60px;
}

.login-art-content h1 {
  margin-top: 24px;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 5vw, 5rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1;
  text-wrap: balance;
}

.login-art-content p {
  max-width: 500px;
  margin-top: 24px;
  color: rgba(255, 253, 248, 0.68);
  font-size: 0.94rem;
  line-height: 1.75;
}

.login-art-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 26px;
  border-top: 1px solid rgba(255, 253, 248, 0.18);
}

.login-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 253, 248, 0.2);
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.1);
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.login-art-foot > span:last-child {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.login-art-foot strong {
  font-size: 0.78rem;
  font-weight: 700;
}

.login-art-foot small {
  color: rgba(255, 253, 248, 0.5);
  font-size: 0.64rem;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 44px;
  background:
    radial-gradient(circle at 0% 100%, rgba(201, 111, 77, 0.07), transparent 30%),
    var(--cream);
}

.login-card {
  width: min(100%, 430px);
}

.admin-brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--forest);
  color: var(--cream);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.04em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.admin-brand-mark-small {
  width: 38px;
  height: 38px;
  background: rgba(255, 253, 248, 0.1);
  color: var(--paper);
  font-size: 0.82rem;
}

.login-kicker {
  display: block;
  margin-top: 34px;
  color: var(--terracotta-dark);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.login-card h2 {
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.4vw, 2.7rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1.06;
}

.login-lead {
  margin-top: 14px;
  color: var(--ink-muted);
  font-size: 0.86rem;
  line-height: 1.65;
}

.login-card form {
  margin-top: 32px;
}

.login-status {
  display: none;
  margin: -2px 0 14px;
  padding: 11px 13px;
  border: 1px solid rgba(184, 70, 43, 0.22);
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
}

.login-status.is-visible {
  display: block;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  transform: translateY(-50%);
  cursor: pointer;
}

.password-toggle:hover {
  background: rgba(23, 37, 31, 0.05);
  color: var(--ink);
}

.password-toggle .icon {
  width: 16px;
  height: 16px;
}

.login-hint {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 0.67rem;
  line-height: 1.65;
}

.login-hint code {
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(23, 37, 31, 0.06);
  color: var(--ink-soft);
  font-size: 0.64rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

.back-link .icon {
  width: 13px;
  height: 13px;
  transform: rotate(180deg);
}

.back-link:hover {
  color: var(--terracotta-dark);
}

/* ---------------------------------- Shell ----------------------------------- */

.admin-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  background: var(--cream);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 0% 0%, rgba(216, 175, 113, 0.08), transparent 26%),
    linear-gradient(175deg, var(--forest) 0%, var(--forest-deep) 100%);
  color: var(--paper);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 10px 22px;
}

.sidebar-brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}

.sidebar-brand-copy strong {
  font-family: var(--font-display);
  font-size: 0.94rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.sidebar-brand-copy small {
  margin-top: 1px;
  color: rgba(255, 253, 248, 0.42);
  font-size: 0.57rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.sidebar-close {
  display: none;
  color: rgba(255, 253, 248, 0.55);
}

.sidebar-close:hover {
  background: rgba(255, 253, 248, 0.09);
  color: var(--paper);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-label {
  margin: 20px 12px 7px;
  color: rgba(255, 253, 248, 0.3);
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.sidebar-label:first-child {
  margin-top: 2px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 253, 248, 0.62);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition:
    background 180ms ease,
    color 180ms ease;
}

.nav-item .icon {
  width: 17px;
  height: 17px;
  color: rgba(255, 253, 248, 0.4);
  transition: color 180ms ease;
}

.nav-item:hover {
  background: rgba(255, 253, 248, 0.055);
  color: var(--paper);
}

.nav-item.is-active {
  background: rgba(255, 253, 248, 0.1);
  color: var(--paper);
}

.nav-item.is-active .icon {
  color: var(--gold);
}

.nav-count {
  min-width: 21px;
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 99px;
  background: rgba(255, 253, 248, 0.08);
  color: rgba(255, 253, 248, 0.55);
  font-size: 0.6rem;
  font-weight: 700;
  text-align: center;
}

.nav-count:empty {
  display: none;
}

.nav-count-alert {
  background: var(--terracotta);
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 253, 248, 0.1);
}

.sidebar-site-link,
.sidebar-logout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: rgba(255, 253, 248, 0.55);
  font-size: 0.7rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition:
    color 180ms ease,
    background 180ms ease;
}

.sidebar-site-link .icon,
.sidebar-logout .icon {
  width: 15px;
  height: 15px;
}

.sidebar-site-link:hover,
.sidebar-logout:hover {
  background: rgba(255, 253, 248, 0.055);
  color: var(--paper);
}

.sidebar-logout {
  margin-top: 2px;
}

.sidebar-backdrop {
  display: none;
}

.admin-main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 82px;
  padding: 16px clamp(20px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: rgba(245, 242, 234, 0.9);
  backdrop-filter: blur(16px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sidebar-toggle {
  display: none;
}

.topbar-titles {
  min-width: 0;
}

.topbar-titles > span {
  display: block;
  color: var(--ink-muted);
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-titles h1 {
  margin-top: 3px;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
}

.dirty-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-muted);
  font-size: 0.66rem;
  font-weight: 600;
  white-space: nowrap;
}

.dirty-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(201, 111, 77, 0.12);
}

.view-wrap {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(22px, 3vw, 36px);
}

.view {
  animation: view-in 280ms ease both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 4px;
}

.view-header h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.view-header p {
  max-width: 580px;
  margin-top: 7px;
  color: var(--ink-muted);
  font-size: 0.78rem;
  line-height: 1.65;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
}

/* ---------------------------------- Cards ----------------------------------- */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.panel-pad {
  padding: clamp(20px, 2.8vw, 28px);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.panel-head h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.panel-head p {
  margin-top: 4px;
  color: var(--ink-muted);
  font-size: 0.72rem;
  line-height: 1.55;
}

.panel-kicker {
  display: block;
  margin-bottom: 6px;
  color: var(--terracotta-dark);
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* -------------------------------- Overview ---------------------------------- */

.overview-welcome {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  overflow: hidden;
  padding: clamp(24px, 3.4vw, 38px);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 100% 0%, rgba(216, 175, 113, 0.2), transparent 34%),
    linear-gradient(145deg, var(--forest) 0%, var(--forest-deep) 100%);
  color: var(--paper);
}

.overview-welcome::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -170px;
  width: 360px;
  height: 360px;
  border: 1px solid rgba(255, 253, 248, 0.1);
  border-radius: 50%;
}

.overview-welcome-copy {
  position: relative;
  z-index: 1;
}

.overview-welcome .panel-kicker {
  color: var(--sage-mid);
}

.overview-welcome h2 {
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.8vw, 3rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1.03;
}

.overview-welcome p {
  max-width: 520px;
  margin-top: 12px;
  color: rgba(255, 253, 248, 0.62);
  font-size: 0.8rem;
  line-height: 1.65;
}

.overview-welcome-actions {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.overview-welcome .button-light {
  background: var(--paper);
  color: var(--forest);
}

.overview-welcome .button-light:hover {
  background: #fff;
}

.overview-welcome .button-ghost-light {
  border-color: rgba(255, 253, 248, 0.2);
  color: var(--paper);
}

.overview-welcome .button-ghost-light:hover {
  background: rgba(255, 253, 248, 0.08);
}

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

.stat-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 11px;
  background: var(--sage);
  color: var(--forest);
}

.stat-icon .icon {
  width: 17px;
  height: 17px;
}

.stat-card:nth-child(2) .stat-icon {
  background: #f3e8db;
  color: var(--terracotta-dark);
}

.stat-card:nth-child(3) .stat-icon {
  background: #edf0e9;
  color: var(--forest-soft);
}

.stat-card:nth-child(4) .stat-icon {
  background: #f7eedb;
  color: #92702f;
}

.stat-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-copy strong {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1;
}

.stat-copy span {
  margin-top: 5px;
  color: var(--ink-muted);
  font-size: 0.64rem;
  font-weight: 600;
  line-height: 1.35;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.8fr);
  gap: 20px;
  align-items: start;
}

.overview-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.recent-list {
  display: flex;
  flex-direction: column;
}

.recent-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.recent-row:hover {
  background: rgba(230, 236, 226, 0.42);
}

.recent-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.recent-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: var(--sage);
  color: var(--forest);
  font-family: var(--font-display);
  font-size: 0.78rem;
}

.recent-copy {
  flex: 1;
  min-width: 0;
}

.recent-copy strong {
  display: block;
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-copy span {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--ink-muted);
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-time {
  flex: none;
  color: var(--ink-muted);
  font-size: 0.58rem;
  white-space: nowrap;
}

.quick-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.quick-action:hover {
  background: var(--cream);
  color: var(--ink);
}

.quick-action .icon {
  width: 15px;
  height: 15px;
  color: var(--ink-muted);
}

.quick-action .icon:last-child {
  margin-left: auto;
  width: 12px;
  height: 12px;
}

.preview-card {
  overflow: hidden;
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 80% 20%, rgba(216, 175, 113, 0.15), transparent 35%),
    var(--forest);
  color: var(--paper);
  padding: 20px;
}

.preview-card span {
  color: var(--sage-mid);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.preview-card h4 {
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.preview-card h4 em {
  color: var(--gold);
  font-weight: 400;
}

.preview-card .button {
  margin-top: 18px;
  background: rgba(255, 253, 248, 0.12);
  color: var(--paper);
}

.preview-card .button:hover {
  background: rgba(255, 253, 248, 0.2);
}

/* ---------------------------------- Forms ----------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 0.67rem;
  font-weight: 700;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.field-label-row > span {
  margin-bottom: 6px;
  color: var(--ink-muted);
  font-size: 0.6rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fffefa;
  color: var(--ink);
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.5;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.field input {
  min-height: 40px;
}

.field textarea {
  min-height: 104px;
  resize: vertical;
}

.field select {
  min-height: 40px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237b857e' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.field input:hover,
.field textarea:hover,
.field select:hover {
  border-color: rgba(23, 37, 31, 0.3);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--forest-soft);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(23, 63, 51, 0.08);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #a5ada7;
}

.field-help {
  margin-top: 5px;
  color: var(--ink-muted);
  font-size: 0.6rem;
  line-height: 1.55;
}

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

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

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 16px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.5;
}

.checkbox-field input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--forest);
}

.checkbox-field span {
  display: flex;
  flex-direction: column;
}

.checkbox-field small {
  margin-top: 2px;
  color: var(--ink-muted);
  font-size: 0.6rem;
}

.section-form + .section-form {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.panel-subhead {
  margin-bottom: 18px;
}

.panel-subhead h4 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.panel-subhead p {
  margin-top: 3px;
  color: var(--ink-muted);
  font-size: 0.66rem;
}

/* ------------------------------- Image fields -------------------------------- */

.image-control {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.image-preview {
  position: relative;
  width: 150px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, var(--sage) 0%, var(--sand) 100%);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(23, 63, 51, 0.42);
}

.image-preview-empty .icon {
  width: 22px;
  height: 22px;
}

.image-control-fields {
  min-width: 0;
}

.image-control-fields input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fffefa;
  color: var(--ink);
  font-size: 0.7rem;
}

.image-control-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.image-control-buttons .button {
  min-height: 31px;
  padding: 7px 11px;
  font-size: 0.63rem;
}

.image-control-hint {
  margin-top: 7px;
  color: var(--ink-muted);
  font-size: 0.57rem;
  line-height: 1.5;
}

/* -------------------------------- Stats editor ------------------------------- */

.stats-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-edit-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
}

.stat-edit-row input {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fffefa;
  color: var(--ink);
  font-size: 0.72rem;
}

.stat-edit-row input:focus {
  outline: none;
  border-color: var(--forest-soft);
  box-shadow: 0 0 0 3px rgba(23, 63, 51, 0.08);
}

.stat-edit-row .icon-button {
  width: 34px;
  height: 34px;
}

.stats-add {
  align-self: flex-start;
  margin-top: 9px;
}

/* -------------------------------- Collections -------------------------------- */

.collection-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.entity-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.entity-row:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.entity-thumb {
  position: relative;
  width: 76px;
  height: 58px;
  flex: none;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--sage), var(--sand));
}

.entity-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.entity-thumb > .icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  color: rgba(23, 63, 51, 0.45);
  transform: translate(-50%, -50%);
}

.entity-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 11px;
  background: var(--sage);
  color: var(--forest);
}

.entity-icon .icon {
  width: 18px;
  height: 18px;
}

.entity-main {
  flex: 1;
  min-width: 0;
}

.entity-topline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.entity-topline strong {
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-meta {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--ink-muted);
  font-size: 0.65rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-quote {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 0.66rem;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.entity-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--sage);
  color: var(--forest-soft);
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.entity-badge-featured {
  background: #f7ead8;
  color: #8b6327;
}

.entity-badge-price {
  background: var(--forest);
  color: var(--paper);
}

.entity-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.entity-actions .icon-button {
  width: 32px;
  height: 32px;
}

.empty-state {
  padding: 38px 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  font-size: 0.72rem;
  line-height: 1.65;
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
}

.empty-state .button {
  margin-top: 14px;
}

/* -------------------------------- Messages ---------------------------------- */

.messages-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr);
  overflow: hidden;
  min-height: 560px;
}

#message-detail {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.message-list-pane {
  border-right: 1px solid var(--line);
  background: #fcfaf4;
}

.message-list-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.search-wrap {
  position: relative;
}

.search-wrap .icon {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--ink-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px 8px 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.7rem;
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--forest-soft);
  box-shadow: 0 0 0 3px rgba(23, 63, 51, 0.07);
}

.message-list {
  max-height: 610px;
  overflow-y: auto;
}

.message-row {
  position: relative;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid rgba(23, 37, 31, 0.07);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease;
}

.message-row:hover {
  background: rgba(230, 236, 226, 0.5);
}

.message-row.is-active {
  background: var(--sage);
}

.message-row.is-unread {
  background: rgba(255, 253, 248, 0.8);
}

.message-row.is-unread.is-active {
  background: var(--sage);
}

.message-row.is-unread::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--terracotta);
}

.message-avatar {
  width: 33px;
  height: 33px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: var(--sage);
  color: var(--forest);
  font-family: var(--font-display);
  font-size: 0.72rem;
}

.message-row.is-unread .message-avatar {
  background: var(--forest);
  color: var(--paper);
}

.message-row-copy {
  flex: 1;
  min-width: 0;
}

.message-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.message-row-top strong {
  overflow: hidden;
  font-size: 0.7rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-row-top time {
  flex: none;
  color: var(--ink-muted);
  font-size: 0.54rem;
}

.message-row-subject {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 0.64rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-row-preview {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--ink-muted);
  font-size: 0.6rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-detail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(20px, 3vw, 32px);
}

.message-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.message-detail-head h3 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.message-detail-from {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 14px;
}

.message-detail-from .message-avatar {
  width: 38px;
  height: 38px;
}

.message-detail-from > span:last-child {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}

.message-detail-from strong {
  font-size: 0.72rem;
}

.message-detail-from small {
  color: var(--ink-muted);
  font-size: 0.61rem;
}

.message-detail-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.message-meta span,
.message-meta a {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--ink-muted);
  font-size: 0.59rem;
}

.message-meta a:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.message-body {
  flex: 1;
  padding-top: 22px;
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-reply {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.message-empty-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 380px;
  color: var(--ink-muted);
  text-align: center;
}

.message-empty-detail .icon {
  width: 28px;
  height: 28px;
  margin-bottom: 12px;
  color: var(--sage-mid);
}

.message-empty-detail strong {
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
}

.message-empty-detail p {
  max-width: 300px;
  margin-top: 5px;
  font-size: 0.7rem;
  line-height: 1.65;
}

/* --------------------------------- Account ---------------------------------- */

.account-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.72fr);
  gap: 20px;
  align-items: start;
}

.account-profile {
  display: flex;
  align-items: center;
  gap: 15px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.account-avatar {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: var(--forest);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.account-profile strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.account-profile span {
  display: block;
  margin-top: 2px;
  color: var(--ink-muted);
  font-size: 0.64rem;
}

.security-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 20px;
  padding: 12px;
  border-radius: 10px;
  background: var(--cream);
  color: var(--ink-muted);
  font-size: 0.63rem;
  line-height: 1.6;
}

.security-note .icon {
  width: 15px;
  height: 15px;
  margin-top: 1px;
  color: var(--forest-soft);
}

.backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.backup-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.backup-row strong {
  display: block;
  font-size: 0.72rem;
}

.backup-row span {
  display: block;
  margin-top: 2px;
  color: var(--ink-muted);
  font-size: 0.62rem;
  line-height: 1.55;
}

.storage-note {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 0.6rem;
  line-height: 1.65;
}

.storage-note code {
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--cream);
  color: var(--ink-soft);
}

/* ---------------------------------- Modal ----------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(10, 26, 19, 0.54);
  backdrop-filter: blur(5px);
  animation: backdrop-in 180ms ease both;
}

.modal-backdrop.is-closing {
  animation: backdrop-out 160ms ease both;
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes backdrop-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.modal {
  width: min(100%, 680px);
  max-height: min(90vh, 850px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-xl);
  background: var(--paper);
  box-shadow: var(--shadow-lg);
  animation: modal-in 220ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.modal.is-small {
  width: min(100%, 460px);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--terracotta-dark);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.modal-head h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.modal-body {
  padding: 22px 26px;
  overflow-y: auto;
}

.modal-body > p {
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.75;
}

.modal-body .confirm-callout {
  margin-top: 14px;
  padding: 13px;
  border: 1px solid rgba(184, 70, 43, 0.16);
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.68rem;
  line-height: 1.6;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 16px 26px 22px;
  border-top: 1px solid var(--line);
}

.modal-error {
  display: none;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(184, 70, 43, 0.2);
  border-radius: 9px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.68rem;
  line-height: 1.55;
}

.modal-error.is-visible {
  display: block;
}

/* ---------------------------------- Toasts ---------------------------------- */

.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 360px;
  padding: 11px 14px;
  border: 1px solid rgba(23, 63, 51, 0.12);
  border-radius: 11px;
  background: var(--forest);
  color: var(--paper);
  box-shadow: 0 12px 35px rgba(12, 32, 24, 0.22);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in 240ms ease both;
}

.toast.is-error {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--danger);
}

.toast.is-leaving {
  animation: toast-out 180ms ease both;
}

.toast .icon {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--gold);
}

.toast.is-error .icon {
  color: #ffd9cb;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------------------------------- Loader ---------------------------------- */

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(216, 175, 113, 0.1), transparent 26%),
    var(--forest-deep);
}

.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--paper);
}

.boot-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 253, 248, 0.2);
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.08);
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.boot-inner span {
  color: rgba(255, 253, 248, 0.55);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.boot-line {
  width: 80px;
  height: 2px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 253, 248, 0.15);
}

.boot-line::after {
  content: "";
  display: block;
  width: 45%;
  height: 100%;
  background: var(--gold);
  animation: boot-progress 1.1s ease-in-out infinite;
}

@keyframes boot-progress {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(260%);
  }
}

/* --------------------------------- Responsive -------------------------------- */

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

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

  .overview-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .overview-side .panel:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1024px) {
  .admin-app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 80;
    width: 280px;
    transform: translateX(-101%);
    transition: transform 230ms cubic-bezier(0.2, 0.7, 0.2, 1);
    box-shadow: var(--shadow-lg);
  }

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

  .sidebar-close {
    display: inline-grid;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    background: rgba(9, 25, 18, 0.45);
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 200ms ease,
      visibility 200ms ease;
  }

  .sidebar-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
  }

  .sidebar-toggle {
    display: inline-grid;
    border-color: var(--line);
    background: var(--paper);
  }

  .login-view {
    grid-template-columns: 1fr;
  }

  .login-art {
    min-height: 300px;
    padding: 32px;
  }

  .login-art-content {
    padding-block: 30px;
  }

  .login-art-content h1 {
    max-width: 560px;
    font-size: clamp(2rem, 5.4vw, 3rem);
  }

  .login-art-content p {
    display: none;
  }

  .login-art-foot {
    display: none;
  }

  .login-panel {
    min-height: auto;
    padding: 46px 28px 64px;
  }
}

@media (max-width: 820px) {
  .messages-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .message-list-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .message-list {
    max-height: 290px;
  }

  .message-detail {
    min-height: 360px;
  }

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

  .overview-welcome {
    align-items: flex-start;
    flex-direction: column;
  }

  .overview-side {
    grid-template-columns: 1fr;
  }

  .overview-side .panel:last-child {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 72px;
    padding: 12px 16px;
  }

  .topbar-titles h1 {
    font-size: 1.3rem;
  }

  .dirty-indicator {
    display: none !important;
  }

  .view-wrap {
    padding: 18px 14px 28px;
  }

  .view-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .view-actions {
    width: 100%;
  }

  .view-actions .button {
    flex: 1;
  }

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

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

  .image-control {
    grid-template-columns: 1fr;
  }

  .image-preview {
    width: 100%;
    max-width: 220px;
  }

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

  .stat-card {
    padding: 14px;
    gap: 10px;
  }

  .stat-icon {
    width: 32px;
    height: 32px;
  }

  .stat-copy strong {
    font-size: 1.45rem;
  }

  .entity-thumb {
    width: 58px;
    height: 48px;
  }

  .entity-icon {
    width: 36px;
    height: 36px;
  }

  .entity-row {
    gap: 10px;
    padding: 10px;
  }

  .entity-actions {
    flex-direction: column;
  }

  .entity-actions .icon-button {
    width: 29px;
    height: 29px;
  }

  .entity-quote {
    display: none;
  }

  .modal-backdrop {
    padding: 12px;
    align-items: end;
  }

  .modal {
    max-height: 92vh;
    border-radius: 24px;
  }

  .modal-head {
    padding: 20px 20px 15px;
  }

  .modal-body {
    padding: 18px 20px;
  }

  .modal-foot {
    padding: 14px 20px 18px;
  }

  .modal-foot .button {
    flex: 1;
  }

  .message-detail-head {
    flex-direction: column;
  }

  .message-detail-actions {
    align-self: flex-end;
  }

  .toast-stack {
    left: 14px;
    right: 14px;
    bottom: 14px;
    align-items: stretch;
  }

  .toast {
    max-width: none;
  }
}

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

  .login-art {
    min-height: 250px;
    padding: 24px;
  }

  .login-art-content h1 {
    font-size: 1.9rem;
  }

  .login-panel {
    padding: 36px 20px 54px;
  }

  .login-card h2 {
    font-size: 2rem;
  }

  .view-header h2 {
    font-size: 1.4rem;
  }

  .overview-welcome {
    padding: 24px 20px;
  }

  .overview-welcome-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------- Bilingual field helpers (v2) ---------------------- */

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

.loc-control {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.loc-badge {
  align-self: flex-start;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(23, 63, 51, 0.09);
  color: var(--forest-soft);
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.5;
}

.loc-badge-en {
  background: rgba(201, 111, 77, 0.13);
  color: var(--terracotta-dark, #a85638);
}

.loc-control input,
.loc-control textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fffefa;
  color: var(--ink);
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.5;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.loc-control input {
  min-height: 40px;
}

.loc-control textarea {
  min-height: 104px;
  resize: vertical;
}

.loc-control input:hover,
.loc-control textarea:hover {
  border-color: rgba(23, 37, 31, 0.3);
}

.loc-control input:focus,
.loc-control textarea:focus {
  outline: none;
  border-color: var(--forest-soft);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(23, 63, 51, 0.08);
}

.loc-control input::placeholder,
.loc-control textarea::placeholder {
  color: #a5ada7;
}

.loc-stat-row {
  grid-template-columns: 90px minmax(0, 1fr) minmax(0, 1fr) 34px;
}

/* -------------------------------- Facts editor ------------------------------- */

.facts-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fact-edit-labels,
.fact-edit-row {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 0.9fr) minmax(0, 1.4fr) minmax(0, 1.4fr) 34px;
  gap: 8px;
  align-items: center;
}

.fact-edit-labels span {
  color: var(--ink-muted);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fact-edit-row input {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fffefa;
  color: var(--ink);
  font-size: 0.72rem;
}

.fact-edit-row input:focus {
  outline: none;
  border-color: var(--forest-soft);
  box-shadow: 0 0 0 3px rgba(23, 63, 51, 0.08);
}

.fact-edit-row .icon-button {
  width: 34px;
  height: 34px;
}

@media (max-width: 900px) {
  .loc-pair {
    grid-template-columns: 1fr;
  }

  .stat-edit-row,
  .loc-stat-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px;
  }

  .loc-stat-row input:first-child {
    grid-column: 1 / -1;
  }

  .fact-edit-labels {
    display: none;
  }

  .fact-edit-row {
    grid-template-columns: 1fr 1fr;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
  }

  .fact-edit-row .icon-button {
    justify-self: end;
  }
}
