/* ============================================================
   Components — cards, tables, modal, toast, top nav
   ============================================================ */

/* Public top nav */
.nav {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  display: flex; align-items: center;
  background: rgba(10,15,30,.72); backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .25s, background .25s;
}
.nav.scrolled { border-bottom-color: var(--border); background: rgba(10,15,30,.92); }
.nav .wrap { display: flex; align-items: center; justify-content: space-between; }
.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-links a { color: var(--muted); font-weight: 600; font-size: .92rem; }
.nav-links a:hover { color: #fff; }
.nav-cta { display: flex; align-items: center; gap: 12px; }

/* Brand mark */
.brand { display: inline-flex; align-items: center; gap: 11px; font-family: var(--f-display); font-weight: 700; font-size: 1.18rem; color: #fff; letter-spacing: -.01em; }
.brand-glyph {
  width: 34px; height: 34px; border-radius: 9px; position: relative; flex: none;
  background: linear-gradient(135deg, var(--amber), #ff8a3c);
  box-shadow: 0 6px 18px -6px var(--amber);
  display: grid; place-items: center;
}
.brand-glyph::before { content:""; width:12px; height:12px; border:2.5px solid #1a1300; border-radius:50%; }
.brand-glyph::after { content:""; position:absolute; width:5px; height:5px; background:#1a1300; border-radius:50%; }
.brand small { font-family: var(--f-mono); font-size: .6rem; letter-spacing: .25em; color: var(--amber); display:block; line-height:1; margin-top:2px; }

/* Cards */
.card {
  background: linear-gradient(180deg, var(--card), var(--panel));
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 24px; box-shadow: var(--shadow-sm);
}

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r);
  padding: 18px 18px 16px; position: relative; overflow: hidden;
}
.stat::after { content:""; position:absolute; inset:0 0 auto 0; height:3px; background: var(--accent, var(--sky)); opacity:.85; }
.stat .k { font-family: var(--f-mono); font-size: .72rem; letter-spacing:.14em; text-transform:uppercase; color: var(--muted); }
.stat .v { font-family: var(--f-display); font-size: 2rem; font-weight: 700; margin-top: 6px; }
.stat .sub { font-size: .78rem; color: var(--faint); margin-top: 2px; }

/* Tables */
.table-wrap { border: 1px solid var(--border); border-radius: var(--r-lg); overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--panel); }
.table-wrap table.tbl { min-width: 640px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl thead th {
  text-align: left; padding: 14px 16px; font-family: var(--f-mono);
  font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  background: #0e1525; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border-soft); border-bottom-color: #1c2542; vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: #131c33; }
.cell-name { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 700; font-size: .85rem; color: #06121f;
  background: linear-gradient(135deg, var(--sky), #9b8cff);
}
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--muted); transition: .15s;
}
.icon-btn:hover { color:#fff; border-color: var(--sky); }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.search { position: relative; flex: 1; max-width: 340px; }
.search .input { padding-left: 40px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); }

/* Modal */
.modal-back {
  position: fixed; inset: 0; z-index: 100; background: rgba(5,8,16,.7); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-back.open { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 480px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow); transform: translateY(12px) scale(.98); transition: transform .2s;
  max-height: 90vh; overflow: auto;
}
.modal-back.open .modal { transform: none; }
.modal-head { display:flex; align-items:center; justify-content:space-between; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* Toast */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 10px; }
.toast {
  background: var(--card-2); border: 1px solid var(--border); border-left: 3px solid var(--green);
  border-radius: var(--r-sm); padding: 13px 16px; min-width: 240px; box-shadow: var(--shadow);
  font-size: .9rem; animation: toast-in .25s ease;
}
.toast.err { border-left-color: var(--red); }
.toast.info{ border-left-color: var(--sky); }
@keyframes toast-in { from { opacity:0; transform: translateX(20px); } }

@media (max-width: 860px) { .stat-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 720px) { .nav-links { display: none; } }
