:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2a44;
  --muted: #6b7895;
  --line: #d9e0ef;
  --accent: #2f6bff;
  --sidebar: #13203f;
  --sidebar-ink: #e8edff;
}

html[data-theme="dark"] {
  --bg: #0f1526;
  --panel: #161f36;
  --ink: #e7eeff;
  --muted: #b2bddb;
  --line: #293656;
  --accent: #7ea2ff;
  --sidebar: #0c1222;
  --sidebar-ink: #dce6ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 290px 1fr;
  grid-template-rows: 74px 1fr;
}

.sidebar {
  grid-column: 1;
  grid-row: 1 / span 2;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  border-right: 1px solid rgba(255,255,255,0.1);
  padding: 1rem;
  overflow-y: auto;
}

.logo-wrap {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1rem;
}
.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.12);
  font-weight: 700;
}
.eyebrow { font-size: .75rem; opacity: .8; text-transform: uppercase; letter-spacing: .05em; }

.user-card {
  display: flex;
  gap: .75rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: .75rem;
  margin-bottom: 1rem;
}
.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
}
.role, .scope { font-size: .8rem; opacity: .9; }

.menu h4 {
  margin: 1rem 0 .4rem;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  opacity: .7;
}
.menu a {
  display: block;
  color: var(--sidebar-ink);
  text-decoration: none;
  padding: .5rem .55rem;
  border-radius: 10px;
  font-size: .95rem;
}
.menu a:hover,
.menu a.active { background: rgba(255,255,255,.14); }

.header {
  grid-column: 2;
  grid-row: 1;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1rem;
}

.search-wrap {
  display: flex;
  gap: .5rem;
  flex: 1;
}
.search-wrap input,
.search-wrap select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 .75rem;
}
.search-wrap input { min-width: 260px; flex: 1; }

.header-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
}
.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #ff4d5a;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: 0 4px;
}
.notif-wrap { position: relative; }
.notif-menu {
  position: absolute;
  right: 0;
  top: 46px;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(0,0,0,.12);
  padding: .6rem;
  display: grid;
  gap: .4rem;
  z-index: 20;
}
.notif-menu[hidden] { display: none !important; }
.notif-menu a {
  text-decoration: none;
  color: var(--ink);
  font-size: .9rem;
  border-radius: 8px;
  padding: .45rem;
}
.notif-menu a:hover { background: rgba(47,107,255,.1); }

.content {
  grid-column: 2;
  grid-row: 2;
  padding: 1rem;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.table th,
.table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: .65rem .5rem;
}
.table th { color: var(--muted); font-weight: 600; }

.tenant-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
}
.tenant-editor {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .75rem;
  background: var(--panel);
}
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.editor-form {
  display: grid;
  gap: .65rem;
}
.editor-form label {
  display: grid;
  gap: .3rem;
  font-size: .88rem;
}
.editor-form input,
.editor-form select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 .6rem;
}
.editor-actions {
  display: flex;
  gap: .5rem;
  margin-top: .4rem;
}
.btn-primary,
.btn-danger,
.row-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  padding: .45rem .65rem;
  cursor: pointer;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger,
.row-btn.danger { border-color: #ff8d97; color: #c62839; }

@media (max-width: 1280px) {
  .tenant-layout { grid-template-columns: 1fr; }
}

@media (max-width: 1040px) {
  .admin-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }
  .sidebar { grid-column: 1; grid-row: 1; }
  .header { grid-column: 1; grid-row: 2; }
  .content { grid-column: 1; grid-row: 3; }
  .search-wrap { flex-wrap: wrap; }
  .search-wrap input { min-width: 180px; }
}
