:root {
  --mjw-primary: #6f4e37;   /* wood brown */
  --mjw-primary-dark: #4e3626;
  --mjw-accent: #c8863a;    /* warm amber */
  --mjw-bg: #f5f2ee;
  --mjw-sidebar-bg: #2c211a;
  --mjw-sidebar-active: #6f4e37;
}

body {
  background-color: var(--mjw-bg);
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
}

.topbar {
  background: linear-gradient(90deg, var(--mjw-primary-dark), var(--mjw-primary));
  padding: 0 1rem;
  height: 60px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  margin-left: 250px; /* sits to the right of the full-height sidebar */
}

.topbar .container-fluid {
  display: flex;
  align-items: center;
  height: 100%;
}

/* Brand */
.topbar .navbar-brand {
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  transition: opacity 0.15s ease;
}
.topbar .navbar-brand:hover { opacity: 0.85; }
.topbar .navbar-brand i { color: var(--mjw-accent); font-size: 1.3rem; }

/* Mobile sidebar toggle */
#sidebarToggle {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0;
  margin-right: 0.5rem;
  transition: background 0.15s ease;
}
#sidebarToggle:hover { background: rgba(255,255,255,0.12); }

/* Global search pill */
.topbar-search .input-group {
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.97);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4);
  transition: box-shadow 0.15s ease;
}
.topbar-search .input-group:focus-within {
  box-shadow: 0 0 0 3px rgba(200,134,58,0.45);
}
.topbar-search .input-group-text {
  background: transparent;
  border: none;
  color: var(--mjw-primary);
  padding-left: 0.9rem;
}
.topbar-search .form-control {
  border: none;
  box-shadow: none;
  background: transparent;
  padding-left: 0.4rem;
}
.topbar-search .form-control:focus { box-shadow: none; }

/* Icon buttons (bell, etc.) */
.topbar-icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.06);
  color: #fff;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.topbar-icon-btn:hover,
.topbar-icon-btn:focus {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.6);
  color: #fff;
}
.topbar-icon-btn .notif-badge {
  animation: notif-pulse 2s ease-in-out infinite;
}
@keyframes notif-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.15); }
}

/* User menu button with initials avatar */
.user-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.06);
  color: #fff;
  border-radius: 999px;
  padding: 0.3rem 0.75rem 0.3rem 0.3rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.user-menu-btn:hover,
.user-menu-btn:focus {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.6);
  color: #fff;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--mjw-accent);
  color: #2c211a;
  font-weight: 700;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.role-chip {
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.role-chip-admin        { background: #2c211a; color: #f5f2ee; }
.role-chip-manager      { background: #2c5f8a; color: #fff; }
.role-chip-accountant   { background: #1f7a4d; color: #fff; }
.role-chip-stock_keeper { background: #a3402e; color: #fff; }
.role-chip-carpenter    { background: var(--mjw-accent); color: #2c211a; }

/* Dropdown polish */
.topbar .dropdown-menu {
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  padding: 0.5rem;
  margin-top: 0.6rem !important;
}
.topbar .dropdown-menu .dropdown-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mjw-primary);
  font-weight: 700;
}
.topbar .dropdown-item {
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}
.topbar .dropdown-item:hover,
.topbar .dropdown-item:focus {
  background: var(--mjw-bg);
  color: var(--mjw-primary-dark);
}
.topbar .dropdown-item.text-danger:hover { background: #fbe9e7; }

.app-wrapper {
  display: flex;
  min-height: calc(100vh - 60px);
  margin-left: 250px; /* space for the fixed full-height sidebar */
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--mjw-sidebar-bg);
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1035;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}

.sidebar .nav.flex-column {
  padding: 1rem 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 60px;
  padding: 0 1.1rem;
  box-sizing: border-box;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-decoration: none;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--mjw-sidebar-bg);
}
.sidebar-brand:hover { color: #fff; opacity: 0.9; }
.sidebar-brand-logo {
  height: 32px;
  width: 32px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  padding: 3px;
  flex-shrink: 0;
}
.sidebar-brand-icon {
  height: 32px;
  width: 32px;
  border-radius: 6px;
  background: var(--mjw-accent);
  color: #2c211a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}
.sidebar-brand-text {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }

.sidebar .nav-link {
  color: rgba(255,255,255,0.75);
  padding: 0.55rem 1.25rem;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
}

.sidebar .nav-link i { width: 1.4rem; display: inline-block; }

.sidebar .nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.sidebar .nav-link.active {
  background: var(--mjw-sidebar-active);
  color: #fff;
  border-left-color: var(--mjw-accent);
}

.nav-divider {
  color: rgba(255,255,255,0.35);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1rem 1.25rem 0.35rem;
}

.main-content {
  flex-grow: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 60px);
}

.main-content > .container-fluid {
  flex: 1 0 auto;
}

.app-footer {
  flex-shrink: 0;
  margin-top: 1.5rem;
  padding: 0.9rem 1.5rem;
  border-top: 1px solid #e6e1d8;
  background: #fff;
  font-size: 0.78rem;
  color: #8a8579;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  text-align: center;
}
.app-footer i { color: var(--mjw-primary); margin-right: 0.15rem; }
.app-footer-divider { color: #d3cdc0; }

.stat-card {
  border: none;
  border-radius: 0.75rem;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.stat-card .stat-icon {
  font-size: 2rem;
  opacity: 0.85;
}

/* ---- Dashboard v2 ---- */
.dash-greeting-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--mjw-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.quick-actions {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}
.quick-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e6e1d8;
  color: var(--mjw-primary-dark);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.quick-action-btn i { font-size: 1rem; color: var(--mjw-accent); }
.quick-action-btn:hover {
  background: var(--mjw-primary);
  border-color: var(--mjw-primary);
  color: #fff;
}
.quick-action-btn:hover i { color: #fff; }

.stat-card-v2 {
  background: #fff;
  border-radius: 0.9rem;
  padding: 1.1rem 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  height: 100%;
}
.stat-card-v2-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  color: #fff;
}
.stat-card-v2-body { min-width: 0; }
.stat-card-v2-label {
  font-size: 0.78rem;
  color: #8a8579;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.15rem;
}
.stat-card-v2-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--mjw-primary-dark);
  line-height: 1.2;
}
.stat-card-v2-sub {
  font-size: 0.75rem;
  color: #a39d8f;
  margin-top: 0.2rem;
}
.bg-icon-brown  { background: var(--mjw-primary); }
.bg-icon-blue   { background: #2c5f8a; }
.bg-icon-green  { background: #1f7a4d; }
.bg-icon-amber  { background: var(--mjw-accent); }
.bg-icon-red    { background: #a3402e; }

.dash-empty {
  text-align: center;
  color: #a39d8f;
  padding: 2rem 1rem;
}
.dash-empty i { font-size: 1.8rem; display: block; margin-bottom: 0.5rem; opacity: 0.6; }

/* ---- Settings page v2 ---- */
.settings-header {
  background: linear-gradient(90deg, var(--mjw-sidebar-bg), var(--mjw-primary-dark));
  border-radius: 0.9rem;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}
.settings-header-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(255,255,255,0.12);
  color: var(--mjw-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.btn-primary-accent {
  background: var(--mjw-accent);
  border: none;
  color: #2c211a;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 0.6rem;
  transition: filter 0.15s ease;
}
.btn-primary-accent:hover,
.btn-primary-accent:focus {
  background: var(--mjw-accent);
  color: #2c211a;
  filter: brightness(1.08);
}

.settings-tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  background: #fff;
  border-radius: 0.75rem;
  padding: 0.4rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: none;
}
.settings-tabs .nav-link {
  border: none;
  border-radius: 0.5rem;
  color: #6b6558;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
}
.settings-tabs .nav-link:hover { background: var(--mjw-bg); color: var(--mjw-primary-dark); }
.settings-tabs .nav-link.active {
  background: var(--mjw-bg);
  color: var(--mjw-primary-dark);
  box-shadow: inset 0 -2px 0 var(--mjw-accent);
}

.settings-tab-content { margin-top: 1rem; }

.settings-card {
  background: #fff;
  border-radius: 0.85rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  overflow: hidden;
  height: 100%;
}
.settings-card-header {
  padding: 0.85rem 1.15rem;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--mjw-primary-dark);
  border-bottom: 1px solid #f0ece3;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.settings-card-header i { color: var(--mjw-accent); }
.settings-card-body { padding: 1.15rem; }

.settings-image-preview {
  border: 1px dashed #d8d2c4;
  border-radius: 0.6rem;
  padding: 0.6rem;
  text-align: center;
  background: var(--mjw-bg);
}
.settings-image-preview img {
  max-height: 110px;
  max-width: 100%;
  border-radius: 0.4rem;
  object-fit: contain;
}

.card {
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #eee;
  font-weight: 600;
}

.table thead th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6b6b6b;
  border-bottom-width: 1px;
}

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--mjw-primary-dark), var(--mjw-primary) 60%, var(--mjw-accent));
}

.login-card {
  width: 100%;
  max-width: 400px;
  border-radius: 1rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.badge { font-weight: 500; }

@media (max-width: 991.98px) {
  .topbar {
    margin-left: 0;
  }
  .app-wrapper {
    margin-left: 0;
  }
  .sidebar {
    left: -260px;
    top: 0;
    height: 100vh;
    transition: left 0.2s ease;
  }
  .sidebar.show { left: 0; }
}

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .print-area { box-shadow: none !important; }
  .app-footer, .topbar, .sidebar { display: none !important; }
}
