:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #5f6b7a;
  --line: #dde3ea;
  --primary: #1f4e79;
  --primary-text: #ffffff;
  --ok: #1e8e3e;
  --ok-bg: #e6f4ea;
  --bad: #c5221f;
  --bad-bg: #fce8e6;
  --warn: #b26a00;
  --warn-bg: #fff4e0;
  --neutral: #8a94a3;
  --neutral-bg: #eef1f5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
}
body.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 8px; }
h2 { font-size: 1.2rem; margin: 20px 0 10px; }
h3 { font-size: 1rem; margin: 0; }
p { margin: 8px 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.muted { color: var(--muted); }
.error { color: var(--bad); }
.small { font-size: .85rem; }
.inline { display: inline; }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary);
  color: var(--primary-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.brand { color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .btn-ghost { color: inherit; border-color: rgba(255,255,255,.4); white-space: nowrap; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; }
.pill {
  background: rgba(255,255,255,.18);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: .8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}
.pill:empty { display: none; }

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  padding: 0 8px;
}
.tabs a {
  flex: 1 0 auto;
  text-align: center;
  padding: 12px 10px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

.container { max-width: 900px; margin: 0 auto; padding: 16px; padding-bottom: 48px; }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card .btn { margin-top: 12px; }
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link:active { background: #eef3f8; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* Buttons & inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  min-height: 44px;
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn-danger { color: var(--bad); border-color: var(--bad); background: var(--card); }
.btn-ok { color: var(--ok); border-color: var(--ok); }
.btn-ok.on { background: var(--ok); color: #fff; }
.btn-bad { color: var(--bad); border-color: var(--bad); }
.btn-bad.on { background: var(--bad); color: #fff; }

input[type=text], input[type=email], input[type=search], select, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}
input[type=file] { font: inherit; max-width: 100%; }
label.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.search { margin-bottom: 12px; }

/* Progress */
.progress { height: 8px; background: var(--neutral-bg); border-radius: 999px; overflow: hidden; display: flex; margin-top: 8px; }
.progress .ok { background: var(--ok); }
.progress .bad { background: var(--bad); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-neutral { background: var(--neutral-bg); color: var(--muted); }
.badge-cat { background: var(--neutral-bg); color: var(--primary); }

/* Weapon card */
.weapon { border-left: 5px solid var(--neutral); }
.weapon.ok { border-left-color: var(--ok); }
.weapon.bad { border-left-color: var(--bad); }
.weapon-title { font-weight: 700; font-size: 1.05rem; }
.weapon-nr { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.1rem; font-weight: 700; }
.weapon-meta { color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; }
.weapon-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.weapon-note { margin-top: 8px; }
.weapon-note input { min-height: 40px; }
.weapon-checked { font-size: .8rem; color: var(--muted); margin-top: 6px; }

/* Summary strip */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.summary .card { margin: 0; text-align: center; padding: 10px; }
.summary .num { font-size: 1.6rem; font-weight: 700; }
.summary .ok .num { color: var(--ok); }
.summary .bad .num { color: var(--bad); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }

/* Tables (desktop) */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1c2430;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: 90vw;
}
.toast.error { background: var(--bad); }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

@media (max-width: 600px) {
  #me-email, #me-sep { display: none; }
  .topbar .btn-ghost { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
  .pill { max-width: 34vw; }
}

@media (min-width: 700px) {
  .weapon-actions { grid-template-columns: 160px 160px 1fr; align-items: center; }
  .weapon-note { margin-top: 0; }
}
