/* Reset + base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

/* App shell */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.topbar .crumb { font-weight: 600; color: var(--text); }
.topbar .spacer { flex: 1; }
.topbar .user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: var(--radius-sm);
}
.topbar .user .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-500); color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 12px;
}
.topbar .user .email { color: var(--text-muted); font-size: 13px; }
.topbar .logout {
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text-muted); padding: 6px 12px;
  border-radius: var(--radius-sm); font-size: 13px;
}
.topbar .logout:hover { color: var(--danger-700); border-color: var(--danger-500); }

.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 16px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.sidebar .brand .mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.sidebar .brand .name { font-weight: 700; font-size: 15px; color: var(--text); }
.sidebar .brand .env { font-size: 11px; color: var(--text-soft); }

.sidebar .group { padding: 12px 0 4px; }
.sidebar .group-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: var(--text-soft); padding: 0 20px 6px; letter-spacing: .04em;
}
.sidebar .nav { list-style: none; padding: 0; margin: 0; }
.sidebar .nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px; color: var(--text-muted);
  font-size: 13.5px; font-weight: 500;
  border-left: 3px solid transparent;
}
.sidebar .nav a:hover {
  background: var(--surface-2); color: var(--text); text-decoration: none;
}
.sidebar .nav a.active {
  background: var(--brand-50); color: var(--brand-700);
  border-left-color: var(--brand-500);
}
.sidebar .nav .icon {
  width: 16px; height: 16px; opacity: .8;
  display: inline-block; flex-shrink: 0;
}

.main {
  grid-area: main;
  padding: 24px 28px;
  min-width: 0;
}

/* Page */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; margin: 0; font-weight: 600; }
.page-header .subtitle { color: var(--text-muted); margin-top: 4px; font-size: 13.5px; }
.page-header .actions { display: flex; gap: 8px; }

/* Login */
.login-shell {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-50), #fff);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px;
  box-shadow: var(--shadow-lg);
}
.login-card .brand-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 20px;
}
.login-card .mark {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; display: grid; place-items: center; font-weight: 700;
}
.login-card h1 { margin: 0; font-size: 18px; }
.login-card .sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.login-card form { margin-top: 20px; }

/* Cleared scroll for big tables */
.scroll-x { overflow-x: auto; }
