:root {
  --navy-deep: #0b0f19;
  --navy: #0b1f3a;
  --navy-mid: #1e3a5f;
  --on-dark: #f8fafc;
  --muted: #94a3b8;
  --accent: #08748a;
  --accent-hover: #0ea5e9;
  --accent-2: #4f46e5;
  --gold: #c9a227;
  --danger: #cf2e2e;
  --ok: #059669;
  --border: rgba(248, 250, 252, 0.12);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --font-h: "Manrope", system-ui, sans-serif;
  --font-b: "Source Sans 3", system-ui, sans-serif;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --btn-3d: inset 0 1px 0 rgba(255,255,255,.22), 0 8px 18px rgba(8, 116, 138, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-b);
  color: var(--on-dark);
  background:
    radial-gradient(circle at 18% 12%, rgba(8, 116, 138, 0.28), transparent 42%),
    radial-gradient(circle at 92% 0%, rgba(79, 70, 229, 0.18), transparent 38%),
    linear-gradient(145deg, #0b0f19 0%, #0b1f3a 55%, #0b0f19 100%);
  background-attachment: fixed;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-h); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 .35rem; }
h1 { font-size: clamp(1.35rem, 2vw, 1.8rem); }
p { margin: 0 0 .75rem; color: var(--muted); }
a { color: var(--accent-hover); }

.app-shell { max-width: 1280px; margin: 0 auto; padding: 18px 18px 56px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-family: var(--font-h); font-weight: 800; background: linear-gradient(145deg, var(--accent), #065f6f);
  box-shadow: var(--btn-3d);
}
.brand-title { font-family: var(--font-h); font-weight: 800; }
.brand-sub { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.user-chip { font-size: .85rem; color: var(--muted); padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: rgba(248,250,252,.04); }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; padding: 8px; border-radius: var(--radius-lg); background: rgba(15,23,42,.45); border: 1px solid var(--border); }
.tab, .subtab, .btn { border: 0; cursor: pointer; transition: .15s ease; }
.tab { background: transparent; color: var(--muted); padding: 10px 16px; border-radius: var(--radius-pill); font-family: var(--font-h); font-weight: 600; }
.tab:hover { color: var(--on-dark); background: rgba(248,250,252,.06); }
.tab.is-active { background: var(--accent); color: #fff; box-shadow: var(--btn-3d); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--radius-pill); font-family: var(--font-h); font-weight: 700;
}
.btn-primary { background: linear-gradient(180deg, #0a8aa3, var(--accent)); color: #fff; box-shadow: var(--btn-3d); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: rgba(248,250,252,.06); color: var(--on-dark); border: 1px solid rgba(248,250,252,.22); }
.btn-danger { background: transparent; color: #fecaca; border: 1px solid rgba(207,46,46,.45); }
.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.panel[hidden] { display: none !important; }
.panel-head { margin-bottom: 16px; }
.panel-head.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card, .placeholder-card {
  background: rgba(30, 58, 95, 0.28); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px; box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: .82rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea, .toolbar input, .toolbar select {
  width: 100%; background: rgba(11,15,25,.65); border: 1px solid rgba(248,250,252,.14);
  border-radius: var(--radius-sm); padding: 10px 12px; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8,116,138,.25); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.field.inline { margin-bottom: 0; min-width: 180px; }
.field.grow { flex: 1; min-width: 200px; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0 14px; color: var(--muted); }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-wrap[hidden],
.app-shell[hidden],
.modal[hidden],
[hidden] { display: none !important; }
.auth-card { width: min(420px, 100%); }
.auth-card h1 { margin-bottom: .25rem; }
.auth-switch { margin-top: 12px; font-size: .92rem; }

.subtabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.subtab {
  background: rgba(248,250,252,.04); color: var(--muted); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 8px 14px; font-family: var(--font-h); font-weight: 600; font-size: .85rem;
}
.subtab.is-active { background: rgba(8,116,138,.22); border-color: rgba(8,116,138,.55); color: #fff; }

.templates-list, .admin-list { display: grid; gap: 12px; }
.tpl-card, .admin-row {
  display: grid; grid-template-columns: 1fr auto; gap: 14px; padding: 16px 18px;
  border-radius: var(--radius-md); background: rgba(15,23,42,.55); border: 1px solid var(--border);
}
.tpl-card.is-disabled { opacity: .55; }
.tpl-card.is-proposal { border-style: dashed; border-color: rgba(201,162,39,.45); }
.tpl-code {
  display: inline-block; font-family: var(--font-h); font-weight: 800; font-size: .75rem;
  padding: 3px 8px; border-radius: 6px; background: rgba(8,116,138,.25); color: #7dd3e8; margin-right: 8px;
}
.tpl-origin {
  display: inline-block; font-family: var(--font-h); font-weight: 700; font-size: .68rem;
  padding: 3px 8px; border-radius: 6px; margin-left: 6px; vertical-align: middle;
}
.tpl-origin-admin { background: rgba(34,197,94,.18); color: #86efac; }
.tpl-origin-proposal { background: rgba(201,162,39,.2); color: #f0d78c; }
.tpl-origin-seed { background: rgba(148,163,184,.18); color: #cbd5e1; }
.tpl-title { font-family: var(--font-h); font-weight: 700; margin-bottom: 6px; }
.phrases-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 14px; }
.phrases-label { width: 100%; font-size: .82rem; color: var(--muted); font-family: var(--font-h); font-weight: 600; }
.phrase-chip {
  display: inline-block; padding: 6px 10px; border-radius: 8px; font-size: .8rem;
  background: rgba(8,116,138,.16); border: 1px solid rgba(8,116,138,.4); color: #c8eef6; text-decoration: none;
}
.phrase-chip:hover { border-color: rgba(125,211,232,.7); color: #fff; }
.tpl-meta { font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.tpl-body { white-space: pre-wrap; color: #dbe4f0; font-size: .95rem; max-height: 7.5em; overflow: hidden; }
.tpl-actions { display: flex; flex-direction: column; gap: 8px; min-width: 130px; }
.tpl-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); margin-top: 8px; }
.char-over { color: var(--gold); font-weight: 700; }
.char-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: .82rem; color: var(--muted); }
.warn { color: var(--gold); }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed rgba(248,250,252,.18); border-radius: var(--radius-md); }

.banner-pro {
  margin-bottom: 14px; padding: 12px 16px; border-radius: var(--radius-md);
  background: rgba(8,116,138,.15); border: 1px solid rgba(8,116,138,.35); font-family: var(--font-h); font-weight: 600;
}
.install-hint {
  margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius-md);
  background: rgba(248,250,252,.04); border: 1px dashed rgba(248,250,252,.2); font-size: .9rem; color: var(--muted);
}

.industry-tabs {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px;
}
.industry-tab {
  background: rgba(248,250,252,.04); color: var(--muted); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 8px 14px; font-family: var(--font-h); font-weight: 700;
  font-size: .85rem; cursor: pointer;
}
.industry-tab.is-active {
  background: rgba(201, 162, 39, .22); border-color: rgba(201, 162, 39, .55); color: #fff;
}
.industry-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px;
  max-height: 280px; overflow: auto; padding: 4px;
}
.industry-chip {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: rgba(15,23,42,.55); cursor: pointer; font-size: .9rem;
}
.industry-chip input { margin-top: 3px; }
.industry-chip.is-picked { border-color: rgba(8,116,138,.7); background: rgba(8,116,138,.18); }
.user-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.members-badge {
  display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 6px;
  font-family: var(--font-h); font-weight: 800; font-size: .72rem;
  background: rgba(201, 162, 39, .22); color: #fbbf24; border: 1px solid rgba(201,162,39,.45);
}
.work-card.is-oversized { border-color: rgba(201, 162, 39, .4); }

.modal { border: 0; padding: 0; background: transparent; max-width: 720px; width: calc(100% - 24px); }
.modal::backdrop { background: rgba(2,6,14,.72); backdrop-filter: blur(4px); }
.modal-card {
  background: linear-gradient(180deg, rgba(30,58,95,.95), rgba(11,15,25,.98));
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden;
}
.modal-head, .modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-foot { border-bottom: 0; border-top: 1px solid var(--border); justify-content: flex-end; }
.modal-body { padding: 16px 18px 8px; max-height: min(70vh, 640px); overflow: auto; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: transparent; color: var(--on-dark); font-size: 1.4rem; cursor: pointer; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.qr-box { display: grid; place-items: center; gap: 10px; padding: 12px; background: #fff; border-radius: 12px; color: #0f172a; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #0f172a; border: 1px solid rgba(8,116,138,.5); border-radius: var(--radius-pill); padding: 12px 18px; box-shadow: var(--shadow); z-index: 50; }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-family: var(--font-h); font-weight: 700; font-size: .8rem; }

.land-setup {
  margin-top: 10px; padding: 10px 14px; border-radius: var(--radius-md);
  background: rgba(8,116,138,.18); border: 1px solid rgba(8,116,138,.4);
  color: var(--on-dark); font-family: var(--font-h); font-weight: 600; font-size: .9rem;
}

.mobile-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(11, 15, 25, 0.94); border-top: 1px solid var(--border);
  backdrop-filter: blur(10px); gap: 6px; justify-content: space-around;
}
.mobile-nav-btn {
  flex: 1; background: transparent; color: var(--muted); border: 0;
  border-radius: 12px; padding: 10px 6px; font-family: var(--font-h); font-weight: 700; font-size: .72rem;
}
.mobile-nav-btn.is-active { color: #fff; background: rgba(8,116,138,.35); }

.anti-ban {
  margin-bottom: 14px; padding: 12px 14px; border-radius: var(--radius-md);
  background: rgba(15,23,42,.55); border: 1px solid var(--border);
}
.anti-ban-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-family: var(--font-h); font-weight: 700; font-size: .9rem; }
.anti-ban-track { height: 10px; border-radius: 999px; background: rgba(248,250,252,.08); overflow: hidden; }
.anti-ban-fill { height: 100%; border-radius: 999px; transition: width .2s ease, background .2s ease; }
.anti-ban-fill.ok { background: linear-gradient(90deg, #059669, #34d399); }
.anti-ban-fill.warn { background: linear-gradient(90deg, #b45309, #fbbf24); }
.anti-ban-fill.danger { background: linear-gradient(90deg, #991b1b, #ef4444); }
.anti-ban-meta { margin-top: 8px; font-size: .82rem; color: var(--muted); }

.work-list { display: grid; gap: 12px; }
.work-card {
  padding: 14px 16px; border-radius: var(--radius-md);
  background: rgba(15,23,42,.55); border: 1px solid var(--border);
}
.work-card.is-overdue { border-color: rgba(251,191,36,.55); box-shadow: 0 0 0 1px rgba(251,191,36,.25); }
.work-title { font-family: var(--font-h); font-weight: 700; margin-bottom: 4px; }
.work-meta { font-size: .82rem; color: var(--muted); margin-bottom: 10px; }
.work-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest { font-size: .8rem; color: #7dd3e8; margin-bottom: 8px; }

.color-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.color-btn {
  border: 1px solid var(--border); background: rgba(248,250,252,.05);
  border-radius: var(--radius-pill); padding: 6px 10px; font-size: .78rem; cursor: pointer; color: var(--on-dark);
}
.color-btn.is-active.zielony { background: rgba(5,150,105,.28); border-color: #34d399; }
.color-btn.is-active.niebieski { background: rgba(37,99,235,.28); border-color: #60a5fa; }
.color-btn.is-active.zolty { background: rgba(202,138,4,.28); border-color: #fbbf24; }
.color-btn.is-active.czerwony { background: rgba(220,38,38,.28); border-color: #f87171; }
.cheat { margin: 8px 0 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(8,116,138,.12); border: 1px solid rgba(8,116,138,.3); font-size: .88rem; color: #dbe4f0; }
.funnel-select, .check-row { margin: 6px 0; }
.check-row label { display: flex; align-items: flex-start; gap: 8px; font-size: .88rem; color: var(--muted); margin-bottom: 6px; }
.msg-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.image-dock {
  position: fixed; right: 16px; bottom: 88px; z-index: 45; max-width: min(420px, calc(100vw - 24px));
}
.image-dock-inner {
  display: flex; gap: 12px; align-items: center; padding: 12px;
  background: rgba(11,15,25,.96); border: 1px solid rgba(8,116,138,.45); border-radius: var(--radius-md); box-shadow: var(--shadow);
}
.image-dock img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }

.toast { display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); }
.toast-undo #toastUndo { flex-shrink: 0; }

@media (max-width: 720px) {
  .tpl-card, .admin-row { grid-template-columns: 1fr; }
  .tpl-actions { flex-direction: row; flex-wrap: wrap; }
  .app-shell { padding: 12px 12px 88px; }
  .tabs { display: none; }
  .mobile-nav { display: flex; }
  .topbar-meta, .user-chip { font-size: .75rem; max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .subtabs { gap: 6px; }
  .subtab { font-size: .78rem; padding: 8px 10px; }
  .panel-head.row-between .btn { width: 100%; }
  .settings-grid, .grid-2 { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; }
  .image-dock { left: 12px; right: 12px; bottom: 76px; max-width: none; }
  .work-actions .btn { flex: 1 1 calc(50% - 8px); }
}
