:root { --violet: #8a3fd6; --violet-dark: #6f2fb4; --line: #e3e0ea; --bg: #f6f5f9; --ink: #1c1a22; --muted: #6d6a78; --danger: #c62828; --ok: #157a3c; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); min-height: 1.4em; }

.btn { padding: 9px 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 500; }
.btn:hover { border-color: #bdb7cc; }
.btn--primary { background: var(--violet); border-color: var(--violet); color: #fff; }
.btn--primary:hover { background: var(--violet-dark); border-color: var(--violet-dark); }
.btn--danger { color: var(--danger); }
.btn--sm { padding: 5px 10px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: default; }
.link { border: 0; background: none; padding: 4px; color: var(--violet); }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login__box { width: min(380px, 100%); display: grid; gap: 16px; padding: 32px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.login__box h1 { font-size: 22px; }

/* layout */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding: 10px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.top__title { font-size: 17px; }
.top__right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.top__right a { color: var(--violet); text-decoration: none; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { padding: 8px 14px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-weight: 500; }
.tabs button:hover { background: var(--bg); }
.tabs button.is-active { background: #efe6fa; color: var(--violet-dark); }
.view { max-width: 1000px; margin: 0 auto; padding: 28px 24px 120px; }
.view h1 { font-size: 24px; margin-bottom: 6px; }
.view > .muted { margin-bottom: 20px; }
.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 18px 0; }
.toolbar .f { margin-left: auto; grid-template-columns: auto 80px; align-items: center; gap: 10px; }

/* list of cards */
.rows { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 84px 1fr auto; gap: 16px; align-items: center; padding: 10px 14px 10px 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.row.is-hidden { opacity: .6; }
.row.is-more { border-style: dashed; }
.row img { width: 84px; height: 56px; object-fit: cover; border-radius: 8px; background: #eee; }
.row__title { font-weight: 600; }
.row__meta { font-size: 14px; color: var(--muted); }
.row__actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #e6ff4d; }
.tag--grey { background: #e8e6ee; color: var(--muted); }
.divider { margin: 10px 0 2px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* fields */
.f { display: grid; gap: 6px; }
.f > span { font-size: 14px; font-weight: 500; }
.f small { color: var(--muted); font-size: 13px; }
.f input[type=text], .f input[type=password], .f input[type=number], .f input[type=url], .f textarea { width: 100%; padding: 9px 12px; border: 1px solid #cfcad9; border-radius: 8px; background: #fff; }
.f textarea { min-height: 110px; resize: vertical; }
.f textarea.tall { min-height: 300px; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 18px; height: 18px; accent-color: var(--violet); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.group { display: grid; gap: 16px; padding: 20px; margin-bottom: 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.group h2 { font-size: 18px; }
.pic { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pic img { width: 150px; height: 96px; object-fit: cover; border-radius: 8px; background: #eee; border: 1px solid var(--line); }
.pic input[type=file] { max-width: 260px; font-size: 14px; }

/* photo tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile { display: grid; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #faf9fc; font-size: 14px; }
.tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: #eee; }
.tile__actions { display: flex; gap: 4px; flex-wrap: wrap; }
.group .toolbar { margin: 0; }
.group .toolbar .f { margin-left: 0; grid-template-columns: 1fr; }

/* editor dialog */
.editor { width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.editor::backdrop { background: rgba(20, 16, 30, .5); }
.editor__form { display: grid; grid-template-rows: auto 1fr auto; max-height: calc(100dvh - 24px); }
.editor__head, .editor__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; background: #fff; }
.editor__head { border-bottom: 1px solid var(--line); }
.editor__head h2 { font-size: 18px; }
.editor__head .link { font-size: 26px; line-height: 1; color: var(--muted); }
.editor__foot { justify-content: flex-end; border-top: 1px solid var(--line); }
.editor__body { display: grid; gap: 16px; padding: 20px; overflow: auto; }
.editor__body h3 { font-size: 15px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }

/* save bar */
.savebar { position: fixed; inset: auto 0 0 0; z-index: 6; display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 24px; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0, 0, 0, .08); }
.savebar span { margin-right: auto; font-weight: 500; }
.toast { position: fixed; left: 50%; bottom: 84px; z-index: 20; transform: translateX(-50%); padding: 10px 18px; border-radius: 10px; background: #1c1a22; color: #fff; max-width: calc(100% - 32px); }
.toast.is-error { background: var(--danger); }

/* leads */
.leads { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.leads th, .leads td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); font-size: 15px; }
.leads th { font-size: 13px; color: var(--muted); background: #faf9fc; }
.leads td:first-child { white-space: nowrap; color: var(--muted); }
.leads dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.leads dt { color: var(--muted); }
.leads dd { margin: 0; }

@media (max-width: 700px) {
  .top { padding: 10px 14px; gap: 10px; }
  .view { padding: 20px 14px 130px; }
  .row { grid-template-columns: 64px 1fr; }
  .row img { width: 64px; height: 44px; }
  .row__actions { grid-column: 1 / -1; justify-content: flex-start; }
  .grid2 { grid-template-columns: 1fr; }
  .savebar { flex-wrap: wrap; padding: 10px 14px; }
  .savebar span { width: 100%; }
}
