:root {
  --black: #0a0d0b;
  --panel: #121b16;
  --panel-2: #1a2620;
  --border: #2a3b32;
  --green: #1f7a4d;
  --green-bright: #35c476;
  --green-dim: #163d29;
  --white: #f5faf7;
  --muted: #9fb3a8;
  --danger: #e2574c;
  --radius: 12px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--black);
  color: var(--white);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--green-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

/* ---------- App shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 20px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--green-bright), var(--green-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #04150c;
}

.brand-name {
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.15;
}
.brand-sub { color: var(--muted); font-size: 0.72rem; }

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
}

.nav-link:hover { background: var(--panel-2); color: var(--white); text-decoration: none; }
.nav-link.active { background: var(--green-dim); color: var(--green-bright); }
.nav-icon { width: 20px; text-align: center; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.logout-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

.main {
  flex: 1;
  min-width: 0;
  padding: 22px 28px 90px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-title { font-size: 1.5rem; font-weight: 800; margin: 0; }
.page-sub { color: var(--muted); margin: 4px 0 0; font-size: 0.9rem; }

/* ---------- Mobile bottom nav ---------- */

.mobile-topbar { display: none; }
.bottom-nav { display: none; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { display: none; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .main { padding: 16px 14px 90px; }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--panel);
    border-top: 1px solid var(--border);
    z-index: 20;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav .nav-link {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    font-size: 0.68rem;
    text-align: center;
    padding: 7px 2px;
  }
  .bottom-nav .nav-icon { font-size: 1.15rem; }
}

/* ---------- Cards / panels ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card + .card { margin-top: 16px; }

.grid {
  display: grid;
  gap: 16px;
}
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-value { font-size: 1.9rem; font-weight: 800; color: var(--green-bright); }
.stat-label { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }

h1, h2, h3 { margin-top: 0; }
h2 { font-size: 1.1rem; }

.muted { color: var(--muted); }

/* ---------- Forms ---------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--black);
  border: 1px solid var(--border);
  color: var(--white);
  border-radius: 8px;
  padding: 11px 12px;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--green-bright);
}
.field textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--green-bright);
  color: #04150c;
  border: 0;
  padding: 12px 18px;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary { background: var(--panel-2); color: var(--white); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; }

.alert {
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 0.88rem;
  margin-bottom: 14px;
}
.alert-error { background: #3a1414; color: #ffb0a8; border: 1px solid #5c1f1a; }
.alert-success { background: var(--green-dim); color: var(--green-bright); border: 1px solid #235c3d; }

/* ---------- Tables / lists ---------- */

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; color: var(--muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge-sim { background: var(--green-dim); color: var(--green-bright); }
.badge-out { background: #1a2f4a; color: #7fb3ff; }
.badge-in { background: #3a2f1a; color: #ffcf7f; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

.search-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-row input { flex: 1; min-width: 200px; }

.contact-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; }
.contact-row .name { font-weight: 700; }
.contact-row .phone { color: var(--muted); font-size: 0.88rem; }
.row-actions { display: flex; gap: 8px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center;
  z-index: 50; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-close { background: none; border: 0; color: var(--muted); font-size: 1.3rem; cursor: pointer; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card { width: 100%; max-width: 360px; }

.kv-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--muted); }

.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 600; }
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.status-off .dot { background: var(--danger); }
.status-sim .dot { background: #ffb066; }
