:root {
  --sidebar-width: 256px;
  --topbar-height: 56px;
  --sidebar-bg: #1a2e4a;
  --sidebar-hover: #243d5c;
  --sidebar-text: rgba(255, 255, 255, 0.7);
  --sidebar-text-active: #ffffff;
  --accent: #2d7dd2;
  --accent-soft: #e8f1fc;
  --body-bg: #f0f2f5;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --text-primary: #1a202c;
  --text-muted: #718096;
}

* { box-sizing: border-box; }

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */

.dashboard-body {
  background: var(--body-bg);
  display: flex;
  min-height: 100vh;
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* --- Sidebar --- */

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  overflow-y: auto;
  transition: transform 0.25s ease;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-group {
  margin-bottom: 24px;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.3);
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 450;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  line-height: 1.4;
}

.nav-link-item:hover,
.nav-link-item:focus {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  text-decoration: none;
}

.nav-link-item.active {
  background: var(--accent);
  color: #fff;
}

.nav-link-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-link-btn {
  font-family: inherit;
  font-weight: 450;
}

.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

/* --- Main wrapper --- */

.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

.main-wrapper.expanded {
  margin-left: 0;
}

/* --- Topbar --- */

.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-toggle {
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: background 0.15s;
}
.sidebar-toggle:hover { background: var(--body-bg); }

.topbar-right { margin-left: auto; }

.topbar-user-name {
  font-size: 13px;
  color: var(--text-muted);
}

/* --- Page content --- */

.page-content {
  flex: 1;
  padding: 28px;
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 4px 0 0;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border) !important;
  border-radius: 10px !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.card-header {
  padding: 14px 20px !important;
  border-bottom: 1px solid var(--card-border) !important;
  background: transparent !important;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-body { padding: 20px; }

/* ============================================================
   STAT CARDS
   ============================================================ */

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.bg-primary-soft { background: #dbeafe; }
.bg-warning-soft { background: #fef9c3; }
.bg-success-soft { background: #dcfce7; }
.bg-danger-soft  { background: #fee2e2; }

.stat-card-body { flex: 1; min-width: 0; }

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ============================================================
   TABLES
   ============================================================ */

.table thead th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--card-border) !important;
  padding: 10px 16px;
  background: transparent;
}

.table td {
  padding: 11px 16px;
  font-size: 14px;
  color: var(--text-primary);
  vertical-align: middle;
  border-color: var(--card-border);
}

.table-hover tbody tr:hover { background: #f7fafc; }

/* ============================================================
   STATUS BADGES
   ============================================================ */

.badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 4px; }

.status-paid    { background: #dcfce7; color: #166534; }
.status-pending { background: #fef9c3; color: #854d0e; }
.status-overdue { background: #fee2e2; color: #991b1b; }
.status-draft   { background: #f1f5f9; color: #475569; }

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 48px 24px;
}

/* ============================================================
   MESSAGES
   ============================================================ */

.messages-container { margin-bottom: 20px; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-body {
  background: var(--body-bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 16px;
}

.login-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.brand-logo-lg {
  width: 54px;
  height: 54px;
  background: var(--accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 26px;
  color: #fff;
  margin: 0 auto 14px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

/* ============================================================
   CLIENT PORTAL
   ============================================================ */

.portal-body {
  background: var(--body-bg);
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.portal-nav {
  background: #fff;
  border-bottom: 1px solid var(--card-border);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
}

.portal-brand {
  display: flex;
  align-items: center;
}

.brand-logo-sm {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}

.portal-content {
  min-height: calc(100vh - var(--topbar-height));
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .page-content { padding: 16px; }
}
