:root {
  --ivory: #f7f4ec;
  --paper: #fffdf8;
  --forest: #173d32;
  --forest-soft: #2d594b;
  --ink: #27342f;
  --muted: #66746d;
  --terracotta: #b97862;
  --line: #dfd5c6;
  --sage-light: #e6eee4;
  --danger: #a94235;
  --shadow: 0 18px 48px rgba(23, 61, 50, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 2% 0, rgba(168, 187, 167, 0.18), transparent 24rem),
    var(--ivory);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, .admin-button { -webkit-tap-highlight-color: transparent; }

.admin-header {
  position: sticky;
  z-index: 50;
  top: 0;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 0 max(28px, calc((100vw - 1420px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(18px);
}

.admin-brand {
  color: var(--forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  letter-spacing: -0.045em;
  text-decoration: none;
  white-space: nowrap;
}

.admin-brand > span { color: var(--terracotta); }
.admin-brand small {
  margin-left: 7px;
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.admin-nav a,
.admin-nav button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 650;
  text-decoration: none;
}

.admin-nav a:hover,
.admin-nav button:hover,
.admin-nav a.is-active {
  background: var(--sage-light);
  color: var(--forest);
}

.admin-nav form { margin: 0; }
.admin-nav-toggle { display: none; }

.admin-main {
  width: min(100% - 56px, 1420px);
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  padding: 50px 0 90px;
}

.admin-main.is-auth {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 36px;
  margin-bottom: 30px;
}

.page-heading h1,
.login-card h1 {
  margin: 0;
  color: var(--forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 4vw, 4rem);
  font-weight: 500;
  letter-spacing: -0.05em;
}

.page-heading p:not(.eyebrow) {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--terracotta);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.admin-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--forest);
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

.admin-button.primary { background: var(--forest); color: white; }
.admin-button.primary:hover { background: var(--forest-soft); }
.admin-button.secondary { background: var(--paper); color: var(--forest); }
.admin-button:disabled { cursor: not-allowed; opacity: 0.45; }
.admin-button.wide { width: 100%; }

.flash {
  margin: 0 0 22px;
  border: 1px solid;
  border-radius: 16px;
  padding: 14px 18px;
  line-height: 1.5;
}

.flash ul { margin: 8px 0 0; padding-left: 22px; }
.flash-success { border-color: #b8d2bd; background: #eaf4e9; color: #285735; }
.flash-error { border-color: #e0b9b2; background: #fff0ed; color: #7e342a; }

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

.stat-grid article {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px;
  background: var(--paper);
  box-shadow: 0 10px 30px rgba(23, 61, 50, 0.05);
}

.stat-grid span { color: var(--muted); font-size: 0.88rem; }
.stat-grid strong { color: var(--forest); font-family: Georgia, serif; font-size: 2.2rem; font-weight: 500; }

.panel,
.form-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.panel { overflow: hidden; }

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 25px 28px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 { margin: 0; color: var(--forest); font-family: Georgia, serif; font-weight: 500; }
.panel-head a { color: var(--forest); font-weight: 700; text-decoration: none; }
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  padding: 13px 20px;
  background: #f2ede4;
  color: var(--muted);
  font-size: 0.73rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  padding: 16px 20px;
  border-top: 1px solid #ebe3d7;
  vertical-align: middle;
}

tbody tr:first-child td { border-top: 0; }
td strong { display: block; color: var(--forest); }
td small { display: block; margin-top: 4px; color: var(--muted); }
td.actions { text-align: right; }
td.actions a { color: var(--forest); font-weight: 700; text-decoration: none; }
code { color: #7a5547; }

.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 750;
  white-space: nowrap;
}

.status.active { background: #e3f0e4; color: #2e6539; }
.status.inactive { background: #eeeae4; color: #716d66; }
.empty-state { padding: 54px 28px; color: var(--muted); text-align: center; }

.product-cell {
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.product-cell img,
.image-placeholder {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  object-fit: cover;
}

.image-placeholder {
  display: grid;
  place-items: center;
  background: var(--sage-light);
  color: var(--forest);
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.filter-bar input { min-width: min(430px, 45vw); }
.filter-bar a { color: var(--muted); font-size: 0.9rem; }

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfc4b4;
  border-radius: 12px;
  padding: 11px 13px;
  background: white;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(23, 61, 50, 0.1);
}

textarea { resize: vertical; line-height: 1.55; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.pager a { color: var(--forest); font-weight: 700; text-decoration: none; }

.admin-form { display: grid; gap: 22px; }
.form-card { padding: clamp(24px, 3vw, 38px); }
.compact-form { max-width: 960px; }

.admin-form label {
  display: grid;
  gap: 7px;
  color: var(--forest);
  font-size: 0.9rem;
  font-weight: 700;
}

.admin-form label > small,
.form-note {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.5;
}

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

.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.section-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.section-heading > span {
  width: 40px;
  height: 40px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--sage-light);
  color: var(--forest);
  font-weight: 800;
}

.section-heading h2 { margin: 0; color: var(--forest); font-family: Georgia, serif; font-size: 1.55rem; font-weight: 500; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 0.86rem; }

fieldset {
  margin: 2px 0 0;
  border: 0;
  padding: 0;
}

legend {
  margin-bottom: 10px;
  color: var(--forest);
  font-size: 0.9rem;
  font-weight: 750;
}

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

.admin-form .choice {
  position: relative;
  display: block;
  cursor: pointer;
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice span {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: white;
  color: var(--muted);
  text-align: center;
}

.choice input:checked + span {
  border-color: var(--forest);
  background: var(--sage-light);
  color: var(--forest);
  box-shadow: inset 0 0 0 1px var(--forest);
}

.admin-form .check-row,
.admin-form .switch-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
}

.check-row input,
.switch-row input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--forest);
}

.switch-row {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fffefa;
}

.switch-row span { display: grid; gap: 3px; }
.switch-row strong { color: var(--forest); }
.switch-row small { color: var(--muted); font-weight: 400; }

.current-image {
  display: flex;
  align-items: center;
  gap: 18px;
}

.current-image img {
  width: 110px;
  height: 110px;
  border: 1px solid var(--line);
  border-radius: 16px;
  object-fit: cover;
}

.form-actions,
.sticky-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.sticky-actions {
  position: sticky;
  z-index: 20;
  bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px;
  background: rgba(255, 253, 248, 0.95);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 32px;
  border: 1px solid #dfb8b1;
  border-radius: 18px;
  padding: 20px 24px;
  background: #fff6f4;
}

.danger-zone strong { color: var(--danger); }
.danger-zone p { margin: 5px 0 0; color: #80645f; font-size: 0.86rem; }
.danger-zone button { border: 1px solid var(--danger); border-radius: 999px; padding: 9px 15px; background: white; color: var(--danger); cursor: pointer; font-weight: 700; }

.login-card {
  width: min(100%, 470px);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: clamp(28px, 5vw, 48px);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.login-brand { display: inline-block; margin-bottom: 42px; }
.login-card h1 { font-size: 3rem; }
.login-intro { margin: 12px 0 28px; color: var(--muted); line-height: 1.55; }

@media (max-width: 1000px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid.three { grid-template-columns: 1fr 1fr; }
  .choice-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-nav-toggle {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 9px 14px;
    background: white;
    color: var(--forest);
    font-weight: 700;
  }
  .admin-nav {
    position: absolute;
    top: calc(100% + 1px);
    right: 18px;
    left: 18px;
    display: none;
    align-items: stretch;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 10px;
    background: var(--paper);
    box-shadow: var(--shadow);
  }
  .admin-nav.is-open { display: flex; }
  .admin-nav a, .admin-nav button { width: 100%; text-align: left; }
}

@media (max-width: 700px) {
  .admin-main { width: min(100% - 28px, 1420px); padding-top: 30px; }
  .admin-header { min-height: 66px; padding: 0 16px; }
  .admin-brand { font-size: 1.38rem; }
  .admin-brand small { display: none; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 18px; }
  .page-heading .admin-button { align-self: flex-start; }
  .stat-grid, .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar input { min-width: 0; }
  .form-card { border-radius: 18px; }
  .danger-zone { align-items: flex-start; flex-direction: column; }
  .sticky-actions { bottom: 8px; }
}
