@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Syne:wght@600;700;800&display=swap');

:root {
  --ink: #0f2438;
  --ink-soft: #5b738b;
  --paper: #ffffff;
  --mist: #eef4f8;
  --teal: #0c7a56;
  --teal-deep: #07563c;
  --teal-soft: #e5f6ef;
  --amber: #e2a116;
  --amber-soft: #fff4d9;
  --coral: #d94b4b;
  --line: rgba(15, 36, 56, 0.1);
  --shadow: 0 16px 40px rgba(15, 36, 56, 0.1);
  --radius: 20px;
  --nav: 248px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: "Syne", sans-serif;
  --font-body: "Manrope", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(900px 480px at -10% -10%, rgba(12, 122, 86, 0.14), transparent 55%),
    radial-gradient(700px 420px at 110% 0%, rgba(226, 161, 22, 0.12), transparent 50%),
    linear-gradient(180deg, #e9f0f6 0%, #f5f8fb 45%, #eef3f7 100%);
  min-height: 100vh;
  line-height: 1.55;
  font-size: 15px;
}
a { color: var(--teal); text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }

.container { width: min(1100px, calc(100% - 1.5rem)); margin: 0 auto; }

/* ===== Front header ===== */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .95rem 0; gap: .75rem; position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px); background: rgba(245, 248, 251, .82);
  border-bottom: 1px solid transparent;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.brand {
  font-family: var(--font-display); font-weight: 800; font-size: 1.2rem;
  letter-spacing: -0.03em; color: var(--ink);
  display: inline-flex; align-items: center; gap: .5rem;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  background: linear-gradient(145deg, var(--teal), #18a873);
  box-shadow: 0 8px 18px rgba(12, 122, 86, .28);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 7px;
  border: 2px solid rgba(255,255,255,.9); border-radius: 5px;
  border-right-color: transparent; transform: rotate(20deg);
}
.nav-links { display: flex; gap: .35rem; align-items: center; }
.nav-links a {
  color: var(--ink-soft); font-weight: 650; padding: .5rem .85rem; border-radius: 999px;
}
.nav-links a:hover { background: var(--teal-soft); color: var(--teal-deep); }
.nav-burger {
  display: none; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; align-items: center; justify-content: center; cursor: pointer;
}
.nav-burger span { width: 16px; height: 2px; background: var(--ink); position: relative; display: block; }
.nav-burger span::before, .nav-burger span::after {
  content: ""; position: absolute; left: 0; width: 16px; height: 2px; background: var(--ink);
}
.nav-burger span::before { top: -5px; }
.nav-burger span::after { top: 5px; }
.mobile-nav {
  display: none; position: fixed; inset: 0; z-index: 60; background: rgba(15,36,56,.42);
}
.mobile-nav.open { display: block; }
.mobile-nav-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(82vw, 300px);
  background: #fff; padding: 1.2rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .35rem;
  animation: slideIn .22s ease;
}
.mobile-nav-panel a {
  padding: .9rem 1rem; border-radius: 14px; color: var(--ink); font-weight: 700;
  background: var(--mist);
}
.mobile-nav-panel .close-nav {
  align-self: flex-end; border: 0; background: var(--mist); border-radius: 10px;
  padding: .55rem .8rem; font-weight: 700; margin-bottom: .6rem; cursor: pointer;
}

/* ===== Hero ===== */
.hero {
  display: grid; grid-template-columns: 1.05fr .95fr; gap: 1.6rem;
  align-items: stretch; padding: 1.6rem 0 2.4rem;
}
.hero-copy { display: flex; flex-direction: column; justify-content: center; padding: .4rem 0; }
.hero-kicker {
  display: inline-flex; align-self: flex-start; gap: .4rem; align-items: center;
  background: var(--amber-soft); color: #8a5b00; font-weight: 700; font-size: .78rem;
  padding: .35rem .7rem; border-radius: 999px; margin-bottom: .9rem;
}
.hero h1 {
  font-family: var(--font-display); font-size: clamp(2rem, 6vw, 3.35rem);
  line-height: 1.05; letter-spacing: -0.045em; margin: 0 0 .9rem;
}
.hero h1 span {
  background: linear-gradient(120deg, var(--teal) 10%, #1aa8c9 55%, var(--amber));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { color: var(--ink-soft); font-size: 1rem; max-width: 34rem; margin: 0 0 1.35rem; }
.cta-row { display: flex; flex-wrap: wrap; gap: .65rem; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  border-radius: 14px; padding: .78rem 1.15rem; font-weight: 750;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 44px;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--teal), #16a36f);
  color: #fff; box-shadow: 0 10px 24px rgba(12,122,86,.25);
}
.btn-secondary {
  background: rgba(255,255,255,.88); color: var(--ink);
  border: 1px solid var(--line);
}
.btn-danger { background: var(--coral); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-sm { padding: .48rem .78rem; font-size: .86rem; border-radius: 11px; min-height: 36px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.hero-panel {
  border-radius: 28px; overflow: hidden; color: #fff; padding: 1.35rem;
  background:
    radial-gradient(circle at 85% 15%, rgba(226,161,22,.35), transparent 35%),
    linear-gradient(155deg, #0b6b4c 0%, #0a4f55 55%, #123a4d 100%);
  box-shadow: var(--shadow); min-height: 300px;
  display: flex; flex-direction: column;
  animation: rise .55s ease both;
}
.hero-panel h3 { font-family: var(--font-display); margin: 0 0 .35rem; font-size: 1.3rem; }
.hero-panel .meta { opacity: .86; font-size: .9rem; margin-bottom: 1rem; }
.source-url {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px; padding: .95rem 1rem; word-break: break-all;
  font-family: ui-monospace, monospace; font-size: .84rem; line-height: 1.45;
}
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: auto; padding-top: 1.1rem; }
.chip {
  background: rgba(255,255,255,.14); border-radius: 999px; padding: .32rem .68rem; font-size: .78rem; font-weight: 650;
}

.section { padding: .6rem 0 2.4rem; }
.section h2 {
  font-family: var(--font-display); font-size: clamp(1.35rem, 3vw, 1.7rem);
  letter-spacing: -0.03em; margin: 0 0 .35rem;
}
.section .lead { color: var(--ink-soft); margin: 0 0 1.15rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; }
.feature {
  background: rgba(255,255,255,.78); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.15rem; backdrop-filter: blur(8px);
}
.feature .ico {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--teal-soft); color: var(--teal-deep); font-weight: 800; margin-bottom: .75rem;
}
.feature h3 { margin: 0 0 .3rem; font-size: 1.02rem; }
.feature p { margin: 0; color: var(--ink-soft); font-size: .9rem; }
.site-footer {
  border-top: 1px solid var(--line); padding: 1.2rem 0 calc(1.4rem + var(--safe-bottom));
  color: var(--ink-soft); font-size: .88rem;
}

/* ===== Shared ===== */
.card {
  background: rgba(255,255,255,.88); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.05rem; box-shadow: 0 8px 24px rgba(15,36,56,.04);
}
.card + .card { margin-top: .85rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: .82rem; font-weight: 700; color: var(--ink-soft); margin-bottom: .32rem; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: .72rem .85rem; background: #fff; color: var(--ink); outline: none;
  min-height: 44px;
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: rgba(12,122,86,.45); box-shadow: 0 0 0 3px rgba(12,122,86,.12);
}
.table-wrap {
  overflow: auto; border-radius: 16px; border: 1px solid var(--line);
  -webkit-overflow-scrolling: touch; background: #fff;
}
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .72rem .75rem; border-bottom: 1px solid var(--line); text-align: left; }
th { background: #f3f8f6; font-weight: 750; color: var(--ink-soft); position: sticky; top: 0; }
td { white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.badge {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: .18rem .55rem; font-size: .74rem; font-weight: 750;
}
.badge-ok { background: var(--teal-soft); color: var(--teal-deep); }
.badge-warn { background: var(--amber-soft); color: #8a5b00; }
.badge-off { background: #fde8e8; color: var(--coral); }
.toolbar { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin-bottom: .9rem; }
.toolbar .grow { flex: 1; min-width: 140px; }
.muted { color: var(--ink-soft); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.stat {
  border-radius: 18px; padding: 1rem 1.05rem; color: #fff;
  background: linear-gradient(145deg, var(--teal), #148a7a);
  box-shadow: 0 10px 24px rgba(12,122,86,.18);
}
.stat:nth-child(2) { background: linear-gradient(145deg, #b8860f, #e2a116); }
.stat:nth-child(3) { background: linear-gradient(145deg, #1f4e6b, #3d7ea6); }
.stat:nth-child(4) { background: linear-gradient(145deg, #8b3a3a, #d94b4b); }
.stat:nth-child(5) { background: linear-gradient(145deg, #3b4d61, #627d98); }
.stat:nth-child(6) { background: linear-gradient(145deg, #0f766e, #14b8a6); }
.stat .n { font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; }
.stat .t { opacity: .9; font-size: .82rem; margin-top: .15rem; }
.empty { text-align: center; padding: 1.8rem 1rem; color: var(--ink-soft); }

/* ===== Admin ===== */
.admin-body { background: #e7eef4; }
.admin-shell { display: grid; grid-template-columns: var(--nav) 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #0a3d30 0%, #0a2c38 100%);
  color: #e8f5ef; padding: 1rem .75rem calc(1rem + var(--safe-bottom));
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.sidebar .brand { color: #fff; margin: .15rem .35rem 1rem; font-size: 1.15rem; }
.side-nav a {
  display: flex; align-items: center; gap: .5rem;
  color: rgba(232,245,239,.78); padding: .72rem .8rem; border-radius: 12px;
  margin-bottom: .18rem; font-weight: 650; font-size: .92rem;
}
.side-nav a:hover, .side-nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.side-nav .sep { height: 1px; background: rgba(255,255,255,.12); margin: .65rem .35rem; }
.main { padding: 1rem 1.1rem calc(1.4rem + var(--safe-bottom)); min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .9rem;
}
.topbar h1 { font-family: var(--font-display); font-size: 1.35rem; margin: 0; letter-spacing: -0.03em; }
.menu-toggle {
  display: none; border: 0; background: #fff; border-radius: 12px; padding: .55rem .75rem;
  font-weight: 750; min-height: 42px; border: 1px solid var(--line); cursor: pointer;
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.login-card {
  width: min(420px, 100%); background: rgba(255,255,255,.94); border: 1px solid var(--line);
  border-radius: 24px; padding: 1.45rem; box-shadow: var(--shadow); animation: rise .45s ease both;
}
.login-card h1 { font-family: var(--font-display); margin: 0 0 .25rem; font-size: 1.55rem; }
.toast {
  position: fixed; left: 50%; bottom: calc(1rem + var(--safe-bottom)); z-index: 99;
  transform: translate(-50%, 140%); transition: transform .25s ease;
  background: var(--ink); color: #fff; padding: .78rem 1.05rem; border-radius: 14px;
  box-shadow: var(--shadow); max-width: calc(100vw - 2rem); font-weight: 650; font-size: .9rem;
}
.toast.show { transform: translate(-50%, 0); }
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,36,56,.48); display: none; place-items: end center;
  z-index: 80; padding: 0;
}
.modal-mask.show { display: grid; }
.modal {
  width: min(640px, 100%); background: #fff; border-radius: 22px 22px 0 0;
  padding: 1.15rem 1.15rem calc(1.15rem + var(--safe-bottom));
  max-height: 92vh; overflow: auto; animation: rise .25s ease;
}
.modal h3 { margin: 0 0 .9rem; font-family: var(--font-display); }
.modal-actions { display: flex; justify-content: flex-end; gap: .55rem; margin-top: 1rem; flex-wrap: wrap; }

.app-ico {
  width: 40px; height: 40px; border-radius: 10px; overflow: hidden; flex: none;
  background: linear-gradient(145deg, #dfe8ef, #c9d6e2);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(15,36,56,.08);
  position: relative;
}
.app-ico img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.app-ico.fallback::after,
.app-ico:has(img[src=""])::after {
  content: "App"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: .68rem; font-weight: 800; color: #6b8299; background: inherit;
}
.app-ico.sm { width: 34px; height: 34px; border-radius: 9px; }
.app-cell {
  display: flex; align-items: center; gap: .65rem; min-width: 140px; max-width: 280px;
}
.app-cell .meta { min-width: 0; }
.app-cell .name {
  font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px;
}
.app-cell .sub {
  color: var(--ink-soft); font-size: .75rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 180px;
}

.admin-bottom {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  padding: 0 .7rem calc(.55rem + var(--safe-bottom));
  pointer-events: none;
}
.admin-bottom-inner {
  pointer-events: auto;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: .2rem;
  background: rgba(255,255,255,.92); backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid rgba(15,36,56,.08);
  border-radius: 22px;
  padding: .4rem .35rem;
  box-shadow: 0 12px 36px rgba(15,36,56,.16), 0 2px 8px rgba(15,36,56,.06);
}
.admin-bottom a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .18rem; padding: .42rem .2rem .38rem; border-radius: 16px; color: #6b8299;
  font-size: .68rem; font-weight: 750; min-height: 54px; text-decoration: none;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.admin-bottom a:active { transform: scale(.96); }
.admin-bottom a.active {
  color: var(--teal-deep);
  background: linear-gradient(180deg, rgba(12,122,86,.14), rgba(12,122,86,.08));
}
.admin-bottom .ico {
  width: 28px; height: 28px; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(15,36,56,.05);
}
.admin-bottom a.active .ico {
  background: rgba(12,122,86,.16);
  color: var(--teal-deep);
}
.admin-bottom .ico svg {
  width: 18px; height: 18px; display: block;
}
.admin-bottom .lab { letter-spacing: .02em; }

.hint {
  background: var(--amber-soft); color: #7a5200; border-radius: 12px;
  padding: .7rem .85rem; font-size: .86rem; margin-bottom: .85rem;
}
.ua-box {
  display: none; margin-top: .55rem;
}
.ua-box.show { display: block; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes slideIn {
  from { transform: translateX(16px); opacity: .6; }
  to { transform: none; opacity: 1; }
}

@media (min-width: 901px) {
  .modal-mask { place-items: center; padding: 1rem; }
  .modal { border-radius: 20px; }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 1.1rem; padding-top: .8rem; }
  .grid-3, .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-links { display: none; }
  .nav-burger { display: inline-flex; }
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, 290px); z-index: 70;
    transform: translateX(-108%); transition: transform .24s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .main { padding: .85rem .85rem calc(5.6rem + var(--safe-bottom)); }
  .admin-bottom { display: block; }
  td, th { white-space: nowrap; }
  .toolbar .btn { flex: 1 1 auto; }
  .app-cell .name, .app-cell .sub { max-width: 120px; }
}

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat .n { font-size: 1.45rem; }
  .hero-panel { min-height: 260px; border-radius: 22px; }
  .container { width: min(1100px, calc(100% - 1.1rem)); }
  .topbar h1 { font-size: 1.15rem; }
}
