* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f5; color: #333; }

/* Top bar */
.topbar { background: #1a3a5c; color: #fff; padding: 0.5rem 1rem; display: flex; justify-content: space-between; align-items: center; position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 52px; }
.topbar a { color: #fff; text-decoration: none; margin-left: 1rem; opacity: 0.85; }
.topbar a:hover { opacity: 1; }
.topbar .brand { font-weight: 600; font-size: 1.1rem; }

/* App layout */
.app-layout { display: flex; margin-top: 52px; min-height: calc(100vh - 52px); }

/* Sidebar */
.sidebar { width: 200px; min-width: 200px; background: #2c3e50; padding: 0.5rem 0; overflow-y: auto; position: fixed; top: 52px; bottom: 0; left: 0; display: flex; flex-direction: column; }
.sidebar-section { color: #fff; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.75rem 1rem 0.35rem; font-weight: 700; margin-top: 0.5rem; border-top: 1px solid #3d566e; background: #243447; }
.sidebar-item { display: block; color: #ccd6dd; text-decoration: none; padding: 0.4rem 1rem; font-size: 0.85rem; border-left: 3px solid transparent; }
.sidebar-item:hover { background: #34495e; color: #fff; }
.sidebar-item.active { background: #34495e; color: #fff; border-left-color: #3498db; }

/* Sidebar collapsible groups */
.sidebar-toggle { cursor: pointer; user-select: none; }
.sidebar-toggle:hover { background: #1a2a3a; }
.sidebar-toggle.open { background: #1a2a3a; }
.sidebar-group { overflow: hidden; }
.sidebar-group .sidebar-item { padding-left: 1.5rem; font-size: 0.82rem; }

/* Sidebar company logo */
.sidebar-logo { margin-top: auto; padding: 1rem; border-top: 1px solid #3d566e; text-align: center; }
.sidebar-logo img { max-width: 160px; max-height: 60px; object-fit: contain; opacity: 0.85; }

/* Main content */
.main-content { flex: 1; margin-left: 200px; padding: 1rem 1.5rem; max-width: calc(100% - 200px); }

/* Breadcrumb */
.breadcrumb { font-size: 0.85rem; color: #666; margin-bottom: 1rem; }
.breadcrumb a { color: #666; }
.breadcrumb a:hover { color: #1a3a5c; }

/* Cards */
.card { background: #fff; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); padding: 1.5rem; margin-bottom: 1rem; overflow-x: auto; }

/* Tables */
table { width: 100%; border-collapse: collapse; table-layout: auto; }
th, td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid #eee; word-break: break-word; }
th { background: #f8f9fa; font-weight: 600; font-size: 0.85rem; text-transform: uppercase; color: #666; cursor: pointer; user-select: none; }
th:hover { background: #e8eef4; }
th::after { content: ' ⇅'; font-size: 0.7rem; color: #ccc; }
tr:hover { background: #f8f9fa; }

/* Links & buttons */
a { color: #1a3a5c; }
.btn { display: inline-block; padding: 0.4rem 1rem; background: #1a3a5c; color: #fff; border: none; border-radius: 4px; cursor: pointer; text-decoration: none; font-size: 0.9rem; }
.btn:hover { background: #2a5a8c; }

/* Forms */
input[type="text"], input[type="password"], input[type="email"], input[type="date"], select, textarea { padding: 0.4rem 0.6rem; border: 1px solid #ccc; border-radius: 4px; font-size: 0.9rem; font-family: inherit; }
.search-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; align-items: center; flex-wrap: wrap; }
.search-bar input[type="text"] { min-width: 250px; }

/* Pagination */
.pagination { display: flex; gap: 0.5rem; margin-top: 1rem; justify-content: center; }
.pagination a { padding: 0.3rem 0.7rem; border: 1px solid #ccc; border-radius: 4px; text-decoration: none; color: #333; }
.pagination a.active { background: #1a3a5c; color: #fff; border-color: #1a3a5c; }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; }
.field { margin-bottom: 0.75rem; }
.field label { font-weight: 600; font-size: 0.85rem; color: #666; display: block; margin-bottom: 0.2rem; }

/* Misc */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 3px; font-size: 0.8rem; background: #e8f4e8; color: #2d6a2d; }
.error { color: #c00; padding: 0.5rem; background: #fee; border-radius: 4px; margin-bottom: 1rem; }
.text-muted { color: #999; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; top: 0; min-height: auto; }
  .main-content { margin-left: 0; max-width: 100%; }
  .app-layout { flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* Dark mode */
body.dark { background: #1a1a2e; color: #e0e0e0; }
body.dark .topbar { background: #0f0f23; }
body.dark .sidebar { background: #16213e; }
body.dark .sidebar-section { background: #0f0f23; border-top-color: #2a2a4a; color: #8899bb; }
body.dark .sidebar-item { color: #99aabb; }
body.dark .sidebar-item:hover, body.dark .sidebar-item.active { background: #1a1a3e; color: #fff; }
body.dark .card { background: #16213e; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
body.dark th { background: #0f0f23; color: #8899bb; }
body.dark th:hover { background: #1a1a3e; }
body.dark td { border-bottom-color: #2a2a4a; }
body.dark tr:hover { background: #1a1a3e; }
body.dark a { color: #5dade2; }
body.dark .btn { background: #2471a3; }
body.dark .btn:hover { background: #2e86c1; }
body.dark input, body.dark select, body.dark textarea { background: #1a1a2e; color: #e0e0e0; border-color: #2a2a4a; }
body.dark .badge { background: #1a3a2e; color: #5dcea0; }
body.dark .error { background: #3a1a1a; color: #e07070; }
body.dark .breadcrumb, body.dark .breadcrumb a { color: #8899bb; }
body.dark .text-muted { color: #667788; }
body.dark .field label { color: #8899bb; }
body.dark .pagination a { border-color: #2a2a4a; color: #99aabb; }
body.dark .pagination a.active { background: #2471a3; border-color: #2471a3; color: #fff; }

/* Print */
@media print {
  .topbar, .sidebar, .btn, .search-bar, .pagination, .breadcrumb { display: none !important; }
  .main-content { margin-left: 0 !important; max-width: 100% !important; padding: 0 !important; }
  .app-layout { display: block !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc; page-break-inside: avoid; }
  body, body.dark { background: #fff !important; color: #000 !important; }
  a { color: #000 !important; text-decoration: none !important; }
}
