:root {
  --bg: #ffffff;
  --text: #111827;          /* near-black */
  --muted: #6b7280;         /* gray */
  --border: #e5e7eb;
  --card: #ffffff;
  --blue: #2563eb;
  --blue-600: #1d4ed8;
  --blue-50: #eff6ff;
  --danger: #dc2626;
  --shadow: 0 6px 24px rgba(17,24,39,0.06);
  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}

.brand { display:flex; align-items:center; gap:10px; font-weight: 700; color: var(--text); }
.brandLogo {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  display: none;
  object-fit: contain;
  background: transparent;
  border: none;
}
.nav { display:flex; gap: 10px; align-items:center; flex-wrap: wrap; }
.nav a, .nav button {
  font: inherit;
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
}
.nav a.active { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.nav button.primary, .btn.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}
.nav button.primary:hover, .btn.primary:hover { background: var(--blue-600); border-color: var(--blue-600); }

.container { max-width: 980px; margin: 0 auto; padding: 18px 16px 60px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 14px 0;
}

.h1 { font-size: 22px; margin: 0 0 10px; }
.h2 { font-size: 18px; margin: 0 0 10px; }
.p { color: var(--muted); margin: 0 0 12px; }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 720px) {
  .grid.cols2 { grid-template-columns: 1fr 1fr; }
  .grid.cols3 { grid-template-columns: 1fr 1fr 1fr; }
}

.field label {
  display:block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font: inherit;
  outline: none;
  background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.row { display:flex; gap: 10px; align-items:center; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--border);
  background: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}
.btn:hover { border-color: #d1d5db; }
.btn.danger { border-color: rgba(220,38,38,0.4); color: var(--danger); }
.badge {
  display:inline-flex; align-items:center; gap:6px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}
.kv { display:grid; grid-template-columns: 160px 1fr; gap: 10px; }
.kv .k { color: var(--muted); font-size: 13px; }
.kv .v { font-weight: 600; }

.table {
  width:100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  text-align:left;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.table th { color: var(--muted); font-weight: 600; }
.table tr:hover td { background: rgba(37,99,235,0.03); }

.notice {
  border: 1px solid rgba(37,99,235,0.25);
  background: rgba(37,99,235,0.06);
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
}
.error {
  border: 1px solid rgba(220,38,38,0.28);
  background: rgba(220,38,38,0.06);
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: #f3f4f6;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 12.5px; }
.footer {
  border-top: 1px solid var(--border);
  padding: 16px;
  color: var(--muted);
  text-align:center;
}


.notifBubble{
  margin-left:6px;
  min-width:18px;
  height:18px;
  padding:0 6px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  border:1px solid var(--border);
  font-size:12px;
  line-height:18px;
  background:#fff;
  color:var(--text);
}

/* Toasts (live WS notifications) */
.toastWrap{
  position:fixed;
  top: 12px;
  right: 12px;
  z-index: 9999;
  display:flex;
  flex-direction:column;
  gap: 10px;
  pointer-events:none;
}
.toast{
  pointer-events:auto;
  max-width: 320px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: 14px;
  padding: 12px 12px;
  color: var(--text);
}
.toast a{ color: var(--blue); text-decoration:none; font-weight:700; }
.toast.error{ border-color: rgba(220,38,38,0.35); }
.toast.success{ border-color: rgba(22,163,74,0.35); }


/* --- Auth pages --- */
.authWrap{
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 0;
  min-height: calc(100dvh - 140px); /* header+footer allowance */
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.authLogoWrap{
  display: flex;
  justify-content: center;
  margin: 0 0 16px;
}
.authLogo{
  width: 220px;
  height: 220px;
  object-fit: contain;
  border: none;
  background: transparent;
  border-radius: 18px;
}
.authCard{ margin: 0; }

/* --- Mobile responsiveness tweaks --- */
@media (max-width: 720px){
  .topbar{ padding: 10px 12px; gap: 10px; }
  .brand{ gap: 8px; }
  .brandLogo{ width: 56px; height: 56px; border-radius: 16px; }
  .nav{ gap: 8px; }
  .nav a, .nav button{ padding: 7px 9px; border-radius: 10px; font-size: 13px; }
  .container{ padding: 14px 12px 54px; }
  .kv{ grid-template-columns: 120px 1fr; }
  .avatar{ width: 52px; height: 52px; border-radius: 14px; }
  .authWrap{ padding: 18px 0; min-height: calc(100dvh - 130px); }
  .authLogo{ width: 120px; height: 120px; border-radius: 16px; }
}

/* Make wide tables usable on mobile */
@media (max-width: 720px){
  .table{
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}
