:root {
  --bg: #f3f5f8; --card: #fff; --ink: #1d2733; --muted: #66758a; --line: #dfe4ea;
  --brand: #1f4e79; --brand-2: #2c6aa6; --ok: #1e7b45; --err: #b42318; --dl: #1e7b45;
  --r: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand-2); }
h1 { font-size: 1.45rem; margin: 0 0 .9rem; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; color: var(--brand); }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .82rem; }
main { max-width: 1280px; margin: 0 auto; padding: 1.1rem; }

/* header */
.top { background: var(--brand); color: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.2rem; padding: .6rem 1.1rem; }
.top a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.05rem; }
.top nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.top nav a { padding: .35rem .7rem; border-radius: 6px; opacity: .85; }
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.16); opacity: 1; }
.who { font-size: .88rem; opacity: .9; }
.who a { text-decoration: underline; }
.tag { background: #f5c542; color: #3a2c00; font-size: .7rem; padding: .05rem .35rem; border-radius: 4px; font-weight: 700; }

/* cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card.narrow { max-width: 640px; }
.cards2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.big { font-size: 2rem; font-weight: 700; color: var(--brand); }
.page-head { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.page-head h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* forms */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .86rem; font-weight: 600; color: #344255; }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); padding: .55rem .65rem; border: 1px solid #c9d2dc; border-radius: 7px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3ea; border-color: var(--brand-2); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .85rem 1rem; }
.grid .wide { grid-column: 1 / -1; }
.grid-mat { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.grid-mat label { font-size: .78rem; }
.req { color: var(--err); }
.chk { flex-direction: row; align-items: center; font-weight: 400; gap: .4rem; }
.chk input { width: auto; }
.inline { display: flex; gap: .5rem; align-items: center; margin: 0; }
.inline + table { margin-top: 1rem; }

.photo { display: flex; flex-direction: column; gap: .35rem; }
.photo .lbl { font-size: .86rem; font-weight: 600; color: #344255; }
.drop { position: relative; border: 2px dashed #b9c6d4; border-radius: 9px; min-height: 150px; display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden; background: #f8fafc; }
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.drop .drop-txt { position: relative; z-index: 1; background: rgba(255,255,255,.9); padding: .3rem .6rem; border-radius: 6px; font-weight: 600; }
.drop img:not([hidden]) + .drop-txt { position: absolute; bottom: .4rem; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 1rem 0 .6rem; display: flex; gap: .6rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; font: inherit; font-weight: 600; padding: .55rem 1rem; border-radius: 8px; border: 1px solid #c3cdd8; background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #eef2f6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.dl { background: var(--dl); border-color: var(--dl); color: #fff; }
.btn.danger { color: var(--err); border-color: #f0b8b2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: .28rem .6rem; font-size: .82rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }

/* flash */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: #e7f5ec; color: var(--ok); border: 1px solid #b7e1c6; }
.flash.err { background: #fdecea; color: var(--err); border-color: #f5c2bc; }
.flash ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* filters */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .7rem; align-items: end; }
.filters .grow { grid-column: span 2; }
.filters small { grid-column: 1 / -1; }

/* tables */
.tablewrap { overflow-x: auto; padding: 0; }
table { border-collapse: collapse; width: 100%; }
.data th, .data td { padding: .5rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: .88rem; }
.data th { background: #f6f8fa; font-size: .76rem; text-transform: uppercase; letter-spacing: .02em; color: #4b5a6c; white-space: nowrap; }
.data tbody tr:hover { background: #fafcff; }
.data .empty { text-align: center; color: var(--muted); padding: 2rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.thumbs { white-space: nowrap; }
.thumbs img { width: 42px; height: 42px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); margin-right: 3px; vertical-align: middle; }
.nophoto { display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center; border: 1px dashed #cfd8e2; border-radius: 5px; color: #a0acba; margin-right: 3px; vertical-align: middle; }
.rowact { white-space: nowrap; display: flex; gap: .35rem; }
.rowact form { margin: 0; }
.mini td { padding: .3rem 0; border-bottom: 1px solid var(--line); }
.card .actions { margin-top: 1rem; }

.pager { display: flex; flex-wrap: wrap; gap: .3rem; }
.pager a { padding: .3rem .65rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; text-decoration: none; }
.pager a.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.code { background: #0f1b2a; color: #d7e6f5; padding: .6rem .8rem; border-radius: 7px; overflow-x: auto; font-size: .82rem; }
code { background: #eef2f6; padding: .05rem .3rem; border-radius: 4px; font-size: .85em; }
.ok-text { color: var(--ok); }
.err-text { color: var(--err); }
.narrow-table { max-width: 520px; }
.users-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 860px) { .users-grid { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: .7rem; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] .stack { margin-top: .5rem; min-width: 200px; }
.rowact { align-items: flex-start; }

.login { max-width: 380px; margin: 9vh auto; }
.login form { display: flex; flex-direction: column; gap: .9rem; }

@media (max-width: 640px) {
  main { padding: .75rem; }
  .card { padding: .85rem; }
  .filters .grow { grid-column: auto; }
  .sticky-actions .btn { flex: 1; }
  .top { padding: .55rem .75rem; }
  .top nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; }
  .who { margin-left: auto; }
}
