:root {
  --brand: #0b3d2e;
  --brand-2: #147a5a;
  --accent: #c4a35a;
  --bg: #f3f1ea;
  --bg-soft: #ebe6db;
  --panel: #ffffff;
  --text: #1c2421;
  --muted: #5f6b66;
  --border: rgba(11, 61, 46, 0.12);
  --shadow: 0 10px 30px rgba(11, 61, 46, 0.08);
  --radius: 16px;
  --sidebar: 260px;
  --font: "DM Sans", sans-serif;
  --mono: "JetBrains Mono", monospace;
}

[data-bs-theme="dark"] {
  --bg: #0f1714;
  --bg-soft: #16201c;
  --panel: #18241f;
  --text: #e8eee9;
  --muted: #9aaba3;
  --border: rgba(232, 238, 233, 0.1);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
body.app-body, body.auth-body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}
a { color: var(--brand-2); text-decoration: none; }
.font-mono { font-family: var(--mono); font-size: .85rem; }

.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: var(--sidebar);
  background: linear-gradient(180deg, #0b3d2e 0%, #0f4a38 55%, #123f32 100%);
  color: #edf6f1;
  position: sticky; top: 0; height: 100vh; overflow: auto;
  flex-shrink: 0; z-index: 100;
}
.sidebar-brand {
  display: flex; gap: .9rem; align-items: center;
  padding: 1.25rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #e6d3a3);
  color: #0b3d2e;
}
.brand-mark.lg { width: 56px; height: 56px; margin: 0 auto 1rem; font-size: 1.2rem; }
.brand-text strong { display: block; font-size: .95rem; }
.brand-text small { opacity: .7; }
.sidebar-nav { padding: .75rem; display: flex; flex-direction: column; gap: .2rem; }
.sidebar-nav .nav-link {
  color: rgba(255,255,255,.78); border-radius: 10px;
  display: flex; align-items: center; gap: .7rem; padding: .7rem .85rem;
}
.sidebar-nav .nav-link:hover, .sidebar-nav .nav-link.active {
  background: rgba(255,255,255,.1); color: #fff;
}
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  height: 64px; display: flex; align-items: center; gap: 1rem;
  padding: 0 1.25rem; background: rgba(255,255,255,.7); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
[data-bs-theme="dark"] .app-topbar { background: rgba(24,36,31,.8); }
.topbar-search { position: relative; flex: 1; max-width: 360px; }
.topbar-search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar-search input { padding-left: 2rem; border-radius: 999px; background: var(--bg-soft); border-color: transparent; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.btn-icon { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); }
.btn-user { border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: .25rem .75rem .25rem .25rem; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--brand); color: #fff; font-size: .85rem; margin-right: .35rem;
}
.app-content { padding: 1.25rem; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-header h2 { margin: 0; font-weight: 700; letter-spacing: -.02em; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.panel-header h5 { margin: 0; font-weight: 650; }

.stat-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1rem;
}
.stat-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card::after {
  content: ""; position: absolute; inset: auto -20% -40% auto; width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(11,61,46,.12), transparent 70%);
}
.stat-label { color: var(--muted); font-size: .82rem; margin-bottom: .35rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; }
.stat-card.success .stat-value { color: #2f9e44; }
.stat-card.warning .stat-value { color: #e67700; }
.stat-card.danger .stat-value { color: #c92a2a; }
.stat-card.info .stat-value { color: #1c7ed6; }
.stat-card.muted .stat-value { color: #868e96; }

.sys-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.sys-grid > div { background: var(--bg-soft); border-radius: 12px; padding: .8rem; }
.sys-grid span { display: block; color: var(--muted); font-size: .75rem; }
.activity-feed { list-style: none; margin: 0; padding: 0; }
.activity-feed li { display: flex; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.act-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand-2); margin-top: .4rem; flex-shrink: 0; }
.activity-feed strong { display: block; }
.activity-feed small { color: var(--muted); }

.bulk-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.notif-menu { width: 340px; }
.notif-list { max-height: 360px; overflow: auto; }
.notif-item { padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.notif-item.unread { background: rgba(20,122,90,.08); }
.log-view {
  max-height: 70vh; overflow: auto; background: #0f1714; color: #d7e6de;
  padding: 1rem; border-radius: 12px; font-family: var(--mono); font-size: .78rem;
}

/* Auth */
.auth-body { min-height: 100vh; display: grid; place-items: center; position: relative; overflow: hidden; }
.auth-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(196,163,90,.35), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(20,122,90,.35), transparent 40%),
    linear-gradient(145deg, #0b3d2e, #147a5a 45%, #0f2f26);
}
.auth-bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 40px 40px; opacity: .5;
}
.auth-wrap { position: relative; z-index: 1; width: min(440px, calc(100% - 2rem)); }
.auth-card {
  background: rgba(255,255,255,.96); border-radius: 20px; padding: 2rem;
  box-shadow: 0 25px 60px rgba(0,0,0,.25);
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { font-size: 1.5rem; margin: 0 0 .35rem; color: #0b3d2e; }
.auth-brand p { margin: 0; color: #5f6b66; }

.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.form-control:focus, .form-select:focus {
  border-color: var(--brand-2); box-shadow: 0 0 0 .2rem rgba(20,122,90,.15);
}

@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 992px) {
  .app-sidebar { position: fixed; left: 0; transform: translateX(-105%); transition: .25s ease; }
  .app-sidebar.open { transform: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sys-grid { grid-template-columns: 1fr; }
}
@media (max-width: 576px) {
  .stat-grid { grid-template-columns: 1fr; }
  .app-content { padding: .85rem; }
}

@media print {
  .app-sidebar, .app-topbar, .page-actions, .btn { display: none !important; }
  .app-content { padding: 0; }
  .panel { box-shadow: none; border: 1px solid #ccc; }
}
