/* ===================================================
   OWL WEB WORKS - CLIENT PORTAL DESIGN SYSTEM
   App: app.owlwebworks.com
   Tenant: Apex Security Guards (demo)
   =================================================== */

:root {
  /* Core palette - matches marketing but tuned for app density */
  --navy: #0A0E27;
  --navy-soft: #151A3D;
  --navy-deep: #060920;
  --cobalt: #2563EB;
  --cobalt-bright: #3B82F6;
  --cobalt-soft: #93C5FD;
  --amber: #F59E0B;
  --amber-soft: #FCD34D;
  --emerald: #10B981;
  --emerald-soft: #6EE7B7;
  --red: #EF4444;
  --red-soft: #FCA5A5;
  --purple: #8B5CF6;

  /* Neutrals - app needs more granularity */
  --white: #FFFFFF;
  --gray-25: #FCFCFD;
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-150: #E8EEF4;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  /* Typography */
  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(10, 14, 39, 0.04);
  --shadow-sm: 0 1px 3px rgba(10, 14, 39, 0.06), 0 1px 2px rgba(10, 14, 39, 0.04);
  --shadow-md: 0 4px 12px rgba(10, 14, 39, 0.06), 0 2px 4px rgba(10, 14, 39, 0.04);
  --shadow-lg: 0 12px 32px rgba(10, 14, 39, 0.08), 0 4px 8px rgba(10, 14, 39, 0.04);
  --shadow-xl: 0 24px 56px rgba(10, 14, 39, 0.10), 0 8px 16px rgba(10, 14, 39, 0.06);

  /* App layout */
  --sidebar-width: 256px;
  --header-height: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--navy);
  line-height: 1.5;
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
img, svg { display: block; max-width: 100%; }

/* ===== APP LAYOUT ===== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--navy);
  color: rgba(255,255,255,0.7);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.04);
}
.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 16px;
}
.sidebar-brand-row {
  display: flex; align-items: center; gap: 12px;
}
.sidebar-brand-mark {
  width: 36px; height: 36px;
  background: var(--cobalt);
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--white);
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}
.sidebar-brand-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--white);
  letter-spacing: -0.015em;
}
.sidebar-brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 1px;
  letter-spacing: 0.02em;
}

.sidebar-section {
  padding: 12px 16px 8px;
}
.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.65);
  margin-bottom: 1px;
  transition: all 0.15s;
  position: relative;
}
.sidebar-link:hover {
  background: rgba(255,255,255,0.04);
  color: var(--white);
}
.sidebar-link.active {
  background: rgba(37, 99, 235, 0.15);
  color: var(--white);
}
.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--cobalt-bright);
  border-radius: 0 3px 3px 0;
}
.sidebar-link svg { flex-shrink: 0; }
.sidebar-link-badge {
  margin-left: auto;
  background: var(--cobalt);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.sidebar-link-badge.amber { background: var(--amber); color: var(--navy); }
.sidebar-link-badge.red { background: var(--red); }

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.sidebar-user:hover { background: rgba(255,255,255,0.04); }
.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cobalt), var(--amber));
  display: grid; place-items: center;
  color: var(--white);
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
}

/* ===== MAIN CONTENT ===== */
.main {
  background: var(--gray-50);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  height: var(--header-height);
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  font-size: 13px;
  color: var(--navy);
  outline: none;
  transition: all 0.15s;
}
.topbar-search input:focus {
  background: var(--white);
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.topbar-btn {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--gray-600);
  position: relative;
  transition: background 0.15s;
}
.topbar-btn:hover { background: var(--gray-100); color: var(--navy); }
.topbar-btn-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--red);
  border: 2px solid var(--white);
  border-radius: 50%;
}

.content {
  padding: 32px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* ===== PAGE HEADER ===== */
.page-head {
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head-left h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--navy);
}
.page-head-left p {
  font-size: 14px;
  color: var(--gray-600);
  margin-top: 6px;
}

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  padding: 24px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-subtitle {
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 2px;
}

/* ===== STAT CARDS ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
}
.stat-card:hover {
  border-color: var(--cobalt-soft);
  box-shadow: var(--shadow-md);
}
.stat-card-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  margin-bottom: 16px;
}
.stat-card-icon.blue { background: rgba(37, 99, 235, 0.1); color: var(--cobalt); }
.stat-card-icon.amber { background: rgba(245, 158, 11, 0.1); color: var(--amber); }
.stat-card-icon.emerald { background: rgba(16, 185, 129, 0.1); color: var(--emerald); }
.stat-card-icon.red { background: rgba(239, 68, 68, 0.1); color: var(--red); }
.stat-card-icon.purple { background: rgba(139, 92, 246, 0.1); color: var(--purple); }
.stat-card-label {
  font-size: 12px;
  color: var(--gray-600);
  font-weight: 500;
}
.stat-card-value {
  font-family: var(--font-serif);
  font-size: 36px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--navy);
  margin-top: 6px;
}
.stat-card-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 6px;
}
.stat-card-meta-trend {
  font-weight: 600;
}
.stat-card-meta-trend.up { color: var(--emerald); }
.stat-card-meta-trend.down { color: var(--red); }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}
.badge.emerald { background: rgba(16, 185, 129, 0.12); color: #047857; }
.badge.amber { background: rgba(245, 158, 11, 0.12); color: #B45309; }
.badge.blue { background: rgba(37, 99, 235, 0.10); color: var(--cobalt); }
.badge.red { background: rgba(239, 68, 68, 0.10); color: #B91C1C; }
.badge.gray { background: var(--gray-100); color: var(--gray-700); }
.badge.purple { background: rgba(139, 92, 246, 0.10); color: #6D28D9; }
.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-dot.live {
  animation: pulse 1.8s infinite;
  box-shadow: 0 0 6px currentColor;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--navy);
  color: var(--white);
}
.btn-primary:hover { background: var(--cobalt); transform: translateY(-1px); }
.btn-outline {
  background: var(--white);
  color: var(--navy);
  border-color: var(--gray-200);
}
.btn-outline:hover { border-color: var(--cobalt); color: var(--cobalt); }
.btn-ghost {
  background: transparent;
  color: var(--gray-700);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--navy); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 14px; }

/* ===== TABLES ===== */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}
.table td {
  padding: 14px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--gray-25); }
.table .row-link { color: var(--navy); font-weight: 500; }
.table .row-link:hover { color: var(--cobalt); }

/* ===== UTILITY ===== */
.text-mono { font-family: var(--font-mono); font-size: 0.92em; }
.text-muted { color: var(--gray-600); }
.text-faint { color: var(--gray-500); }
.text-sm { font-size: 12px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  :root { --sidebar-width: 72px; }
  .sidebar-brand-name, .sidebar-brand-sub,
  .sidebar-link span:not(.sidebar-link-badge),
  .sidebar-section-label,
  .sidebar-user-info {
    display: none;
  }
  .sidebar { padding: 16px 0; align-items: center; }
  .sidebar-brand { padding: 0 0 16px; }
  .sidebar-section { padding: 8px 0; }
  .sidebar-link { width: 44px; height: 44px; justify-content: center; padding: 0; }
  .sidebar-link.active::before { left: 0; }
  .sidebar-user { width: 44px; height: 44px; justify-content: center; padding: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    top: auto;
    height: auto;
    flex-direction: row;
    padding: 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
    border-right: none;
    z-index: 100;
    overflow: visible;
  }
  .sidebar-brand, .sidebar-section-label, .sidebar-footer { display: none; }
  .sidebar-section { display: flex; gap: 4px; padding: 0; }
  .content { padding: 20px 16px 88px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .topbar { padding: 0 16px; }
  .page-head-left h1 { font-size: 28px; }
}
