:root {
  --bg: #F2F5F7; --card: #FFFFFF; --ink: #12212B; --muted: #5B6B75; --line: #DCE3E8; --line2: #EDF1F4;
  --primary: #0E5A64; --primary-dark: #0A434B; --primary-soft: #E3F0F1; --gold: #F5B841;
  --red: #B4232F; --red-soft: #FCE8EA; --amber: #A14B0B; --amber-soft: #FDEEDC;
  --green: #1F7A4D; --green-soft: #E2F3EA; --blue: #1E4FA0; --blue-soft: #E5EDFA; --gray-soft: #E9EEF1;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 26px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.btn { height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #b9c6ce; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--red); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.field textarea { height: 72px; padding: 8px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Layout */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 220px; max-width: 250px; background: var(--primary-dark); color: #fff; padding: 24px 16px; display: flex; flex-direction: column; gap: 24px; }
.side .brand { font-size: 20px; font-weight: 700; }
.side .handle { color: var(--gold); font-size: 12px; font-weight: 600; }
.side nav a { display: block; color: #CFE3E5; text-decoration: none; padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.side nav a.on { background: rgba(255,255,255,.14); color: #fff; }
.side .langs { display: flex; gap: 6px; margin-top: auto; }
.side .langs button { flex: 1; height: 32px; border-radius: 8px; border: 1px solid rgba(255,255,255,.25); background: transparent; color: #fff; cursor: pointer; font-weight: 600; }
.side .langs button.on { background: #fff; color: var(--primary-dark); }
.side .who { font-size: 12px; color: #CFE3E5; }
.side .who button { background: none; border: 0; color: var(--gold); cursor: pointer; padding: 0; font-weight: 600; }
.main { flex: 999 1 560px; min-width: 0; padding: 28px clamp(16px, 3vw, 40px); max-width: 1240px; display: flex; flex-direction: column; gap: 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tile .k { color: var(--muted); font-size: 13px; font-weight: 600; }
.tile .v { font-size: 30px; font-weight: 700; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 700; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #F8FAFB; }
.avatar { width: 34px; height: 34px; border-radius: 17px; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 9px; margin: 2px 4px 2px 0; white-space: nowrap; }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.gray { background: var(--gray-soft); color: #3A4A54; }

.tabs { display: flex; gap: 4px; background: #E4EAEE; padding: 4px; border-radius: 12px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.on { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(18,33,43,.12); }

.charts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.chart svg { width: 100%; height: 120px; display: block; }
.big { font-size: 28px; font-weight: 700; }

.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line2); flex-wrap: wrap; }
.list-item:last-child { border-bottom: 0; }

.preview { display: flex; gap: 16px; flex-wrap: wrap; background: var(--primary-soft); border-radius: 12px; padding: 12px 14px; }
.preview b { font-size: 18px; }

.thumbs { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.thumb { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.thumb .img { height: 160px; background: #F8FAFB; display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 160px; object-fit: cover; cursor: zoom-in; }
.thumb .meta { padding: 10px; display: flex; flex-direction: column; gap: 6px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(18,33,43,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 10; }
.modal { background: #fff; border-radius: 18px; padding: 22px; width: 100%; max-width: 620px; display: flex; flex-direction: column; gap: 14px; }
.modal.wide { max-width: 1000px; }
.modal img { max-width: 100%; border-radius: 8px; }
.code { font-size: 40px; font-weight: 700; letter-spacing: .12em; text-align: center; background: var(--primary-soft); color: var(--primary-dark); border-radius: 14px; padding: 18px; font-variant-numeric: tabular-nums; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.error { color: var(--red); font-weight: 600; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
#toast.on { opacity: 1; }

@media (max-width: 720px) {
  .side { max-width: none; flex-basis: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 14px 16px; gap: 12px; }
  .side nav { display: none; }
  .side .langs { margin-top: 0; }
}
@media print {
  .side, .no-print, #toast { display: none !important; }
  .modal-bg { position: static; background: none; padding: 0; }
}
