/* ==========================================================================
   BUSY API Platform - Enterprise Dashboard Stylesheet (Clean Modern Light Theme)
   Zero Harsh Black - SaaS Design System - High Contrast & Crisp Typography
   ========================================================================== */

:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --sidebar-hover: #f1f5f9;
  --sidebar-active: #eff6ff;
  --sidebar-active-text: #2563eb;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-sidebar: #475569;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-family);
  -webkit-user-select: none;
  user-select: none;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar Layout */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.sidebar-header {
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  color: white;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.logo-text h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.5px;
}

.logo-text span {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

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

.nav-section-title {
  padding: 0.85rem 1.25rem 0.35rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #94a3b8;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background-color: var(--sidebar-hover);
  color: #0f172a;
}

.nav-item.active {
  background-color: var(--sidebar-active);
  color: var(--sidebar-active-text);
  font-weight: 600;
  border-left-color: var(--primary);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fafbfc;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  background-color: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.user-details h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #0f172a;
}

.user-details span {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.btn-logout {
  background: white;
  border: 1px solid #fecaca;
  color: #dc2626;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 5px 9px;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.btn-logout:hover {
  background-color: #fee2e2;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-main);
}

.top-bar {
  min-height: 60px;
  height: auto;
  background-color: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-title {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}

.page-title h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.3;
  word-break: break-word;
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
}
.status-dot.offline {
  background-color: var(--danger);
}

.content-body {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

/* KPI Metric Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  margin-top: 0.5rem;
  color: var(--text-main);
}

/* Data Tables */
.card-table {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  margin-bottom: 1.5rem;
  max-width: 100%;
}

.table-header {
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background-color: #fafbfc;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.table-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
  min-width: 650px;
}

th {
  background-color: #f8fafc;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-main);
}

tr:hover td {
  background-color: #f8fafc;
}

/* Toggle Switches */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: .2s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(16px);
}

/* Live Terminal Log (Clean Modern Light Console) */
.terminal-card {
  background-color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #334155;
  font-family: var(--font-mono);
  padding: 1rem;
  font-size: 0.82rem;
  height: 220px;
  overflow-y: auto;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}

.terminal-line {
  line-height: 1.6;
  word-break: break-all;
  font-family: inherit;
}

.terminal-line.outbound {
  color: #0284c7;
  font-weight: 500;
}

.terminal-line.inbound {
  color: #16a34a;
  font-weight: 500;
}

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

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

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 90%;
  max-width: 520px;
  padding: 1.5rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

.modal-card h3 {
  margin-bottom: 1rem;
  color: #0f172a;
  font-size: 1.15rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.35rem;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text-main);
  background-color: white;
  transition: border-color 0.15s ease;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* API Documentation Styles */
.api-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: var(--font-mono);
}

.api-badge.get {
  background-color: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.api-badge.post {
  background-color: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.api-badge.delete {
  background-color: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.api-badge.put {
  background-color: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}

.api-badge.patch {
  background-color: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.api-badge.ws {
  background-color: #f5f3ff;
  color: #7c3aed;
  border: 1px solid #ddd6fe;
}

.api-badge.rpc {
  background-color: #ecfeff;
  color: #0891b2;
  border: 1px solid #a5f3fc;
}

.api-badge.sub {
  background-color: #fdf2f8;
  color: #db2777;
  border: 1px solid #fbcfe8;
}

.api-endpoint-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1.25rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  transition: box-shadow 0.15s ease;
}

.api-endpoint-card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.api-endpoint-header {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  background-color: #fafbfc;
  border-bottom: 1px solid var(--border);
}

.api-endpoint-path {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: #0f172a;
}

.api-endpoint-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex: 1;
}

.api-endpoint-body {
  padding: 1.25rem;
  background-color: #ffffff;
}

.api-code-block {
  background-color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #1e293b;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  position: relative;
}

.api-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 8px;
  font-size: 0.72rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
}
.api-copy-btn:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.api-test-sandbox {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.api-response-viewer {
  background-color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.85rem;
  margin-top: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  max-height: 280px;
  overflow-y: auto;
  color: #1e293b;
}

/* ==========================================
   Enterprise Login Screen Styles
   ========================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 50% 25%, #f8fafc 0%, #e2e8f0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 1.5rem;
}

.login-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  padding: 2.5rem;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(15, 23, 42, 0.04);
  animation: loginSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-logo {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-radius: 12px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 1.6rem;
  box-shadow: 0 8px 16px -4px rgba(37, 99, 235, 0.35);
}

.login-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-header h2 {
  font-size: 1.45rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.025em;
  margin-bottom: 0.25rem;
}

.login-header p {
  color: #64748b;
  font-size: 0.85rem;
}

.login-role-pills {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.login-pill {
  flex: 1;
  padding: 0.45rem 0.6rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.login-pill:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #2563eb;
}

.login-form-group {
  margin-bottom: 1.15rem;
}

.login-form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.35rem;
}

.login-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #0f172a;
  transition: all 0.15s ease;
}

.login-input:focus {
  background: #ffffff;
  border-color: #2563eb;
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.login-btn {
  width: 100%;
  padding: 0.75rem;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  transition: all 0.2s ease;
}

.login-btn:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.login-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.login-footer-badge {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.72rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

/* Selective Sync Checkbox UI */
.modal-card-lg {
  max-width: 620px !important;
  width: 92% !important;
}

.sync-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.sync-actions-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.sync-tool-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sync-tool-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #1e293b;
}

.sync-badge-count {
  background: #dbeafe;
  color: #1d4ed8;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.sync-list-container {
  max-height: 330px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sync-list-container::-webkit-scrollbar {
  width: 6px;
}
.sync-list-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.sync-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #f1f5f9;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.sync-checkbox-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.sync-checkbox-item.checked {
  background: #eff6ff;
  border-color: #93c5fd;
}

.sync-checkbox-item input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: #2563eb;
  cursor: pointer;
}

.sync-item-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.sync-item-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: #1e293b;
  flex: 1;
}

.sync-item-sub {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 1px;
}

.sync-search-box {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
  color: #1e293b;
  background: #ffffff;
}
.sync-search-box:focus {
  border-color: #2563eb;
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.badge-status-active {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-status-disabled {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* ============================================================
   Granular Permission Matrix Styles (Voucher-wise & Master-wise)
   ============================================================ */
.perm-preset-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.perm-preset-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  margin-right: 0.35rem;
}

.btn-preset {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
}

.btn-preset:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.btn-preset-primary {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.btn-preset-primary:hover {
  background: #dbeafe;
  border-color: #60a5fa;
}

.btn-preset-danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #e11d48;
}

.btn-preset-danger:hover {
  background: #ffe4e6;
  border-color: #fda4af;
}

.perm-section-card {
  margin: 1.25rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.perm-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}

.perm-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-perm-count {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  background: #e2e8f0;
  color: #334155;
}

.badge-perm-count.active {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.perm-table-container {
  overflow-x: auto;
  max-height: 480px;
}

.perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.perm-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  text-align: center;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #cbd5e1;
  z-index: 2;
  white-space: nowrap;
}

.perm-table th:first-child {
  text-align: left;
  padding-left: 1.25rem;
}

.perm-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  text-align: center;
  vertical-align: middle;
}

.perm-table td:first-child {
  text-align: left;
  padding-left: 1.25rem;
}

.perm-table tr:hover td {
  background: #f8fafc;
}

.perm-entity-name {
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.perm-entity-sub {
  font-size: 0.74rem;
  color: #64748b;
  margin-top: 1px;
}

.btn-row-all, .btn-row-none {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
}

.btn-row-all:hover {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.btn-row-none:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

/* ========================================================
   Multi-Company Switcher & Management Cards
   ======================================================== */
.company-selector-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #f8fafc;
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.company-selector-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #64748b;
  text-transform: uppercase;
  white-space: nowrap;
}

.company-dropdown {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.32rem 0.6rem;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  transition: all 0.15s ease;
  max-width: 240px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.company-dropdown:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

#fin-year-selector {
  max-width: 170px;
}

.company-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.company-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.company-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.company-card.active-company {
  border: 2px solid #6366f1;
  background: #fdfdfe;
}

.company-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.company-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.company-card-code {
  font-size: 0.75rem;
  font-weight: 600;
  background: #e0e7ff;
  color: #4338ca;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.company-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.8rem;
  border-bottom: 1px dashed #f1f5f9;
}

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

.company-meta-key {
  color: #64748b;
  font-weight: 500;
}

.company-meta-val {
  color: #1e293b;
  font-weight: 600;
  font-family: var(--font-mono, monospace);
  font-size: 0.76rem;
}

.company-badge-default {
  background: #dcfce7;
  color: #15803d;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid #bbf7d0;
}

.btn-set-default {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.45rem;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-set-default:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
  color: #3730a3;
}

/* Sidebar Mobile Off-Canvas Drawer & Toggle */
.sidebar-toggle-btn {
  display: none;
}
.sidebar-backdrop {
  display: none;
}

/* ========================================================
   Mobile & Responsive Adjustments Across All Screen Sizes
   ======================================================== */
@media (max-width: 1200px) {
  .company-dropdown {
    max-width: 190px;
  }
}

@media (max-width: 1024px) {
  .top-bar {
    padding: 0.6rem 1rem;
    gap: 0.5rem;
  }
  .company-dropdown {
    max-width: 160px;
    font-size: 0.8rem;
  }
  #fin-year-selector {
    max-width: 130px;
  }
  .page-title h1 {
    font-size: 1.05rem;
  }
  .header-actions {
    gap: 0.4rem;
  }
  .summary-hero-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

@media (max-width: 768px) {
  .sidebar-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    margin-right: 8px;
    color: #475569;
    border-radius: 6px;
    transition: background-color 0.15s ease;
  }
  .sidebar-toggle-btn:hover {
    background: #f1f5f9;
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 998;
  }
  .sidebar-backdrop.open {
    display: block;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: -290px;
    width: 275px;
    height: 100vh;
    z-index: 999;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: var(--bg-sidebar);
  }
  .sidebar.open {
    left: 0;
  }
  .app-layout {
    flex-direction: row;
    position: relative;
  }
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    min-height: auto;
  }
  .page-title {
    width: 100%;
    display: flex;
    align-items: center;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .company-selector-wrapper {
    flex: 1 1 auto;
    min-width: 140px;
  }
  .company-dropdown {
    width: 100%;
    max-width: none;
  }
  #fin-year-selector-wrapper {
    flex: 0 1 auto;
    min-width: 110px;
  }
  #fin-year-selector {
    max-width: none;
  }
  .status-badge {
    font-size: 0.72rem;
    padding: 0.25rem 0.6rem;
  }
  .content-body {
    padding: 0.85rem;
  }
  .summary-hero-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
  .category-cards-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .view-toggle-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .toggle-group {
    width: 100%;
    justify-content: center;
  }
  .toggle-pill {
    flex: 1;
    text-align: center;
  }
  .modal-card {
    width: 96% !important;
    padding: 1rem !important;
    max-height: 94vh;
  }
}

@media (max-width: 480px) {
  .header-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .company-selector-wrapper {
    width: 100%;
  }
  .status-badge {
    justify-content: center;
    width: 100%;
  }
}

/* ========================================================
   Beautiful Dashboard & Category Summary Cards
   ======================================================== */
.summary-hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-hero-card {
  position: relative;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1.35rem 1.4rem;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-hero-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.stat-hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.stat-hero-card.sales::before { background: linear-gradient(90deg, #10b981, #059669); }
.stat-hero-card.vouchers::before { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.stat-hero-card.purchase::before { background: linear-gradient(90deg, #f59e0b, #d97706); }
.stat-hero-card.finance::before { background: linear-gradient(90deg, #8b5cf6, #7c3aed); }
.stat-hero-card.masters::before { background: linear-gradient(90deg, #06b6d4, #0891b2); }
.stat-hero-card.items::before { background: linear-gradient(90deg, #10b981, #047857); }
.stat-hero-card.accounts::before { background: linear-gradient(90deg, #6366f1, #4f46e5); }

.stat-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.stat-hero-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.stat-hero-icon.sales { background: #ecfdf5; color: #059669; }
.stat-hero-icon.vouchers { background: #eff6ff; color: #2563eb; }
.stat-hero-icon.purchase { background: #fffbeb; color: #d97706; }
.stat-hero-icon.finance { background: #f5f3ff; color: #7c3aed; }
.stat-hero-icon.masters { background: #ecfeff; color: #0891b2; }
.stat-hero-icon.items { background: #ecfdf5; color: #047857; }
.stat-hero-icon.accounts { background: #eef2ff; color: #4f46e5; }

.stat-hero-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 0.25rem;
}

.stat-hero-count {
  font-size: 2rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
}

.stat-hero-sub {
  font-size: 0.85rem;
  font-weight: 600;
  color: #059669;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.category-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.category-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
}

.category-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.07);
}

.category-card.active {
  border-color: #2563eb;
  background: #f8faff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.category-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.category-card-icon {
  font-size: 1.2rem;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
}

.category-card-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

.category-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid #f1f5f9;
}

.category-count-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e293b;
  background: #f1f5f9;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}

.category-amount-badge {
  font-size: 0.82rem;
  font-weight: 700;
  color: #059669;
}

.view-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.toggle-group {
  display: inline-flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.toggle-pill {
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all 0.15s ease;
}

.toggle-pill.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ==========================================
   Separate Portals & Profile Management Styles
   ========================================== */

/* Super Admin Portal Accent */
.admin-login-card {
  border-top: 4px solid #f59e0b;
}
.admin-login-card .login-logo {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid #f59e0b;
  color: #fbbf24;
}
.portal-switch-link {
  display: block;
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.82rem;
  color: #64748b;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease;
}
.portal-switch-link span {
  color: #2563eb;
  font-weight: 600;
}
.portal-switch-link:hover span {
  text-decoration: underline;
}

/* Profile View Styles */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

@media (max-width: 900px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

.profile-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.profile-card-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #f1f5f9;
}

.profile-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
}

.icon-blue {
  background: #eff6ff;
  color: #2563eb;
}

.icon-amber {
  background: #fffbeb;
  color: #d97706;
}

.icon-emerald {
  background: #ecfdf5;
  color: #059669;
}

.profile-card-title h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.profile-card-title p {
  font-size: 0.8rem;
  color: #64748b;
  margin: 2px 0 0 0;
}

.profile-field-group {
  margin-bottom: 1.1rem;
}

.profile-field-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.35rem;
}

.profile-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #0f172a;
  outline: none;
  background: #ffffff;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.profile-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.profile-input[readonly] {
  background: #f8fafc;
  color: #64748b;
  cursor: not-allowed;
  border-color: #e2e8f0;
}

.profile-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f8fafc;
  font-size: 0.85rem;
}

.profile-info-label {
  color: #64748b;
  font-weight: 500;
}

.profile-info-value {
  color: #0f172a;
  font-weight: 600;
}


