:root {
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --bg: #f8fafc;
  --panel-bg: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #cbd5e1;
  --red: #ef4444;
  --green: #10b981;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --sidebar-width: 260px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Login Screen Layout */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(circle at top left, #f0f9ff, var(--bg));
}

.login-card {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  padding: 40px;
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05);
}

.login-brand {
  margin-bottom: 32px;
  justify-content: center;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-card p {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}

.login-form select,
.login-form input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: var(--panel-bg);
  color: var(--text);
}

.login-form select:disabled {
  background: var(--bg);
  cursor: not-allowed;
}

.login-form small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  text-align: center;
}

/* Core Dashboard Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  border-right: 1px solid var(--line);
  background: #0f172a;
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  color: #f8fafc;
}

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

.brand-mark {
  background: var(--primary);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
}

.brand span {
  display: block;
  font-size: 11px;
  color: #94a3b8;
}

.nav-stack {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  padding: 12px 14px;
  border-radius: 8px;
  color: #94a3b8;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s;
}

.nav-button:hover {
  background: #1e293b;
  color: #f8fafc;
}

.nav-button.active {
  font-weight: 600;
  color: #fff;
  background: var(--primary);
}

.nav-button .icon {
  width: 20px;
  font-weight: bold;
}

.role-switch {
  border-top: 1px solid #1e293b;
  padding-top: 16px;
}

.role-switch span {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 6px;
}

.role-switch select {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #1e293b;
  font-family: inherit;
  background: #1e293b;
  color: #fff;
}

/* Main Panel and View Area */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 40px;
  max-width: 1400px;
  width: calc(100% - var(--sidebar-width));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  gap: 20px;
}

.topbar h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
}

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

/* Combined Profile Menu Button & Dropdown Styles */
.user-profile-menu-container {
  position: relative;
  display: inline-block;
}

.profile-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 30px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}

.profile-dropdown-trigger:hover {
  background: #e2e8f0;
}

.profile-trigger-avatar {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  overflow: hidden;
}

.profile-trigger-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-trigger-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.profile-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  min-width: 160px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.profile-dropdown-item {
  background: transparent;
  border: none;
  padding: 10px 16px;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  width: 100%;
  transition: background 0.2s;
}

.profile-dropdown-item:hover {
  background: #f1f5f9;
}

.profile-dropdown-item.logout-btn-style {
  color: var(--red);
  border-top: 1px solid var(--line);
}

/* Button UI Components */
.primary-button, .secondary-button, .ghost-button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-hover);
}

.secondary-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.secondary-button:hover {
  background: #f1f5f9;
}

.ghost-button {
  background: transparent;
  color: var(--muted);
}

.ghost-button:hover {
  background: #e2e8f0;
  color: var(--text);
}

.full {
  width: 100%;
}

/* Metrics and Panel Grids */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.metric {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.metric span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.metric strong {
  display: block;
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0;
  color: #0f172a;
}

.metric small {
  font-size: 12px;
  color: var(--muted);
}

.dashboard-grid, .community-grid, .settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--muted);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
}

.panel.wide {
  grid-column: 1 / -1;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 16px;
}

.panel-header.compact {
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.panel-header p {
  font-size: 13px;
  color: var(--muted);
}

/* Tables Layout styling */
.table-wrap {
  overflow-x: auto;
  margin: 0 -24px -24px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

th, td {
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
}

th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

/* Status Badges */
.status, .badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.status.paid, .status.approved { background: #d1fae5; color: #065f46; }
.status.partial, .status.pending { background: #fef3c7; color: #92400e; }
.status.due, .status.rejected { background: #fee2e2; color: #991b1b; }

.badge { background: #e0f2fe; color: var(--primary); }
.badge.muted { background: #f1f5f9; color: var(--muted); text-transform: none; }

/* Lists and Items feeds structures */
.queue-list, .notice-list, .bar-list, .transaction-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.queue-item, .feed-item {
  padding: 16px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}

.queue-item strong, .feed-item strong {
  display: block;
}

.queue-item small, .feed-item small {
  color: var(--muted);
  font-size: 12px;
}

.queue-item p, .feed-item p {
  margin-top: 8px;
  font-size: 13px;
}

.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.row-actions button {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
}

.row-actions button.approve { background: #10b981; color: white; }
.row-actions button.reject { background: #ef4444; color: white; }

/* Notice layout section distinction adjustments */
.notice-section-container {
  border: 1px solid var(--muted) !important;
  box-shadow: 0 4px 20px -2px rgba(14, 165, 233, 0.15) !important;
  background: #f0f9ff !important;
}

.notice-item {
  padding: 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  transition: transform 0.2s;
}

.notice-item:hover {
  transform: translateY(-1px);
}

.notice-item.important {
  border-left: 5px solid var(--red);
  background: #fff5f5;
  border-color: #fecaca var(--line) #fecaca #ef4444;
}

.notice-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

/* Graphical Analytics List Styling */
.bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.bar-track {
  background: #e2e8f0;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  background: var(--primary);
  height: 100%;
}

/* Member Portal Screens Layout */
.screen { display: none; }
.screen.active { display: block; }

.notice-front {
  margin-bottom: 24px;
}

.notices-layout-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

@media(max-width: 992px) {
  .notices-layout-split {
    grid-template-columns: 1fr;
  }
}

.member-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: start;
}

.profile-panel {
  text-align: center;
  align-items: center;
}

.avatar {
  width: 64px;
  height: 64px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 24px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  overflow: hidden;
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  gap: 12px;
  margin: 20px 0;
}

.profile-stats div {
  background: #f8fafc;
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 8px;
}

.profile-stats span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.profile-stats strong {
  font-size: 14px;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.member-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

/* Database Filters Panel */
.filter-row {
  display: flex;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}

.filter-row input, .filter-row select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
}

.filter-row input {
  flex: 1;
  min-width: 200px;
}

/* Settings view blocks */
.code-box {
  background: #1f2937;
  color: #f9fafb;
  padding: 16px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 13px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.setup-list p {
  margin-bottom: 12px;
  font-size: 14px;
}

.checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.checklist li::before {
  content: "✓";
  color: var(--primary);
  font-weight: bold;
}

/* Dialog Modal UI Overlays */
.modal {
  border: none;
  border-radius: 16px;
  margin: auto;
  background: transparent;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(4px);
}

.modal-card {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  padding: 32px;
  width: 480px;
  max-width: calc(100vw - 32px);
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.icon-button {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
}

.modal-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}

.modal-card input, .modal-card select, .modal-card textarea {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
}

/* Proof Links Styling */
.proof-link {
  color: var(--blue);
  text-decoration: underline;
  cursor: pointer;
}

/* Fixed input overflow and styled distinct container context border variables */
.credential-box-styled {
  background: #ffffff;
  border: 2px solid var(--primary);
  box-shadow: 0 8px 30px rgba(14, 165, 233, 0.12);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 100%;
}

.credential-box-styled h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.form-label-styled {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  width: 100%;
}

.form-label-styled input {
  width: 100%;
  max-width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: #f8fafc;
  color: var(--text);
  box-sizing: border-box;
}

.form-label-styled input:focus {
  border-color: var(--primary);
  background: #ffffff;
  outline: none;
}

/* Floating Bottom Right Responsive Chat Window Stylings */
.chat-widget-dock {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 280px;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  background: #0f172a;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.chat-status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
}

.chat-unread-badge {
  background: var(--red);
  color: white;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: bold;
}

.chat-item-unread-badge {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  font-size: 10px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 8px;
}

.chat-toggle-minimize {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.chat-body-container {
  height: 380px;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.chat-admin-directory {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

.chat-directory-title {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.chat-user-list {
  display: flex;
  flex-direction: column;
}

.chat-user-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.2s;
}

.chat-user-item:hover {
  background: #f1f5f9;
}

.chat-user-item strong {
  display: block;
  font-size: 13px;
  color: var(--text);
}

.chat-user-item span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-view-thread {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-back-to-list {
  background: #f1f5f9;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.chat-back-to-list:hover {
  color: var(--text);
}

.chat-messages-scroll {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
}

.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
}

.chat-bubble.me {
  background: var(--primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.chat-bubble.them {
  background: var(--line);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.chat-input-area {
  display: flex;
  border-top: 1px solid var(--line);
  padding: 8px;
  background: #fff;
}

.chat-input-area input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

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

.chat-input-area button {
  background: transparent;
  border: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  padding: 0 12px;
  cursor: pointer;
}

@media(max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; position: static; height: auto; }
  .main { margin-left: 0; width: 100%; padding: 20px; }
  .member-layout { grid-template-columns: 1fr; }
  .chat-widget-dock { width: calc(100% - 32px); bottom: 16px; right: 16px; }
}