:root {
  --bg: #0f1117;
  --panel: #171a22;
  --panel2: #1e222d;
  --border: #2a2f3d;
  --text: #e6e8ee;
  --muted: #8b91a0;
  --accent: #2f81f7;
  --accent2: #58a6ff;
  --ok: #2ea043;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel2);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent2); }

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px; background: var(--panel); border-right: 1px solid var(--border);
  padding: 16px 10px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px;
}
.sidebar .brand { font-size: 16px; font-weight: 700; padding: 6px 10px 16px; }
.sidebar .brand span { color: var(--accent2); }
.sidebar a {
  display: block; color: var(--text); text-decoration: none; padding: 9px 10px;
  border-radius: 8px;
}
.sidebar a:hover { background: var(--panel2); }
.sidebar a.active { background: var(--accent); color: #fff; }
.sidebar .grow { flex: 1; }
.sidebar .who { padding: 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.sidebar .logout { color: var(--muted); }

/* Main */
.main { flex: 1; padding: 20px 26px; min-width: 0; }
.main h1 { font-size: 20px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 260px; }
.toolbar .btn { width: auto; }

.btn {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: 8px; white-space: nowrap;
}
.btn:hover { border-color: var(--accent2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad); color: #fff; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Cards / grid */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; margin-top: 2px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 12px; font-size: 15px; }

/* Tables */
.tbl-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; background: var(--panel2); }
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; width: 1%; }
td.actions .btn { margin-right: 6px; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.adm { background: #3b1d1f; color: #ff9e9a; }
.badge.off { background: #15263b; color: #7fc1ff; }
.badge.mem { background: #12291a; color: #6fd08c; }
.badge.gst { background: #2a2412; color: #e5c068; }
.badge.active { background: #12291a; color: #6fd08c; }
.badge.inactive { background: #241a1a; color: #d08c8c; }
.badge.scraped { background: #14323c; color: #6fd2d8; }
.pill { color: var(--muted); font-size: 12px; }
.cat { background: var(--panel2); color: var(--muted); border: 1px solid var(--border); padding: 2px 9px; border-radius: 20px; font-size: 12px; }

/* Status colors for trips */
.st { font-weight: 600; }
.st.CONFIRMED, .st.PLANNED, .st.UPCOMING { color: #6fd08c; }
.st.COMPLETED { color: #8b91a0; }
.st.CANCELLED { color: #d08c8c; }
.st.DRAFT { color: #e5c068; }

/* Media grid */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.mcell { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.mcell img { width: 100%; height: 110px; object-fit: cover; display: block; background: #000; }
.mcell .meta { padding: 8px 10px; font-size: 12px; color: var(--muted); flex: 1; }
.mcell .meta b { color: var(--text); display: block; margin-bottom: 2px; }
.mcell .row { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow: auto; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 560px; padding: 20px 22px; }
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal .f { margin-bottom: 12px; }
.modal label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal .btn { width: auto; }

/* Toast */
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* Login */
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
.login { width: 360px; max-width: 92vw; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 26px 28px; }
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login p { color: var(--muted); margin: 0 0 18px; }
.login .f { margin-bottom: 14px; }
.login .error { color: var(--bad); margin: 0 0 12px; font-size: 13px; min-height: 18px; }
.login .btn { width: 100%; padding: 10px; }

/* Responsive */
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar .brand { padding: 0 10px 0; }
  .sidebar .who { border: none; padding: 4px 10px; }
  .main { padding: 14px; }
}