:root {
  --wine: #7a1e3c;
  --wine-deep: #4f1024;
  --gold: #d9822e;
  --gold-soft: #f4d5a8;
  --ink: #1c1418;
  --muted: #6d5c63;
  --line: #eadfe4;
  --paper: #f7f2f4;
  --white: #fff;
  --ok: #1f7a4d;
  --err: #b42318;
  --shadow: 0 18px 40px rgba(79, 16, 36, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Manrope, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

h1, h2, h3 { font-family: "Source Serif 4", Georgia, serif; margin: 0 0 .4rem; }
p { margin: 0; color: var(--muted); }
a { color: var(--wine); text-decoration: none; }
code { background: #f3e8ec; padding: .1rem .35rem; border-radius: 4px; font-size: .85em; }

.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--wine-deep), var(--wine));
  color: #fff;
  padding: 1.4rem 1rem;
}
.sidebar__brand { display: flex; gap: .8rem; align-items: center; color: #fff; margin-bottom: 1.6rem; }
.sidebar__mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--gold); color: #3b1b08; font-weight: 800;
}
.sidebar__brand small { display: block; opacity: .75; font-size: .72rem; }
.sidebar__nav { display: grid; gap: .2rem; }
.sidebar__nav p {
  color: var(--gold-soft); font-size: .7rem; letter-spacing: .12em;
  text-transform: uppercase; margin: 1rem 0 .35rem; padding: 0 .7rem;
}
.sidebar__nav a {
  color: rgba(255,255,255,.86); padding: .62rem .75rem; border-radius: 10px;
}
.sidebar__nav a:hover, .sidebar__nav a.is-active { background: rgba(255,255,255,.12); color: #fff; }

.shell { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1rem 1.5rem; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar__user { display: flex; align-items: center; gap: .8rem; font-weight: 600; }
.page { padding: 1.5rem; max-width: 1180px; }
.page-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1.2rem; }
.page-head h1 { font-size: 2rem; }
.eyebrow { color: var(--gold); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .75rem; }

.global-search { position: relative; flex: 1; max-width: 520px; }
.global-search svg { position: absolute; left: 12px; top: 50%; width: 18px; transform: translateY(-50%); color: var(--muted); }
.global-search input {
  width: 100%; border: 1px solid var(--line); border-radius: 999px; padding: .7rem 1rem .7rem 2.4rem;
  font: inherit; background: #fbf7f8;
}
.global-search__results {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px);
  background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: .5rem; max-height: 380px; overflow: auto;
}
.global-search__results[hidden] { display: none; }
.search-group { padding: .4rem .5rem .2rem; }
.search-group strong { display: block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .25rem; }
.search-group a { display: block; padding: .45rem .5rem; border-radius: 8px; color: inherit; }
.search-group a:hover { background: var(--paper); }
.search-group small { display: block; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 0; border-radius: 999px; padding: .7rem 1.1rem; font: inherit; font-weight: 700; cursor: pointer;
}
.btn--gold { background: var(--gold); color: #3b1b08; }
.btn--ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn--sm { padding: .4rem .75rem; font-size: .85rem; }
.btn--lg { padding: .85rem 1.2rem; }
.btn--block { width: 100%; }

.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat-card {
  background: #fff; border-radius: 18px; padding: 1.1rem; box-shadow: var(--shadow); color: inherit;
  display: grid; gap: .2rem;
}
.stat-card strong { font-size: 2rem; font-family: "Source Serif 4", serif; }
.stat-card--wine { border-top: 4px solid var(--wine); }
.stat-card--gold { border-top: 4px solid var(--gold); }

.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.card { background: #fff; border-radius: 18px; padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.plain-list small, .muted { color: var(--muted); display: block; }
.block { display: block; color: var(--muted); }

.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input, .toolbar select, label input, label select, label textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; font: inherit; background: #fff;
}
.toolbar input, .toolbar select { width: auto; min-width: 180px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .85rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.media-cell { display: flex; gap: .75rem; align-items: center; }
.media-cell img { width: 58px; height: 42px; object-fit: cover; border-radius: 8px; }
.row-actions { display: flex; gap: .7rem; white-space: nowrap; }
.link-danger { background: none; border: 0; color: var(--err); font: inherit; cursor: pointer; padding: 0; }
.empty { text-align: center; color: var(--muted); padding: 2rem !important; }
.pager { display: flex; justify-content: space-between; padding-top: .8rem; color: var(--muted); }

.badge { display: inline-block; border-radius: 999px; padding: .15rem .55rem; font-size: .75rem; font-weight: 700; }
.badge--ok, .badge--published { background: #e7f6ee; color: var(--ok); }
.badge--muted, .badge--draft, .badge--closed { background: #f1eaed; color: var(--muted); }
.badge--new { background: #fff4e6; color: #9a4d00; }
.badge--contacted { background: #e8eefc; color: #274690; }

.form-stack { display: grid; gap: 1rem; max-width: 920px; }
.form-card { background: #fff; border-radius: 18px; padding: 1.2rem; box-shadow: var(--shadow); }
.form-card h3 { margin-bottom: .3rem; }
.help { margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: .35rem; font-weight: 600; font-size: .92rem; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.check input { width: auto; }
.thumb { margin-top: .6rem; border-radius: 12px; max-width: 220px; }
.thumb--wide { width: 220px; height: 130px; object-fit: cover; }
.ck-editor__editable { min-height: 280px; }

.flash { padding: .8rem 1rem; border-radius: 12px; margin-bottom: 1rem; }
.flash--ok { background: #e7f6ee; color: var(--ok); }
.flash--err { background: #fdecea; color: var(--err); }
.field-error { color: var(--err); font-size: .85rem; }
.detail-card dl { display: grid; gap: .7rem; }
.detail-card dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.detail-card dd { margin: .15rem 0 0; font-weight: 600; }
.message-box { margin-top: 1rem; background: var(--paper); padding: 1rem; border-radius: 12px; color: var(--ink); }

.auth-body {
  min-height: 100vh;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--wine-deep), var(--wine) 55%, #9a3a2a);
}
.login { width: min(460px, calc(100% - 2rem)); }
.login__panel { background: #fff; border-radius: 24px; padding: 2rem; box-shadow: var(--shadow); }
.login h1 { font-size: 2.2rem; }
.login__lead { margin: .4rem 0 1.3rem; }
.login__form { display: grid; gap: .8rem; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .split-grid, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 30; }
  .sidebar__nav { grid-template-columns: 1fr 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
  .page-head { flex-direction: column; }
}
