:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --background: #f3f4f6;
  --surface: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --success: #10b981;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --radius: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --sidebar-width: 260px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--background);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 15px;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* LAYOUT: APP */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
  margin: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.nav-group-title {
  padding: 15px 20px 5px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.nav-item {
  display: block;
  padding: 10px 20px;
  color: var(--text-main);
  font-weight: 500;
  transition: all 0.2s;
}

.nav-item:hover, .nav-item.active {
  background-color: #f8fafc;
  color: var(--primary);
  text-decoration: none;
  border-right: 3px solid var(--primary);
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 60px;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 30px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.content-area {
  padding: 30px;
  flex: 1;
}

/* TYPOGRAPHY */
h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--text-main); margin-bottom: 0.5rem;}
.h3 { font-size: 1.5rem; }
.h4 { font-size: 1.25rem; }
.h5 { font-size: 1.1rem; }
.display-6 { font-size: 2.5rem; font-weight: 700; color: var(--primary); margin: 0;}
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-end { text-align: right; }
.fw-semibold { font-weight: 600; }
.page-title { margin-bottom: 5px; margin-top: 0; }

/* UTILITIES */
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.m-b-30 { margin-bottom: 30px !important; }
.mt-4 { margin-top: 1.5rem !important; }
.p-0 { padding: 0 !important; }
.p-4 { padding: 1.5rem !important; }
.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.pl-0 { padding-left: 0 !important; }

.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.justify-content-end { justify-content: flex-end; }
.align-items-center { align-items: center; }
.w-100 { width: 100%; }

/* GRID SYSTEM */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-right: -15px;
  margin-left: -15px;
}
.g-3 { margin-right: -10px; margin-left: -10px; }
.g-3 > [class*="col-"] { padding-right: 10px; padding-left: 10px; margin-bottom: 20px; }
.g-4 { margin-right: -12px; margin-left: -12px; }
.g-4 > [class*="col-"] { padding-right: 12px; padding-left: 12px; margin-bottom: 24px; }

[class*="col-"] {
  position: relative;
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
}

.col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-md-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-md-6 { flex: 0 0 50%; max-width: 50%; }
.col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-md-12 { flex: 0 0 100%; max-width: 100%; }

.col-lg-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-lg-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-lg-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }

/* COMPONENTS */
.card {
  background-color: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
}
.card-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  background-color: #f9fafb;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.card-body {
  padding: 20px;
  flex: 1 1 auto;
}

/* FORMS */
.form-label {
  display: inline-block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-main);
}
.form-control, .form-select {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.5;
  color: var(--text-main);
  background-color: var(--surface);
  border: 1px solid #d1d5db;
  border-radius: 6px;
  transition: border-color 0.15s ease-in-out;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.25);
}

/* BUTTONS */
.btn {
  display: inline-block;
  font-weight: 500;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border-radius: 6px;
  transition: all 0.15s ease-in-out;
  border: 1px solid transparent;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  color: #fff;
  background-color: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}
.btn-outline-primary {
  color: var(--primary);
  background-color: transparent;
  border-color: var(--primary);
}
.btn-outline-primary:hover {
  color: #fff;
  background-color: var(--primary);
}
.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  border-radius: 4px;
}
.btn-link {
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
}
.btn-link:hover {
  color: var(--text-main);
}

/* TABLES */
.table-responsive {
  overflow-x: auto;
}
.table {
  width: 100%;
  margin-bottom: 1rem;
  color: var(--text-main);
  border-collapse: collapse;
}
.table th, .table td {
  padding: 1rem;
  vertical-align: middle;
  border-top: 1px solid var(--border);
  text-align: left;
}
.table thead th {
  vertical-align: bottom;
  border-bottom: 2px solid var(--border);
  background-color: #f9fafb;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}
.table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.02);
}
.table td.text-end, .table th.text-end {
  text-align: right;
}

/* LIST GROUP */
.list-group {
  display: flex;
  flex-direction: column;
  padding-left: 0;
  margin-bottom: 0;
  border-radius: var(--radius);
}
.list-group-item {
  position: relative;
  display: block;
  padding: 0.75rem 1.25rem;
  background-color: var(--surface);
  border: 1px solid var(--border);
}
.list-group-item:first-child { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.list-group-item:last-child { border-bottom-right-radius: var(--radius); border-bottom-left-radius: var(--radius); }
.list-group-item + .list-group-item { border-top-width: 0; }
.list-group-item-action { width: 100%; color: var(--text-main); text-align: left; }
.list-group-item-action:hover { background-color: #f9fafb; text-decoration: none; }

/* BREADCRUMBS */
.breadcrumbbar {
  margin-bottom: 20px;
}
.breadcrumb-list {
  margin-top: 5px;
}
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  margin-bottom: 0;
  list-style: none;
}
.breadcrumb-item + .breadcrumb-item::before {
  display: inline-block;
  padding-right: 0.5rem;
  padding-left: 0.5rem;
  color: var(--text-muted);
  content: "/";
}
.breadcrumb-item a { color: var(--text-muted); }
.breadcrumb-item.active { color: var(--primary); font-weight: 500; }

/* ALERTS */
.alert {
  position: relative;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
}
.alert-success {
  color: #065f46;
  background-color: #d1fae5;
  border-color: #a7f3d0;
}
.alert-danger {
  color: #991b1b;
  background-color: #fee2e2;
  border-color: #fecaca;
}
.close {
  position: absolute;
  top: 0;
  right: 0;
  padding: 1rem 1.25rem;
  color: inherit;
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.5;
}
.close:hover { opacity: 1; }

/* MEDIA OBJECT */
.media {
  display: flex;
  align-items: flex-start;
}
.media-body {
  flex: 1;
}

/* LOGIN VIEW ONLY */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--background);
}
.auth-wrapper .card {
  width: 100%;
  max-width: 400px;
}

/* RESPONSIVENESS */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .col-md-4, .col-md-5, .col-md-6, .col-md-8, .col-lg-4, .col-lg-7, .col-lg-8 { flex: 0 0 100%; max-width: 100%; }
}
