/* =============================================
   Twende Business Portal - Main Stylesheet
   ============================================= */

:root {
  --primary:       #1B3A6B;
  --primary-dark:  #142D54;
  --primary-light: #2B5A9E;
  --accent:        #FF6B00;
  --accent-dark:   #CC5500;
  --accent-light:  #FF8C33;
  --sidebar-bg:    #0F1B2D;
  --sidebar-hover: #1B3A6B;
  --sidebar-active:#2B5A9E;
  --bg:            #F0F4F8;
  --surface:       #FFFFFF;
  --border:        #E2E8F0;
  --text-primary:  #1A202C;
  --text-secondary:#4A5568;
  --text-muted:    #A0AEC0;
  --success:       #38A169;
  --warning:       #D69E2E;
  --danger:        #E53E3E;
  --info:          #3182CE;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 2px 12px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 24px rgba(0,0,0,0.12);
  --transition:    0.2s ease;
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

/* ── Reset ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; }
ul { list-style: none; }

/* ── Scrollbar ────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* =============================================
   Login Screen
   ============================================= */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0F1B2D 0%, #1B3A6B 50%, #142D54 100%);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 64px;
  height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(27,58,107,0.3);
}

.login-logo h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

.login-error {
  background: #FFF5F5;
  border: 1px solid #FED7D7;
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 20px;
  display: none;
}

.login-error.show { display: block; }

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-secondary);
}

.login-footer a {
  color: var(--primary);
  font-weight: 600;
  transition: color var(--transition);
}

.login-footer a:hover {
  color: var(--primary-light);
  text-decoration: underline;
}

/* =============================================
   Register Screen
   ============================================= */
#register-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0F1B2D 0%, #1B3A6B 50%, #142D54 100%);
  padding: 20px;
}

.register-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 720px;
  box-shadow: var(--shadow-md);
}

.register-card .login-logo { margin-bottom: 28px; }

.register-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}

.register-full {
  grid-column: 1 / -1;
}

/* =============================================
   Form Elements
   ============================================= */
.form-group {
  margin-bottom: 20px;
}

.form-group label,
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,58,107,0.12);
  background: var(--surface);
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234A5568' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group-modal {
  margin-bottom: 16px;
}

.form-group-modal label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group-modal .form-control { background: var(--surface); }

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

/* ── Checkbox ────────────────────────────── */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Toggle Switch ────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #CBD5E0;
  border-radius: 26px;
  transition: background-color 0.3s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--success);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* =============================================
   Buttons
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
  outline: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 12px rgba(255,107,0,0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: 0 6px 16px rgba(255,107,0,0.4);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(27,58,107,0.25);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 6px 16px rgba(27,58,107,0.35);
  transform: translateY(-1px);
}

.btn-secondary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #C53030;
  transform: translateY(-1px);
}

.btn-danger:active { transform: translateY(0); }

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #2F855A;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 2px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text-primary);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 16px;
}

/* =============================================
   App Layout
   ============================================= */
#app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition), width var(--transition);
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(255,107,0,0.3);
}

.sidebar-brand {
  color: white;
}

.sidebar-brand h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-brand span {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.3);
  padding: 16px 20px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all var(--transition);
  margin: 2px 8px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: rgba(255,255,255,0.9);
}

.nav-item.active {
  background: var(--sidebar-active);
  color: white;
  border-left-color: var(--accent);
  box-shadow: 0 4px 12px rgba(43,90,158,0.25);
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
}

.nav-item .nav-label { flex: 1; }

.nav-item .nav-badge {
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 0 5px;
  animation: badge-pop 0.3s ease;
}

.nav-item.active .nav-badge { background: rgba(255,255,255,0.3); }

@keyframes badge-pop {
  from { transform: scale(0); }
  50%  { transform: scale(1.2); }
  to   { transform: scale(1); }
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: white;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; overflow: hidden; }
.sidebar-user-name {
  color: white;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  color: rgba(255,255,255,0.4);
  font-size: 11px;
}

/* ── Main Area ────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Top Bar ──────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 20px;
  transition: background var(--transition);
}

.topbar-menu-btn:hover { background: var(--bg); }

.topbar-title {
  flex: 1;
}

.topbar-title h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-title p {
  font-size: 12px;
  color: var(--text-secondary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-company {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-company-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-company-role {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ── Wallet Badge (topbar) ────────────────── */
.wallet-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(27,58,107,0.08);
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  border: 1px solid rgba(27,58,107,0.15);
  transition: background var(--transition);
}

.wallet-badge:hover {
  background: rgba(27,58,107,0.14);
}

.wallet-badge .wallet-icon {
  font-size: 16px;
}

.btn-logout {
  background: none;
  border: 2px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: #FFF5F5;
}

/* ── Page Content ─────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* ── Page Header ──────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* =============================================
   Stat Cards
   ============================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card.stat-blue    { border-left-color: var(--primary); }
.stat-card.stat-orange  { border-left-color: var(--accent); }
.stat-card.stat-green   { border-left-color: var(--success); }
.stat-card.stat-red     { border-left-color: var(--danger); }
.stat-card.stat-warning { border-left-color: var(--warning); }
.stat-card.stat-info    { border-left-color: var(--info); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.icon-blue    { background: rgba(27,58,107,0.1);  color: var(--primary); }
.stat-icon.icon-orange  { background: rgba(255,107,0,0.1);  color: var(--accent); }
.stat-icon.icon-green   { background: rgba(56,161,105,0.1); color: var(--success); }
.stat-icon.icon-red     { background: rgba(229,62,62,0.1);  color: var(--danger); }
.stat-icon.icon-warning { background: rgba(214,158,46,0.1); color: var(--warning); }
.stat-icon.icon-info    { background: rgba(49,130,206,0.1); color: var(--info); }

.stat-info { flex: 1; min-width: 0; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 4px;
}

.stat-title {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-change {
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Period Stats (smaller inline) ────────── */
.period-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.period-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
}

.period-stat .value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.period-stat .label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* =============================================
   Cards / Panels
   ============================================= */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card + .card {
  margin-top: 24px;
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.card-body { padding: 24px; }

/* ── Wallet Card ──────────────────────────── */
.wallet-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius);
  padding: 32px;
  color: white;
  box-shadow: 0 8px 32px rgba(27,58,107,0.25);
  position: relative;
  overflow: hidden;
}

.wallet-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}

.wallet-card::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: -20px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
}

.wallet-card .wallet-label {
  font-size: 13px;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.wallet-card .wallet-balance {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}

.wallet-card .wallet-currency {
  font-size: 14px;
  opacity: 0.7;
  position: relative;
  z-index: 1;
}

.wallet-card .wallet-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.wallet-card .btn-wallet {
  background: rgba(255,255,255,0.2);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wallet-card .btn-wallet:hover {
  background: rgba(255,255,255,0.3);
}

/* =============================================
   Tables
   ============================================= */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:nth-child(even) { background: rgba(0,0,0,0.012); }

tbody tr:hover { background: rgba(27,58,107,0.04) !important; cursor: pointer; }

tbody td {
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text-primary);
  vertical-align: middle;
}

.cell-muted { color: var(--text-secondary); font-size: 12px; }

.cell-id {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.action-btns {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

tbody tr.row-highlight {
  background: rgba(27,58,107,0.04) !important;
}

/* =============================================
   Badges
   ============================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.badge-success  { background: #F0FFF4; color: #276749; }
.badge-danger   { background: #FFF5F5; color: #9B2C2C; }
.badge-warning  { background: #FFFAF0; color: #7B4B0B; }
.badge-info     { background: #EBF8FF; color: #1A4971; }
.badge-purple   { background: #FAF5FF; color: #44337A; }
.badge-gray     { background: #F7FAFC; color: #4A5568; }
.badge-orange   { background: #FFFAF0; color: #7B341E; }
.badge-blue     { background: #EBF4FF; color: #1B3A6B; }
.badge-active   { background: #EBF8FF; color: var(--info); }
.badge-completed{ background: #F0FFF4; color: var(--success); }
.badge-cancelled{ background: #FFF5F5; color: var(--danger); }
.badge-pending  { background: #FFFAF0; color: var(--warning); }

/* =============================================
   Search & Filters
   ============================================= */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.search-input .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}

.search-input input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}

.search-input input:focus { border-color: var(--primary); }

.filter-select {
  padding: 9px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}

.filter-select:focus { border-color: var(--primary); }

.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.filter-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.filter-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

.filter-tab:hover:not(.active) { color: var(--text-primary); }

.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-range input[type="date"] {
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}

.date-range input[type="date"]:focus { border-color: var(--primary); }

.date-range .separator {
  color: var(--text-muted);
  font-size: 13px;
}

/* =============================================
   Pagination
   ============================================= */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 13px;
  color: var(--text-secondary);
}

.pagination-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

.page-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.page-btn:hover:not(:disabled):not(.active) {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(27,58,107,0.05);
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* =============================================
   Modal
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}

.modal-box.modal-sm { max-width: 420px; }
.modal-box.modal-lg { max-width: 800px; }

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  background: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover { background: var(--border); color: var(--text-primary); }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Detail Grid inside Modal */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.detail-item label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.detail-item p {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

/* =============================================
   Toast Notifications
   ============================================= */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 360px;
  min-width: 260px;
  pointer-events: all;
  border-left: 4px solid var(--text-muted);
  animation: slideInRight 0.25s ease;
  transition: opacity 0.25s, transform 0.25s;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.toast.hiding { opacity: 0; transform: translateX(100%); }

.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-message { flex: 1; font-size: 13px; font-weight: 500; color: var(--text-primary); }
.toast-close { background: none; border: none; font-size: 16px; color: var(--text-muted); cursor: pointer; padding: 0; }
.toast-close:hover { color: var(--text-primary); }

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info    { border-left-color: var(--info); }

/* =============================================
   Loading Spinner
   ============================================= */
.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
  display: inline-block;
}

/* ── Loading Overlay ──────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.7);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease;
}

.loading-overlay .spinner {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

.loading-overlay p {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* =============================================
   Empty State
   ============================================= */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  max-width: 360px;
  margin: 0 auto;
  line-height: 1.6;
}

.empty-state .btn {
  margin-top: 20px;
}

/* =============================================
   Policy Sections
   ============================================= */
.policy-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.policy-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.policy-section-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.policy-section-header .badge {
  font-size: 10px;
}

.policy-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.policy-option:last-child { border-bottom: none; }

.policy-option-info {
  flex: 1;
}

.policy-option-info label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  cursor: pointer;
}

.policy-option-info p {
  font-size: 12px;
  color: var(--text-muted);
}

.policy-option-control {
  flex-shrink: 0;
  margin-left: 16px;
}

.policy-input {
  width: 120px;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: right;
  outline: none;
  transition: border-color var(--transition);
}

.policy-input:focus {
  border-color: var(--primary);
}

/* =============================================
   Charts / Graphs Placeholder
   ============================================= */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.chart-placeholder {
  height: 220px;
  background: linear-gradient(135deg, var(--bg) 0%, rgba(27,58,107,0.04) 100%);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  border: 2px dashed var(--border);
}

.chart-placeholder .chart-icon { font-size: 36px; }
.chart-placeholder p { font-size: 13px; font-weight: 500; }
.chart-placeholder span { font-size: 11px; }

/* =============================================
   Sidebar Overlay (mobile)
   ============================================= */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* =============================================
   Responsive
   ============================================= */

/* Tablet - sidebar collapses to icons */
@media (max-width: 1100px) and (min-width: 901px) {
  :root {
    --sidebar-width: 72px;
  }

  .sidebar-brand,
  .nav-section-label,
  .nav-item .nav-label,
  .nav-item .nav-badge,
  .sidebar-user-info {
    display: none;
  }

  .sidebar-header {
    justify-content: center;
    padding: 16px;
  }

  .sidebar-logo-icon {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .nav-item {
    justify-content: center;
    padding: 12px;
    margin: 2px 8px;
    border-left: none;
  }

  .nav-item.active {
    border-left: none;
  }

  .nav-item .nav-icon {
    width: auto;
    font-size: 18px;
  }

  .sidebar-user {
    justify-content: center;
    padding: 8px;
  }

  .sidebar-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
}

/* Mobile - sidebar slides in */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }

  .sidebar-overlay { display: block; }

  .topbar-menu-btn { display: flex; }

  .main-area { width: 100%; }

  .page-content { padding: 20px 16px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  .charts-grid { grid-template-columns: 1fr; }

  .form-row { grid-template-columns: 1fr; }

  .register-columns { grid-template-columns: 1fr; }

  .detail-grid { grid-template-columns: 1fr; }

  .card-header { padding: 16px; }
  .card-body { padding: 16px; }

  .filter-bar { gap: 8px; }
  .search-input { max-width: 100%; }

  .topbar { padding: 0 16px; }
  .topbar-company-name, .topbar-company-role { display: none; }

  .page-header { margin-bottom: 20px; }
  .page-header h2 { font-size: 18px; }

  .wallet-card { padding: 24px; }
  .wallet-card .wallet-balance { font-size: 28px; }

  .policy-option {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .policy-option-control {
    margin-left: 0;
    width: 100%;
  }

  .policy-input { width: 100%; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .period-stats { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 22px; }
  .modal-box { margin: 0; border-radius: var(--radius-sm); }
  .pagination { flex-direction: column; align-items: flex-start; }
  .login-card { padding: 32px 24px; }
  .register-card { padding: 32px 24px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header-actions { width: 100%; }
  .date-range { flex-wrap: wrap; }
}

/* =============================================
   Utility Classes
   ============================================= */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.font-mono { font-family: 'Courier New', monospace; }
.text-muted { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-primary-color { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mr-2 { margin-right: 8px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.d-flex { display: flex; }
.d-none { display: none; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; display: inline-block; }

/* Highlight rows that are pending action */
.pending-row { border-left: 3px solid var(--warning) !important; }

/* Online indicator dot */
.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(56,161,105,0.25);
  animation: pulse 2s infinite;
}

.offline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(56,161,105,0.25); }
  50% { box-shadow: 0 0 0 5px rgba(56,161,105,0.1); }
}

/* Section heading inside page */
.section-heading {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
}

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* =============================================
   Summary / Info Row
   ============================================= */
.info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  font-size: 14px;
}

.info-row:last-child { border-bottom: none; }

.info-row .info-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.info-row .info-value {
  color: var(--text-primary);
  font-weight: 600;
}

/* =============================================
   Department Tag
   ============================================= */
.dept-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(27,58,107,0.08);
  color: var(--primary);
}

/* =============================================
   Alert / Notice Banners
   ============================================= */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.alert-info {
  background: #EBF8FF;
  border: 1px solid #BEE3F8;
  color: #1A4971;
}

.alert-warning {
  background: #FFFAF0;
  border: 1px solid #FEEBC8;
  color: #7B4B0B;
}

.alert-danger {
  background: #FFF5F5;
  border: 1px solid #FED7D7;
  color: #9B2C2C;
}

.alert-success {
  background: #F0FFF4;
  border: 1px solid #C6F6D5;
  color: #276749;
}

.alert-icon { font-size: 18px; flex-shrink: 0; }

/* =============================================
   Tabs (Page-Level)
   ============================================= */
.page-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.page-tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition);
}

.page-tab:hover {
  color: var(--text-primary);
}

.page-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* =============================================
   Print Styles
   ============================================= */
@media print {
  .sidebar,
  .topbar,
  .sidebar-overlay,
  #toast-container,
  .topbar-menu-btn,
  .btn-logout,
  .page-header-actions,
  .filter-bar,
  .pagination {
    display: none !important;
  }

  .main-area {
    margin: 0;
  }

  .page-content {
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }

  body {
    background: white;
  }
}

/* ── Delivery Item Rows ──────────────── */
.delivery-item-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}

.delivery-item-row .form-row {
  gap: 10px;
}

.delivery-item-row .form-group {
  margin-bottom: 6px;
}

.delivery-item-row label {
  font-size: 11px;
}
