:root {
    --ivory: #fbf8f3;
    --cream: #f4ece0;
    --beige: #efe4d4;
    --sage: #7f8f6d;
    --sage-soft: #e8ecdf;
    --gold: #c9a86a;
    --gold-dark: #ad8c4d;
    --ink: #3d362c;
    --muted: #837a6b;
    --line: #e6ddcd;
    --white: #fff;
    --danger: #b5533f;
    --shadow: 0 14px 40px -28px rgba(61,54,44,.5);
    --serif: 'Cormorant Garamond', Georgia, serif;
    --sans: 'Jost', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body.admin, body.admin-auth {
    font-family: var(--sans);
    color: var(--ink);
    background: var(--cream);
    font-weight: 300;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; margin: 0 0 .5rem; line-height: 1.2; }
a { color: var(--gold-dark); }
.muted { color: var(--muted); }
.tiny { font-size: .78rem; }
.card { background: #fff; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); }

/* ---------------- Auth ---------------- */
.admin-auth { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; background: radial-gradient(120% 100% at 50% 0%, #fffaf1, var(--cream)); }
.auth-card { width: min(420px, 100%); padding: 2.4rem; text-align: center; }
.auth-monogram { display: block; font-size: 1.8rem; color: var(--gold); }
.auth-title { font-size: 1.9rem; margin-top: .4rem; }
.auth-sub { margin-top: -.4rem; margin-bottom: 1.4rem; }
.auth-foot { margin-top: 1.2rem; font-size: .85rem; }
.admin-auth form { text-align: left; }

/* ---------------- Layout ---------------- */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 268px;
    background: #2f2a23;
    color: #eee6d8;
    display: flex; flex-direction: column;
    padding: 1.4rem 1.1rem;
    z-index: 40;
    transition: transform .3s ease;
}
.sidebar__brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.6rem; }
.sidebar__monogram { font-size: 1.7rem; color: var(--gold); }
.sidebar__brand strong { display: block; font-family: var(--serif); font-size: 1.15rem; color: #fff; }
.sidebar__brand small { color: #b3a897; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.sidebar__nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.sidebar__nav a {
    color: #d9cfc0; text-decoration: none; padding: .7rem .9rem; border-radius: 10px;
    font-size: .9rem; transition: background .2s ease, color .2s ease;
}
.sidebar__nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar__nav a.is-active { background: var(--gold); color: #2f2a23; font-weight: 500; }
.sidebar__foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: 1rem; display: flex; flex-direction: column; gap: .4rem; }
.sidebar__foot .muted { color: #9c927f; font-size: .74rem; }
.sidebar__foot strong { color: #fff; font-weight: 500; }
.sidebar-toggle { display: none; position: fixed; top: .8rem; left: .8rem; z-index: 60; background: #2f2a23; color: #fff; border: 0; border-radius: 10px; padding: .5rem .7rem; font-size: 1.2rem; cursor: pointer; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }

.admin-main { margin-left: 268px; min-height: 100vh; display: flex; flex-direction: column; }
.admin-topbar { padding: 1.6rem 2rem 0; }
.admin-topbar h1 { font-size: 2rem; }
.admin-content { padding: 1.2rem 2rem 2.5rem; flex: 1; }
.admin-footer { padding: 1rem 2rem; text-align: center; }
.flash-stack { padding: 0 2rem; }

/* ---------------- Grids ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.2rem; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--gold); }
.stat--sage::before { background: var(--sage); }
.stat--danger::before { background: var(--danger); }
.stat__value { font-family: var(--serif); font-size: 2.1rem; line-height: 1; }
.stat__label { text-transform: uppercase; letter-spacing: .12em; font-size: .68rem; color: var(--muted); margin-top: .35rem; }
.stat__hint { font-size: .74rem; color: var(--muted); margin-top: .3rem; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.4rem; box-shadow: var(--shadow); margin-bottom: 1.4rem; }
.panel__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.panel__head h2, .panel__head h3 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 1rem; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; background: #fff; }
th, td { text-align: left; padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { background: #faf6ef; text-transform: uppercase; letter-spacing: .08em; font-size: .68rem; color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fdfaf5; }
td.wrap { white-space: normal; min-width: 180px; }

/* ---------------- Badges ---------------- */
.badge { display: inline-block; padding: .18rem .55rem; border-radius: 999px; font-size: .72rem; letter-spacing: .04em; border: 1px solid transparent; }
.badge-attending { background: #eaf2e0; color: #4a5f34; border-color: #c6dbaf; }
.badge-declined { background: #fbeee9; color: #8a3f2b; border-color: #e8c3b6; }
.badge-pending { background: #fdf4e2; color: #7a5f1e; border-color: #ecd9a6; }
.badge-sent { background: #eaf0f6; color: #355268; border-color: #c8d6e2; }
.badge-muted { background: #f0ede7; color: #7d7466; border-color: #e0d8cb; }

/* ---------------- Forms ---------------- */
label { display: block; font-size: .82rem; color: #5a5143; margin-bottom: .7rem; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=time], input[type=url], select, textarea {
    width: 100%; padding: .65rem .8rem; margin-top: .3rem;
    border: 1px solid var(--line); border-radius: 9px; background: #fffdf9;
    font-family: var(--sans); font-size: .92rem; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,106,.16); }
textarea { resize: vertical; min-height: 70px; }
.form-inline { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.form-inline > * { margin-bottom: 0; }
.stack label { margin-bottom: .9rem; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .62rem 1.2rem; border-radius: 999px; border: 1px solid transparent;
    font-family: var(--sans); font-size: .82rem; letter-spacing: .06em;
    cursor: pointer; text-decoration: none; transition: transform .15s ease, background .2s ease, color .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover { background: var(--gold-dark); }
.btn-outline { background: transparent; border-color: var(--gold); color: var(--gold-dark); }
.btn-outline:hover { background: var(--gold); color: #fff; }
.btn-ghost { background: #f4efe6; color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: .38rem .8rem; font-size: .74rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

.invite-url { display: flex; gap: .5rem; align-items: stretch; }
.invite-url input { flex: 1; min-width: 0; }

.slug-field { display: flex; align-items: stretch; border: 1px solid var(--line, #e7ddcd); border-radius: 10px; overflow: hidden; background: #fff; max-width: 34rem; }
.slug-field__prefix { display: inline-flex; align-items: center; padding: 0 .6rem; background: #f5efe4; color: #7c7364; font-size: .9rem; white-space: nowrap; border-right: 1px solid var(--line, #e7ddcd); }
.slug-field input { border: 0; border-radius: 0; flex: 1; min-width: 0; }
.tiny { font-size: .8rem; }

/* ---------------- Alerts ---------------- */
.alert { padding: .8rem 1.05rem; border-radius: 10px; margin: 0 0 .9rem; font-size: .9rem; border: 1px solid transparent; }
.alert-success { background: #eef4e8; border-color: #c6dbaf; color: #4a5f34; }
.alert-error { background: #fbeee9; border-color: #e8c3b6; color: #8a3f2b; }
.alert-info { background: #eef2f6; border-color: #c8d6e2; color: #355268; }
.alert-warn { background: #fbf4e4; border-color: #ecd9a6; color: #7a5f1e; }

/* ---------------- Filters ---------------- */
.filters { display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters label { margin: 0; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip { padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; text-decoration: none; color: var(--muted); font-size: .78rem; }
.chip.is-active { background: var(--gold); color: #fff; border-color: var(--gold); }

/* ---------------- Misc ---------------- */
.progress { height: 8px; background: var(--beige); border-radius: 999px; overflow: hidden; margin-top: .5rem; }
.progress span { display: block; height: 100%; background: var(--sage); }
.invite-link { display: flex; gap: .4rem; align-items: center; }
.invite-link input { font-size: .78rem; }
.detail-list { list-style: none; padding: 0; margin: 0; }
.detail-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.detail-list li:last-child { border-bottom: 0; }
.detail-list span { color: var(--muted); }
.empty { text-align: center; padding: 2.6rem 1rem; color: var(--muted); }
.empty h3 { color: var(--ink); }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; flex-wrap: wrap; }
.tabs a { padding: .6rem 1rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-size: .88rem; }
.tabs a.is-active { color: var(--gold-dark); border-color: var(--gold); }
.repeat-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; margin-bottom: .5rem; align-items: start; }
.repeat-row textarea { min-height: 44px; }
.hp { position: absolute; left: -9999px; }
.section-mini { font-size: 1.05rem; margin: 1.2rem 0 .6rem; color: var(--sage); text-transform: uppercase; letter-spacing: .12em; font-family: var(--sans); font-size: .74rem; }
.img-preview { width: 90px; height: 90px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--beige); }
.media-row { display: flex; gap: 1rem; align-items: center; }
.help { font-size: .76rem; color: var(--muted); margin-top: .2rem; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.is-open { transform: none; }
    .sidebar-toggle { display: block; }
    .admin-main { margin-left: 0; }
    .admin-topbar { padding: 1.2rem 1.1rem 0; padding-top: 3.4rem; }
    .admin-content, .flash-stack { padding-left: 1.1rem; padding-right: 1.1rem; }
    .grid-2 { grid-template-columns: 1fr; }
}

/* ---------------- Checkboxes & row menus ---------------- */
label.checkbox { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
label.checkbox input { width: auto; margin: 0; }
.rowmenu { position: relative; }
.rowmenu summary { list-style: none; cursor: pointer; display: inline-flex; }
.rowmenu summary::-webkit-details-marker { display: none; }
.rowmenu[open] summary { background: var(--beige); }
.rowmenu__panel {
    position: absolute; right: 0; top: 110%; z-index: 20;
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    box-shadow: var(--shadow); min-width: 200px; padding: .4rem;
    display: flex; flex-direction: column;
}
.rowmenu__item {
    display: block; width: 100%; text-align: left; padding: .5rem .7rem;
    border: 0; background: none; color: var(--ink); text-decoration: none;
    font-size: .84rem; border-radius: 7px; cursor: pointer; font-family: var(--sans);
}
.rowmenu__item:hover { background: var(--beige); }
.rowmenu__item--danger { color: var(--danger); }
