*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg:          #0f0d0b;
  --bg2:         #1a1714;
  --bg3:         #232019;
  --border:      #2e2a25;
  --text:        #e8e2d9;
  --text-soft:   #9a9186;
  --accent:      #7b1c2e;
  --accent-h:    #9b2438;
  --accent-text: #fff;
  --green:       #2a6b52;
  --red:         #8b1c1c;
  --red-h:       #a52222;
  --radius:      8px;
  --sidebar-w:   228px;
  --topbar-h:    56px;
  --font:        'DM Sans', system-ui, sans-serif;
  --shadow:      0 2px 12px rgba(0,0,0,0.4);
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-shrink: 0;
}
.brand-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}
.brand-logo span { color: var(--accent); }
.brand-sub {
  font-size: 0.7rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1rem;
  color: var(--text-soft);
  text-decoration: none;
  border-radius: var(--radius);
  margin: 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.nav-item:hover  { background: var(--bg3); color: var(--text); }
.nav-item.is-active { background: var(--accent); color: var(--accent-text); }
.nav-icon { width: 1.25rem; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 16px; height: 16px; display: block; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.25rem;
}
.user-info-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.role-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
}
.role-badge.role-team { background: #2a5b6b; }
.role-badge.role-user { background: #3d3528; color: var(--text-soft); }

.btn-visit {
  display: block;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-soft);
  text-decoration: none;
  padding: 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}
.btn-visit:hover { background: var(--bg3); color: var(--text); }

.btn-logout {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-soft);
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 0.45rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-logout:hover { background: var(--red); border-color: var(--red); color: #fff; }

.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}
.sidebar-toggle svg { width: 20px; height: 20px; display: block; }
.topbar-search { flex: 1; max-width: 360px; }
.topbar-search input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.topbar-search input:focus { border-color: var(--accent); }
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-soft);
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.content { flex: 1; padding: 2rem 1.5rem; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.stat-card:hover { border-color: var(--accent); background: var(--bg3); }
.stat-icon { display: flex; align-items: center; }
.stat-icon svg { width: 22px; height: 22px; display: block; }
.stat-label { font-size: 0.72rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 1.75rem; font-weight: 700; }

.overview-actions { margin-top: 0.5rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }

.search-bar { margin-bottom: 1rem; }
.search-bar input {
  width: 100%;
  max-width: 400px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.search-bar input:focus { border-color: var(--accent); }

.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  max-width: 280px;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg3); }
.cell-icon { width: 40px; }
.cell-icon svg { width: 18px; height: 18px; display: block; }
.cell-trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; display: block; }
.cell-muted { color: var(--text-soft); font-size: 0.82rem; }
.actions    { display: flex; gap: 0.5rem; white-space: nowrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-h); }
.btn-ghost    { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover    { background: var(--bg3); }
.btn-danger   { background: var(--red); color: #fff; }
.btn-danger:hover   { background: var(--red-h); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.modal--sm { max-width: 380px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text-soft);
  cursor: pointer; padding: 0.25rem; line-height: 1;
  transition: color 0.15s;
  display: flex; align-items: center;
}
.modal-close svg { width: 16px; height: 16px; display: block; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 1.25rem 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field label {
  font-size: 0.78rem; font-weight: 600; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.field input,
.field textarea,
.field select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 80px; }
.field input[readonly],
.field textarea[readonly] { opacity: 0.7; cursor: default; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 300;
  display: flex; flex-direction: column; gap: 0.5rem;
  pointer-events: none;
}
.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  box-shadow: var(--shadow);
  animation: slide-in 0.2s ease;
  max-width: 300px;
}
.toast--success { border-left-color: var(--green); }
.toast--error   { border-left-color: var(--red); }
@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.pill-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.pill-tag {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.72rem;
  color: var(--text-soft);
}

.empty-row td {
  text-align: center;
  color: var(--text-soft);
  padding: 2.5rem;
  font-size: 0.875rem;
}
.denied-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  gap: 1rem;
  color: var(--text-soft);
  text-align: center;
}
.denied-icon { display: flex; align-items: center; justify-content: center; }
.denied-icon svg { width: 48px; height: 48px; display: block; }
.denied-box h2 { font-size: 1.25rem; color: var(--text); }
.denied-box p  { max-width: 320px; line-height: 1.6; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .field-row { grid-template-columns: 1fr; }
  .content { padding: 1.25rem 1rem; }
  .topbar { padding: 0 1rem; }
}
