:root {
  --brand: #006a4e;
  --brand-2: #00553f;
  --dot: #f42a41;
  --bg: #f6f7f5;
  --card: #ffffff;
  --text: #17201c;
  --muted: #5f6b66;
  --line: #dfe4e1;
  --ok-bg: #e5f4ec;
  --ok: #0b6b3f;
  --err-bg: #fde8ea;
  --err: #a8162a;
  --info-bg: #fff5d6;
  --info: #7a5a00;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #19a57c;
    --brand-2: #138763;
    --bg: #101614;
    --card: #18201d;
    --text: #e6ece9;
    --muted: #97a39e;
    --line: #2a3531;
    --ok-bg: #12301f;
    --ok: #7fdcaa;
    --err-bg: #3a1419;
    --err: #ff9aa6;
    --info-bg: #332a0c;
    --info: #f1d27a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "Noto Sans Bengali", Roboto, sans-serif;
}

a {
  color: var(--brand);
}

h1 {
  font-size: 1.6rem;
  margin: 0 0 0.4rem;
}

h2 {
  font-size: 1.15rem;
  margin: 0 0 0.8rem;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.2rem 0;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}
.center {
  text-align: center;
}
.right {
  text-align: right;
}
.nowrap {
  white-space: nowrap;
}
.break {
  word-break: break-all;
}
.bn {
  font-weight: 500;
  color: var(--muted);
}

/* ---------- top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}
.topbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.topbar nav a,
.topbar nav .link {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
.topbar nav a.active,
.topbar nav a:hover,
.topbar nav .link:hover {
  background: var(--bg);
}

/* ---------- logo */
.logo {
  flex: none;
}
/*
 * Loading, on a 2s loop: the arc flies over the head (0-35%), the fist winds up (35-48%),
 * punches the arrow in (50-55%), bonk + head wobble (55-80%), then everything fades.
 */
.logo .head,
.logo .bonk,
.logo .shot {
  transform-box: view-box;
}
.logo .head {
  transform-origin: 24px 48px;
}
.logo .bonk {
  transform-origin: 36px 38px;
}
.logo .shot {
  transform-origin: 42px 42px;
}
.logo.spin .arc {
  stroke-dasharray: 100;
  animation: ghurano-arc 2s ease-in infinite;
}
.logo.spin .tip {
  animation: ghurano-tip 2s linear infinite;
}
.logo.spin .fist {
  animation: ghurano-punch 2s ease-in-out infinite;
}
.logo.spin .shot {
  animation: ghurano-shot 2s ease-out infinite;
}
.logo.spin .bonk {
  animation: ghurano-bonk 2s ease-out infinite;
}
.logo.spin .head {
  animation: ghurano-wobble 2s ease-out infinite;
}
@keyframes ghurano-arc {
  0% {
    stroke-dashoffset: 100;
    opacity: 1;
  }
  35%,
  85% {
    stroke-dashoffset: 0;
    opacity: 1;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 0;
  }
}
@keyframes ghurano-tip {
  0%,
  33% {
    opacity: 0;
  }
  35%,
  85% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
@keyframes ghurano-punch {
  0%,
  35% {
    transform: translateX(0);
  }
  48% {
    transform: translateX(4px);
  }
  54% {
    transform: translateX(-3px);
  }
  66%,
  100% {
    transform: translateX(0);
  }
}
@keyframes ghurano-shot {
  0%,
  49% {
    opacity: 0;
    transform: scale(0.3);
  }
  55%,
  85% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
  }
}
@keyframes ghurano-bonk {
  0%,
  54% {
    opacity: 0;
    transform: scale(0.4);
  }
  60% {
    opacity: 1;
    transform: scale(1.25);
  }
  75% {
    opacity: 1;
    transform: scale(1);
  }
  86%,
  100% {
    opacity: 0;
  }
}
@keyframes ghurano-wobble {
  0%,
  55% {
    transform: rotate(0);
  }
  60% {
    transform: rotate(-16deg);
  }
  67% {
    transform: rotate(10deg);
  }
  74% {
    transform: rotate(-5deg);
  }
  80%,
  100% {
    transform: rotate(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .logo.spin * {
    animation: none !important;
  }
}

/* ---------- cards, forms */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card.narrow {
  max-width: 400px;
  width: 100%;
}
details.card summary {
  cursor: pointer;
  list-style: none;
}
details.card summary::-webkit-details-marker {
  display: none;
}
details.card[open] summary {
  margin-bottom: 14px;
}

body.centered main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.login-head {
  text-align: center;
  margin-bottom: 16px;
}
.login-head h1 {
  margin-top: 8px;
}
.status-code {
  font-size: 3rem;
  font-weight: 800;
  margin: 8px 0 0;
  color: var(--dot);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 500;
}
label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}
input,
select {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  min-width: 0;
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}
input:focus,
select:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
.input-row {
  display: flex;
  gap: 6px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px 16px;
}
.grid-2 > .card {
  margin-bottom: 0;
}
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 0 0 16px;
}
.facts dt {
  color: var(--muted);
}
.facts dd {
  margin: 0;
}

.button,
button {
  font: inherit;
  cursor: pointer;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.button:hover {
  background: var(--brand-2);
}
.button.secondary {
  background: transparent;
  color: var(--brand);
}
.button.secondary:hover {
  background: var(--bg);
}
.button.danger {
  background: var(--dot);
  border-color: var(--dot);
}
.button.small {
  padding: 5px 10px;
  font-size: 0.85rem;
}
.button.wide {
  width: 100%;
}
.button:disabled,
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button.link {
  background: none;
  border: 0;
}
.icon {
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: inherit;
  padding: 4px 8px;
  text-decoration: none;
  font-size: 1rem;
  line-height: 1.2;
}
.icon:hover:not(:disabled) {
  border-color: var(--line);
  background: var(--bg);
}
form.inline {
  display: inline;
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.card .actions {
  justify-content: flex-start;
}

/* ---------- flash, badges */
.flash {
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  transition: opacity 0.4s;
}
.flash.ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.flash.error {
  background: var(--err-bg);
  color: var(--err);
}
.flash.info {
  background: var(--info-bg);
  color: var(--info);
}
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge.ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.badge.off {
  background: var(--err-bg);
  color: var(--err);
}
.badge.admin {
  background: var(--brand);
  color: #fff;
}
.badge.warn {
  background: var(--info-bg);
  color: var(--info);
}

/* ---------- home */
.hero {
  margin: 8px 0 20px;
}
.filter {
  max-width: 360px;
  margin-top: 8px;
}
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
}
.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.site-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.12s, border-color 0.12s;
}
.site-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
}
.site-card .go {
  margin-left: auto;
  color: var(--brand);
  font-size: 1.3rem;
}
.site-icon {
  position: relative;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.2rem;
  overflow: hidden;
}
.site-icon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--card);
  padding: 6px;
}
.site-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.site-text > * {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- admin */
.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.tabs {
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
}
.tabs a {
  padding: 6px 14px;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
}
.tabs a.active {
  background: var(--brand);
  color: #fff;
}
.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
th.right,
td.right {
  text-align: right;
}
tr:last-child td {
  border-bottom: 0;
}
td .button,
td form {
  margin-left: 4px;
}
.danger-zone {
  border-color: var(--err-bg);
}
.pager {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 16px;
}

/* ---------- browsing shell */
body.shell {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.shell main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
}
.shell-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.shell-bar .site-name {
  font-weight: 600;
  margin: 0 6px;
  white-space: nowrap;
}
.shell-bar .address {
  flex: 1;
  padding: 5px 10px;
  font-size: 0.85rem;
  color: var(--muted);
}
#frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}
.shell-loader {
  position: absolute;
  inset: 48px 0 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 5;
  font-size: 1.15rem;
  transition: opacity 0.35s;
}
.shell-loader.gone {
  opacity: 0;
  pointer-events: none;
}
.toast {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand);
  color: #fff;
  padding: 8px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
  z-index: 6;
  font-weight: 600;
  transition: opacity 0.4s;
}
.toast.fade {
  opacity: 0;
}

@media (max-width: 640px) {
  .shell-bar .site-name,
  .shell-bar [data-action="forward"] {
    display: none;
  }
  h1 {
    font-size: 1.35rem;
  }
  th,
  td {
    padding: 8px 10px;
  }
}
