/* Free Amir Tataloo — admin panel theme. Self-contained, no build step.
   Brand: maroon accent on warm ivory, ink text. */
:root {
  --maroon: #981b2b;
  --maroon-2: #7d1622;
  --maroon-3: #4b0c16;
  --maroon-tint: #f6e7e5;
  --ivory: #f8f4ee;
  --ivory-2: #efe7db;
  --paper: #ffffff;
  --ink: #171412;
  --ink-2: #423b34;
  --ink-3: #6a635b;
  --line: #e7ddcd;
  --line-2: #d9cdba;
  --ok: #1f7a4d;
  --ok-bg: #e4f2ea;
  --warn: #9a6b00;
  --warn-bg: #f7edd6;
  --info: #1d4ae8;
  --info-bg: #e5ecfb;
  --danger: #b0142b;
  --danger-bg: #fbe6e8;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(23,20,18,.05), 0 4px 16px rgba(23,20,18,.05);
  --sidebar-w: 264px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); color: var(--ink); background: var(--ivory);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--maroon); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
img { max-width: 100%; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--maroon-3); color: #f4e9e2;
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40;
  transform: translateX(0); transition: transform .2s ease;
}
.sidebar__brand { display: flex; align-items: center; gap: .6rem; padding: 1.05rem 1.15rem; border-bottom: 1px solid rgba(255,255,255,.09); }
.sidebar__mark { width: 30px; height: 30px; border-radius: 7px; background: var(--maroon); display: grid; place-items: center; font-weight: 800; color: #fff; flex-shrink: 0; }
.sidebar__name { font-weight: 700; font-size: .95rem; color: #fff; line-height: 1.1; }
.sidebar__name small { display: block; font-weight: 500; font-size: .72rem; color: #d9b7b7; letter-spacing: .02em; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: .75rem .7rem 2rem; }
.navgroup { margin-top: 1.1rem; }
.navgroup:first-child { margin-top: .25rem; }
.navgroup__label { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: #cf9ea0; padding: 0 .55rem .3rem; font-weight: 700; }
.navlink { position: relative; display: flex; align-items: center; gap: .6rem; padding: .55rem .65rem; border-radius: var(--radius-sm); color: #ecd8d3; font-weight: 500; font-size: .9rem; margin-bottom: 1px; transition: background .16s ease, color .16s ease; }
.navlink:hover { background: rgba(255,255,255,.09); text-decoration: none; color: #fff; }
.navlink.is-active { background: var(--maroon); color: #fff; font-weight: 600; }
.navlink.is-active::before { content: ""; position: absolute; left: -.7rem; top: .35rem; bottom: .35rem; width: 3px; border-radius: 0 3px 3px 0; background: #fff; }
.navlink:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.navlink svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .95; }
.navlink .badge { margin-left: auto; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar {
  height: 62px; background: var(--paper); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem; padding: 0 1.4rem; position: sticky; top: 0; z-index: 30;
}
.topbar__title { font-size: 1.05rem; font-weight: 700; }
.topbar__crumbs { font-size: .8rem; color: var(--ink-3); }
.topbar__crumbs a { color: var(--ink-3); }
.topbar__spacer { flex: 1; }
.topbar__user { display: flex; align-items: center; gap: .6rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--maroon-tint); color: var(--maroon-2); display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.menu-toggle { display: none; background: none; border: 1px solid var(--line-2); border-radius: 8px; width: 40px; height: 40px; cursor: pointer; }
.avatar--lg { width: 40px; height: 40px; font-size: .9rem; }

/* Account dropdown (top-right) */
.usermenu { position: relative; }
.usermenu__trigger { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .4rem .25rem .25rem; background: none; border: 1px solid transparent; border-radius: 999px; cursor: pointer; transition: background .16s ease, border-color .16s ease; }
.usermenu__trigger:hover { background: var(--ivory); border-color: var(--line-2); }
.usermenu__trigger:focus-visible { outline: 2px solid var(--maroon); outline-offset: 2px; }
.usermenu__chev { color: var(--ink-3); transition: transform .16s ease; }
.usermenu__trigger[aria-expanded="true"] .usermenu__chev { transform: rotate(180deg); }
.usermenu__pop { position: absolute; top: calc(100% + .5rem); right: 0; z-index: 50; width: 250px; background: var(--paper); border: 1px solid var(--line-2); border-radius: 11px; box-shadow: 0 1px 2px rgba(23,20,18,.06), 0 8px 22px rgba(23,20,18,.08); padding: .4rem; }
.usermenu__pop[hidden] { display: none; }
.usermenu__head { display: flex; align-items: center; gap: .6rem; padding: .6rem .55rem; }
.usermenu__id { min-width: 0; }
.usermenu__name { font-weight: 700; font-size: .9rem; }
.usermenu__email { font-size: .78rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usermenu__sep { height: 1px; background: var(--line); margin: .3rem .2rem; }
.usermenu__item { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .6rem; border: 0; background: none; border-radius: var(--radius-sm); font: inherit; font-size: .88rem; color: var(--ink-2); text-align: left; cursor: pointer; text-decoration: none; transition: background .15s ease, color .15s ease; }
.usermenu__item:hover { background: var(--ivory-2); color: var(--ink); text-decoration: none; }
.usermenu__item:focus-visible { outline: none; background: var(--ivory-2); }
.usermenu__item svg { color: var(--ink-3); }
.usermenu__item--danger { color: var(--danger); }
.usermenu__item--danger:hover { background: var(--danger-bg); color: var(--danger); }
.usermenu__item--danger svg { color: var(--danger); }

/* Dashboard stat cards that link to their module */
a.stat { text-decoration: none; color: inherit; display: block; }
a.stat:hover { border-color: var(--maroon); transform: translateY(-1px); }
a.stat:hover .stat__label { color: var(--maroon-2); }
a.stat:focus-visible { outline: 2px solid var(--maroon); outline-offset: 2px; }

/* Content area uses the full available width (up to a comfortable reading cap)
   with generous page padding — no accidental narrow wrappers. */
.content { padding: 1.6rem clamp(1.25rem, 2.2vw, 2.25rem) 3.5rem; width: 100%; max-width: 1440px; }
.content > * { min-width: 0; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.35rem; flex-wrap: wrap; }
.page-head__text h1 { font-size: 1.5rem; }
.page-head__text p { margin: .3rem 0 0; color: var(--ink-3); font-size: .9rem; }
.page-head__actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

/* Cards */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card__head { padding: 1rem 1.15rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .6rem; }
.card__head h2 { font-size: 1rem; }
.card__body { padding: 1.15rem; }
.card--pad { padding: 1.15rem; }
/* Cards that are links get a restrained hover (border + tiny lift, no heavy shadow). */
a.card, .card--link { transition: border-color .18s ease, transform .12s ease; }
a.card:hover, .card--link:hover { border-color: var(--maroon); transform: translateY(-1px); text-decoration: none; }

/* Stats grid */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); transition: border-color .18s ease; }
.stat:hover { border-color: var(--line-2); }
.stat__label { font-size: .78rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat__value { font-size: 1.9rem; font-weight: 800; margin-top: .35rem; letter-spacing: -.02em; }
.stat__meta { font-size: .8rem; color: var(--ink-3); margin-top: .2rem; }
.stat__icon { width: 38px; height: 38px; border-radius: 9px; background: var(--maroon-tint); color: var(--maroon-2); display: grid; place-items: center; float: right; }
.stat__icon svg { width: 20px; height: 20px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; padding: .7rem .8rem; border-bottom: 1px solid var(--line); background: var(--ivory); position: sticky; top: 0; }
table.data td { padding: .75rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fcfbf8; }
.cell-title { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: .8rem; color: var(--ink-3); }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; line-height: 1; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: #1d4ae8; }
.badge-muted { background: var(--ivory-2); color: var(--ink-3); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Buttons — one consistent system (height, padding, radius, states). */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 2.4rem; padding: .5rem 1rem; border-radius: 8px; font: inherit; font-weight: 600; font-size: .88rem;
  cursor: pointer; border: 1px solid transparent; text-decoration: none; white-space: nowrap;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .06s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--maroon-tint), 0 0 0 4px var(--maroon); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--maroon); color: #fff; border-color: var(--maroon); }
.btn-primary:hover { background: var(--maroon-2); border-color: var(--maroon-2); color: #fff; }
.btn-secondary { background: var(--paper); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--ivory); border-color: var(--maroon); color: var(--maroon-2); }
.btn-outline { background: transparent; color: var(--maroon-2); border-color: var(--maroon); }
.btn-outline:hover { background: var(--maroon-tint); color: var(--maroon-2); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #f0c9cf; }
.btn-danger:hover { background: #f6d6da; border-color: var(--danger); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: transparent; min-height: 0; padding: .4rem .55rem; }
.btn-ghost:hover { background: var(--ivory-2); color: var(--ink); }
.btn-sm { min-height: 0; padding: .35rem .6rem; font-size: .82rem; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* Accessible focus ring for all interactive controls */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--maroon); outline-offset: 2px; border-radius: 4px; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: none; }

/* Forms — responsive multi-column grid so wide screens are used well.
   Single column on narrow; two columns from ~820px. Use .col-span-2 for wide
   fields (textareas, addresses), .form-grid--single to force one column, and
   .form-grid--wide (3 cols) only where it genuinely helps. */
.form-grid { display: grid; gap: 1.15rem 1.5rem; grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field.col-span-2 { grid-column: 1 / -1; }
@media (min-width: 820px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.form-grid--single { grid-template-columns: 1fr; }
  .form-grid.form-grid--single .field { max-width: 46rem; }
  /* Wide inputs automatically span the full row so 2-col forms read cleanly. */
  .form-grid .field:has(textarea) { grid-column: 1 / -1; }
  .form-grid .field:has(input[type=file]) { grid-column: 1 / -1; }
}
@media (min-width: 1180px) {
  .form-grid.form-grid--wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Permissions / checkbox groups: responsive 2–4 columns filling the width. */
.perm-grid { display: grid; grid-template-columns: 1fr; gap: .5rem .75rem; }
@media (min-width: 640px)  { .perm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .perm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1360px) { .perm-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.perm-grid .checkline {
  padding: .5rem .65rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); transition: border-color .16s var(--ease, ease), background .16s ease;
}
.perm-grid .checkline:hover { border-color: var(--line-2); background: #fcfbf8; }
.field label { font-weight: 600; font-size: .85rem; }
.field .hint { font-size: .78rem; color: var(--ink-3); }
.field input[type=text], .field input[type=email], .field input[type=url], .field input[type=number], .field input[type=password], .field input[type=date], .field input[type=datetime-local], .field select, .field textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--line-2); border-radius: 8px; font: inherit; color: var(--ink); background: var(--paper);
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--maroon); box-shadow: 0 0 0 3px var(--maroon-tint); }
.field .err { color: var(--danger); font-size: .78rem; }
.field input.has-error, .field textarea.has-error, .field select.has-error { border-color: var(--danger); }
.checkline { display: flex; align-items: center; gap: .5rem; }
.checkline input { width: 16px; height: 16px; accent-color: var(--maroon); }
.form-actions { display: flex; gap: .6rem; border-top: 1px solid var(--line); margin-top: .4rem; padding-top: 1rem; }
fieldset.group { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.15rem; margin: 0; }
fieldset.group > legend { font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 0 .4rem; }

/* Page editor: numbered, clearly-separated section blocks. */
.section-block { padding: 1.25rem 1.2rem 1.15rem; margin-bottom: 1.25rem; background: var(--paper); }
.section-block:hover { border-color: var(--line-2); }
.section-head { display: flex; align-items: flex-start; gap: .7rem; padding-bottom: .85rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.section-num { flex-shrink: 0; margin-top: .1rem; font-family: var(--font-sans, inherit); font-size: .78rem; font-weight: 800; letter-spacing: .02em; color: #fff; background: var(--ink); border-radius: 6px; padding: .18rem .48rem; line-height: 1.2; }
.section-title { font-size: 1.04rem; font-weight: 800; letter-spacing: -0.01em; color: var(--ink); margin: 0; }
.section-appears { margin: .2rem 0 0; font-size: .8rem; color: var(--ink-3); line-height: 1.45; }

/* Repeater (fixed-count structured rows) */
.repeater { display: flex; flex-direction: column; gap: .7rem; }
.repeater__row { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fcfbf8; }
.repeater__num { flex-shrink: 0; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--maroon-tint); color: var(--maroon-2); display: grid; place-items: center; font-size: .78rem; font-weight: 700; margin-top: .15rem; }
.repeater__fields { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr; gap: .6rem; }
@media (min-width: 680px) { .repeater__fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.repeater__fields .field:has(textarea) { grid-column: 1 / -1; }
.repeater__fields label.small { font-weight: 600; font-size: .78rem; color: var(--ink-3); }

/* Flash / toasts */
.flash-wrap { position: fixed; top: 1rem; right: 1rem; z-index: 60; display: flex; flex-direction: column; gap: .5rem; width: 340px; max-width: calc(100vw - 2rem); }
.flash { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem .9rem; border-radius: 9px; box-shadow: var(--shadow); font-size: .88rem; background: var(--paper); border: 1px solid var(--line); }
.flash-success { border-left: 4px solid var(--ok); }
.flash-error { border-left: 4px solid var(--danger); }
.flash-info { border-left: 4px solid var(--maroon); }
.flash-info code { background: var(--maroon-3); padding: 0 .3em; border-radius: 4px; font-size: .92em; }
.flash button { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--ink-3); font-size: 1.1rem; line-height: 1; }

/* Empty state */
.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-3); }
.empty svg { width: 40px; height: 40px; opacity: .5; margin-bottom: .5rem; }

/* Auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--ivory), var(--maroon-tint)); padding: 1.5rem; }
.auth__card { width: 100%; max-width: 26rem; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 2.1rem 2rem; }
.auth__brand { display: flex; align-items: center; gap: .7rem; justify-content: center; margin-bottom: 1.4rem; }
.auth__brand .sidebar__mark { width: 38px; height: 38px; font-size: .9rem; }
.auth__brandtext { display: flex; flex-direction: column; line-height: 1.2; }
.auth__brandtext strong { font-size: 1rem; color: var(--ink); }
.auth__brandsub { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--maroon-2); }
.auth h1 { font-size: 1.25rem; text-align: center; color: var(--ink); }
.auth p.sub { text-align: center; color: var(--ink-3); font-size: .88rem; margin: .35rem 0 1.5rem; line-height: 1.45; }
.auth__form { display: grid; grid-template-columns: 1fr; gap: 1.05rem; }
.auth__form .field label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.auth__form .field input { width: 100%; padding: .62rem .75rem; font-size: .95rem; }
.auth__row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.auth__row .checkline { margin: 0; }
.auth__submit { width: 100%; justify-content: center; margin-top: .2rem; padding: .65rem 1rem; font-size: .95rem; }

/* Utilities */
.muted { color: var(--ink-3); }
.small { font-size: .82rem; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: .5rem; } .between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pill-tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.pill-tabs a { padding: .45rem .9rem; border-radius: 999px; font-size: .86rem; font-weight: 600; color: var(--ink-2); background: var(--paper); border: 1px solid var(--line); transition: background .16s ease, border-color .16s ease, color .16s ease; }
.pill-tabs a:hover { text-decoration: none; background: var(--maroon-tint); border-color: var(--maroon); color: var(--maroon-2); }
.pill-tabs a.is-active { background: var(--maroon); color: #fff; border-color: var(--maroon); }
.pill-tabs a.is-active:hover { color: #fff; }
.pagination { display: flex; gap: .3rem; margin-top: 1.2rem; flex-wrap: wrap; }
.pagination a, .pagination span { padding: .35rem .65rem; border-radius: 7px; border: 1px solid var(--line); font-size: .84rem; color: var(--ink-2); background: var(--paper); }
.pagination .active span, .pagination span[aria-current] { background: var(--maroon); color: #fff; border-color: var(--maroon); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(23,20,18,.5); display: grid; place-items: center; z-index: 70; padding: 1rem; }
.modal-overlay.hidden { display: none; }
.modal-card { background: var(--paper); border-radius: 12px; padding: 1.4rem; max-width: 400px; width: 100%; box-shadow: var(--shadow); }

.sidebar__backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar__backdrop.is-open { display: block; position: fixed; inset: 0; background: rgba(23,20,18,.5); z-index: 39; }
  .main { margin-left: 0; }
  .menu-toggle { display: grid; place-items: center; }
  .grid-2 { grid-template-columns: 1fr; }
}
