@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@600;700&family=JetBrains+Mono:wght@600&display=swap');

:root {
  --navy-950: #0f1b2e;
  --navy-800: #1c2e4a;
  --navy-700: #2a4162;
  --amber-500: #d9a441;
  --amber-600: #bd8a2c;
  --paper: #f4f2ec;
  --card: #ffffff;
  --ink: #17202b;
  --muted: #707a87;
  --border: #e9e5da;
  --success: #2f7d4f;
  --success-bg: #e6f6ec;
  --danger: #c1442c;
  --danger-bg: #fceae5;
  --neutral-bg: #eef0f2;
  --neutral-ink: #55606b;
  --shadow-sm: 0 1px 3px rgba(15, 27, 46, 0.06), 0 1px 2px rgba(15, 27, 46, 0.08);
  --shadow-md: 0 4px 14px rgba(15, 27, 46, 0.10);
  --shadow-lg: 0 10px 30px rgba(15, 27, 46, 0.18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: #ddd8cb;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  height: 100%;
  overscroll-behavior: none;
}

h1, h2, h3, .app-header h1 {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.app-shell {
  max-width: 500px;
  margin: 0 auto;
  background: var(--paper);
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overscroll-behavior: contain;
}

/* ---- Header ---- */
.app-header {
  background: var(--navy-950);
  color: #fff;
  padding: 20px 20px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-radius: 0 0 20px 20px;
}
.app-header .htext { flex: 1; min-width: 0; }
.app-header h1 { font-size: 19px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-header .hsub { font-size: 12.5px; color: #b6c2d4; margin-top: 1px; }
.barrier-mark {
  width: 36px; height: 36px;
  background-image: url('logo.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
}
.header-chip {
  background: rgba(255,255,255,0.12);
  color: var(--amber-500);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
  flex-shrink: 0;
}

/* ---- Content ---- */
.content { flex: 1; padding: 20px 18px 110px; overscroll-behavior-y: contain; }

/* ---- Cards ---- */
.card { background: var(--card); border-radius: 20px; padding: 22px 20px; margin-bottom: 16px; box-shadow: var(--shadow-md); }
.card h2 { font-size: 16px; margin: 0 0 14px; }

.stat-card { background: var(--card); border-radius: 18px; padding: 20px 22px; margin-bottom: 12px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 16px; }
.stat-card .sicon { width: 54px; height: 54px; border-radius: 16px; background: var(--neutral-bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--navy-800); }
.stat-card .sicon svg { width: 26px; height: 26px; }
.stat-card.icon-amber .sicon { background: #fff2d6; color: #9a6a00; }
.stat-card.icon-blue .sicon { background: #e5eefc; color: #2a5aa8; }
.stat-card.icon-purple .sicon { background: #f0e8fb; color: #6b3fa0; }
.stat-card .svalue { font-size: 28px; }

/* ---- Avatar circle (members/devices lists) ---- */
.avatar-circle {
  width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--navy-950), var(--navy-800));
  color: var(--amber-500);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; font-family: "Space Grotesk", sans-serif;
}
.avatar-circle.status-pending { background: linear-gradient(135deg, #b98a1f, #9a6a00); color: #fff2d6; }
.avatar-circle.status-rejected { background: linear-gradient(135deg, #8f3423, #6f2717); color: #fbdcd2; }
.avatar-circle svg { width: 22px; height: 22px; }
.stat-card .sinfo { flex: 1; min-width: 0; }
.stat-card .svalue { font-size: 26px; font-weight: 700; font-family: "Space Grotesk", sans-serif; line-height: 1.1; }
.stat-card .slabel { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.stat-card .sarrow { color: var(--muted); flex-shrink: 0; }
.stat-card .sarrow svg { width: 18px; height: 18px; }

/* ---- Section ---- */
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 14px; }
.section-head h2 { font-size: 17px; margin: 0; font-weight: 700; }
.section-head a, .section-head .link-btn { font-size: 14px; color: var(--navy-800); text-decoration: none; font-weight: 700; background: none; border: none; cursor: pointer; padding: 0; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 5px 13px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.badge.pending { background: #fff2d6; color: #9a6a00; }
.badge.verified, .badge.active, .badge.success { background: var(--success-bg); color: var(--success); }
.badge.rejected, .badge.inactive, .badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral-ink); }

/* ---- List item card (members, units, devices) ---- */
.item-card { background: var(--card); border-radius: 18px; padding: 18px 20px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.item-card .irow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.item-card .ititle { font-weight: 700; font-size: 16.5px; }
.item-card .isub { font-size: 13.5px; color: var(--muted); margin-top: 3px; font-weight: 500; }
.item-card .isub code {
  font-family: "JetBrains Mono", monospace;
  background: var(--neutral-bg);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11.5px;
  display: inline-block;
  max-width: 100%;
  word-break: break-all;
  overflow-wrap: break-word;
  white-space: normal;
  vertical-align: top;
}
.item-card.clickable { cursor: pointer; }

.chevron { display: inline-block; color: var(--muted); transition: transform 0.15s; flex-shrink: 0; }
.chevron svg { width: 18px; height: 18px; }
.chevron.open { transform: rotate(90deg); }

.subpanel { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.subitem { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 13.5px; border-bottom: 1px dashed var(--border); }
.subitem:last-child { border-bottom: none; }

.empty { text-align: center; color: var(--muted); font-size: 14.5px; padding: 32px 20px; background: var(--card); border: 1.5px dashed var(--border); border-radius: 18px; font-weight: 500; }
.empty .barrier-mark { margin: 0 auto 14px; }

/* ---- Forms ---- */
label { display: block; font-size: 13.5px; font-weight: 700; color: #44505c; margin-bottom: 6px; margin-top: 16px; }
label:first-child { margin-top: 0; }
input, select {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font-size: 16px;
  background: #fff;
  font-family: inherit;
  color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--amber-500); box-shadow: 0 0 0 4px rgba(217, 164, 65, 0.18); }

button {
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  border: none;
  background: var(--navy-950);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; }
button.secondary { background: transparent; border: 1.5px solid var(--border); color: var(--ink); }
button.danger { background: var(--danger); }
button.success-btn { background: var(--success); }
button.small { width: auto; padding: 8px 14px; font-size: 12.5px; border-radius: 10px; }
button.text-link { width: auto; background: none; border: none; color: var(--navy-800); text-decoration: none; font-weight: 700; font-size: 14px; padding: 0; }

.alert { background: var(--danger-bg); color: var(--danger); padding: 13px 16px; border-radius: 14px; font-size: 14.5px; margin-bottom: 16px; font-weight: 600; }
.alert.success { background: var(--success-bg); color: var(--success); }

.search-bar { position: relative; margin-bottom: 16px; }
.search-bar input { padding-left: 44px; }
.search-bar .search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }

.pill-switch { display: flex; background: var(--neutral-bg); border-radius: 14px; padding: 4px; margin-bottom: 18px; }
.pill-switch button { flex: 1; background: none; color: var(--neutral-ink); padding: 10px; font-size: 13.5px; border-radius: 11px; box-shadow: none; }
.pill-switch button.active { background: var(--card); color: var(--navy-950); box-shadow: var(--shadow-sm); }
.pill-switch button:active { transform: none; }

.skeleton { background: linear-gradient(90deg, #eae7dd 25%, #f3f1e9 37%, #eae7dd 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---- Floating Action Button ---- */
.fab {
  position: fixed;
  right: calc(50% - 250px + 20px);
  bottom: 96px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--amber-500);
  color: var(--navy-950);
  border: none;
  font-size: 30px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(217, 164, 65, 0.5), 0 2px 6px rgba(0,0,0,0.15);
  cursor: pointer;
  z-index: 25;
  transition: transform 0.12s ease;
  line-height: 1;
  padding: 0;
}
.fab:active { transform: scale(0.92); }
.fab:disabled { opacity: 0.4; box-shadow: none; }
.fab svg { width: 26px; height: 26px; }
@media (max-width: 500px) { .fab { right: 20px; } }

/* ---- Bottom sheet ---- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(15, 27, 46, 0.45);
  z-index: 30; display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; max-width: 500px; background: var(--card);
  border-radius: 24px 24px 0 0; padding: 10px 22px 26px;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.2);
  transform: translateY(100%); transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 88vh; overflow-y: auto;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-handle { width: 40px; height: 5px; background: var(--border); border-radius: 999px; margin: 6px auto 16px; }
.sheet-title { font-size: 19px; font-weight: 700; margin-bottom: 2px; font-family: "Space Grotesk", sans-serif; }
.sheet-sub { font-size: 13.5px; color: var(--muted); margin-bottom: 18px; font-weight: 500; }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; margin: 20px 0 6px; }
.section-label:first-child { margin-top: 0; }

/* ---- Bottom nav ---- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 500px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 10px 6px calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  box-shadow: 0 -2px 12px rgba(15,27,46,0.06);
}
.nav-tab {
  flex: 1; background: none; border: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; cursor: pointer; color: var(--muted);
  font-size: 10.5px; font-weight: 700; font-family: inherit; border-radius: 14px;
}
.nav-tab .nav-icon-wrap { width: 40px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 14px; transition: background 0.15s ease; }
.nav-tab .nav-icon-wrap svg { width: 22px; height: 22px; }
.nav-tab.active { color: var(--navy-950); }
.nav-tab.active .nav-icon-wrap { background: #fff0d6; }
.nav-tab:active .nav-icon-wrap { background: var(--neutral-bg); }

/* ---- Profile rows (More page) ---- */
.profile-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.profile-row:last-child { border-bottom: none; }
.profile-row .plabel { color: var(--muted); font-weight: 600; }
.profile-row .pvalue { font-weight: 700; text-align: right; }

.menu-row { display: flex; align-items: center; gap: 14px; padding: 16px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.menu-row:last-child { border-bottom: none; }
.menu-row .micon { width: 40px; height: 40px; border-radius: 12px; background: var(--neutral-bg); display: flex; align-items: center; justify-content: center; color: var(--navy-800); flex-shrink: 0; }
.menu-row .micon svg { width: 20px; height: 20px; }
.menu-row .mtext { flex: 1; font-weight: 700; font-size: 15px; }
.menu-row .mchevron { color: var(--muted); }
.menu-row .mchevron svg { width: 18px; height: 18px; }

/* ---- Auth pages ---- */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px 0; }
.auth-shell { width: 100%; max-width: 500px; padding: 0 20px; }
.auth-card { background: var(--card); border-radius: 24px; padding: 32px 26px; box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 26px; }
.auth-brand span:last-child { font-size: 19px; font-weight: 700; font-family: "Space Grotesk", sans-serif; color: var(--navy-950); }
.switch-link { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); font-weight: 500; }
.switch-link a { color: var(--navy-800); font-weight: 700; text-decoration: none; }
.code-chip { display: inline-flex; align-items: center; gap: 7px; background: var(--navy-950); color: var(--amber-500); padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 700; font-family: "JetBrains Mono", monospace; }

/* ---- Quick-fill / group blocks (Units page) ---- */
.group-block { border: 1.5px dashed var(--border); border-radius: 16px; padding: 16px; margin-bottom: 14px; background: #fbfaf5; }
.unit-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.unit-row input { flex: 1; }
.unit-row button.small { padding: 10px 12px; }

.hidden { display: none !important; }
.bottom-nav.kb-hidden { display: none !important; }
.sub { color: var(--muted); font-size: 13.5px; font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
