@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");

/* ============================================================
   ROOT VARIABLES
   ============================================================ */
:root {
  --color-primary: #ff8c01;
  --color-primary-hover: #e07800;
  --color-primary-light: rgba(255, 140, 1, 0.1);
  --color-secondary: #015933;
  --color-secondary-light: rgba(1, 89, 51, 0.1);

  --color-success: #1d9e75;
  --color-success-light: rgba(29, 158, 117, 0.1);
  --color-warning: #ba7517;
  --color-warning-light: rgba(186, 117, 23, 0.1);
  --color-danger: #d85a30;
  --color-danger-light: rgba(216, 90, 48, 0.1);

  /* Neutral palette */
  --color-white: #ffffff;
  --color-surface: #ffffff;
  --color-background: #f5f5f2;
  --color-border: rgba(55, 53, 47, 0.12);
  --color-border-strong: rgba(55, 53, 47, 0.25);

  --color-text-primary: #1a1a1a;
  --color-text-secondary: #5a5a5a;
  --color-text-muted: #9a9a9a;

  /* Dark mode overrides */
  --color-dark-bg: #15171a;
  --color-dark-surface: #1e2023;
  --color-dark-surface-2: #25282c;
  --color-dark-border: rgba(255, 255, 255, 0.08);
  --color-dark-text: #e8e8e8;
  --color-dark-text-sec: #9a9da3;

  /* Spacing & shape */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1), 0 3px 8px rgba(0, 0, 0, 0.05);

  /* Layout */
  --sidebar-width: 220px;
  --sidebar-collapsed: 64px;
  --topbar-height: 60px;
  --card-padding: 1.25rem;
}

/* ============================================================
   DARK THEME
   ============================================================ */
body[theme="dark"] {
  --color-background: var(--color-dark-bg);
  --color-surface: var(--color-dark-surface);
  --color-border: var(--color-dark-border);
  --color-border-strong: rgba(255, 255, 255, 0.15);
  --color-text-primary: var(--color-dark-text);
  --color-text-secondary: var(--color-dark-text-sec);
  --color-text-muted: #666;
  --left-msg-bg: var(--color-dark-surface-2);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family:
    "Poppins",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  font-size: 0.875rem;
  line-height: 1.6;
  background: var(--color-background);
  color: var(--color-text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}
img {
  display: block;
  width: 100%;
}
button {
  font-family: inherit;
  cursor: pointer;
}
input,
textarea,
select {
  font-family: inherit;
}

h1 {
  font-size: 1.6rem;
  font-weight: 600;
}
h2 {
  font-size: 1.2rem;
  font-weight: 600;
}
h3 {
  font-size: 0.95rem;
  font-weight: 500;
}
h4 {
  font-size: 0.85rem;
  font-weight: 500;
}
small {
  font-size: 0.75rem;
}

.text-muted {
  color: var(--color-text-muted);
}
.text-secondary {
  color: var(--color-text-secondary);
}
.text-primary-c {
  color: var(--color-primary);
}
.text-success {
  color: var(--color-success);
}
.text-warning {
  color: var(--color-warning);
}
.text-danger {
  color: var(--color-danger);
}

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.container {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 1fr;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
aside {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.25s ease;
  overflow: hidden;
}

/* Logo area */
.sidebar-logo {
  padding: 0 16px;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidebar-logo .logo-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.sidebar-logo .logo-text {
  overflow: hidden;
}
.sidebar-logo .logo-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
}
.sidebar-logo .logo-sub {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* Nav sections */
.sidebar-section {
  padding: 16px 16px 4px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

/* Nav links */
aside .sidebar {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

aside .sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--color-text-secondary);
  border-left: 2px solid transparent;
  border-radius: 0;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-size: 0.85rem;
  position: relative;
}

aside .sidebar a:hover {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

aside .sidebar a.active {
  color: var(--color-primary);
  background: var(--color-primary-light);
  border-left-color: var(--color-primary);
  font-weight: 500;
}

aside .sidebar a span.material-icons-sharp {
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: margin 0.15s;
}

aside .sidebar a h3 {
  font-size: 0.85rem;
  font-weight: 400;
  white-space: nowrap;
}

aside .sidebar a.active h3 {
  font-weight: 500;
}

/* Badge (unread count) */
.sidebar-badge {
  margin-left: auto;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* Sidebar divider */
.sidebar-divider {
  height: 1px;
  background: var(--color-border);
  margin: 8px 16px;
  flex-shrink: 0;
}

/* Sidebar user profile at bottom */
.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-user .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-user .user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-user .user-info {
  overflow: hidden;
}
.sidebar-user .user-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .user-role {
  font-size: 0.65rem;
  color: var(--color-text-muted);
}

/* Close button (mobile) */
aside .close {
  display: none;
  position: absolute;
  top: 14px;
  right: 14px;
  cursor: pointer;
  color: var(--color-text-secondary);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
main {
  grid-column: 2;
  margin-left: 0;
  min-height: 100vh;
  padding: calc(var(--topbar-height) + 24px) 28px 24px;
  transition: margin-left 0.25s ease;
}

/* Dim overlay when sidebar is open on mobile */
@media screen and (max-width: 900px) @media screen and (max-width: 900px) {
  aside.open ~ main::before,
  aside.open ~ .topbar::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99;
    pointer-events: all;
  }
}

/* Page header */
.page-header {
  margin-bottom: 24px;
}

.page-header .breadcrumb {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.page-header p {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* ============================================================
   TOP BAR (mobile menu + theme toggle + profile)
   ============================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 28px;
  gap: 12px;
  z-index: 99;
  transition: left 0.25s ease;
}

.topbar .menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-secondary);
  padding: 4px;
}

#theme-toggler {
  display: flex;
  align-items: center;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
  cursor: pointer;
}

#theme-toggler span {
  font-size: 1rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  transition: all 0.2s;
}

#theme-toggler span.active-mode {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

#sun {
  color: #ba7517;
}
#moon {
  color: #5a5a5a;
}

.topbar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: background 0.15s;
}

.topbar-profile:hover {
  background: var(--color-background);
}

.topbar-profile .info {
  text-align: right;
}
.topbar-profile .info .name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-primary);
}
.topbar-profile .info .role {
  font-size: 0.68rem;
  color: var(--color-text-muted);
}

.profile-photo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--color-border);
}

/* ============================================================
   STAT / INSIGHT CARDS
   ============================================================ */
.insights {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--card-padding);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition:
    box-shadow 0.2s,
    transform 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-card .card-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card .card-icon.orange {
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.stat-card .card-icon.green {
  background: var(--color-success-light);
  color: var(--color-success);
}
.stat-card .card-icon.teal {
  background: var(--color-secondary-light);
  color: var(--color-secondary);
}
.stat-card .card-icon.red {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.stat-card .card-icon span {
  font-size: 1.2rem;
}

.stat-card .card-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  font-weight: 500;
}

.stat-card .card-value {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1;
}

.stat-card .card-sub {
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-card .card-sub .up {
  color: var(--color-success);
}
.stat-card .card-sub .down {
  color: var(--color-danger);
}

/* Accent left border variant */
.stat-card.accent-orange {
  border-left: 3px solid var(--color-primary);
}
.stat-card.accent-green {
  border-left: 3px solid var(--color-secondary);
}
.stat-card.accent-red {
  border-left: 3px solid var(--color-danger);
}

/* ============================================================
   QUICK ACTIONS BAR
   ============================================================ */
.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  cursor: pointer;
  white-space: nowrap;
}

.btn span.material-icons-sharp {
  font-size: 1rem;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover {
  background: var(--color-background);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}
.btn-ghost:hover {
  background: var(--color-background);
  color: var(--color-text-primary);
}

.btn-danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background: var(--color-danger);
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.75rem;
}
.btn-lg {
  padding: 10px 22px;
  font-size: 0.9rem;
}

/* ============================================================
   ROOM GRID (DASHBOARD)
   ============================================================ */
/* ----------------------------------------------------------
   FIX 6: Section title spacing above room grid
   ---------------------------------------------------------- */
.section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-bottom: 12px;
  margin-top: 4px;
}

.cards-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

/* ----------------------------------------------------------
   FIX 3: Room card button — strip default browser styles
   Buttons inside .cards-list look like plain buttons
   in some browsers; this makes them invisible wrappers.
   ---------------------------------------------------------- */
.cards-list button {
  all: unset;
  cursor: pointer;
  display: block;
  width: 100%;
}

.cards-list button:focus-visible .room-card {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ----------------------------------------------------------
   FIX 4: Room card layout
   ---------------------------------------------------------- */
.room-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.room-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(255, 140, 1, 0.12);
  transform: translateY(-1px);
}

.room-card .room-number {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  font-weight: 500;
}

.room-card .room-count {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.room-card .room-status {
  font-size: 0.68rem;
  color: var(--color-text-muted);
}

/* Status colour overrides */
.room-card.status-full .room-count {
  color: var(--color-danger);
}
.room-card.status-almost .room-count {
  color: var(--color-warning);
}
.room-card.status-avail .room-count {
  color: var(--color-success);
}
.room-card.status-full {
  border-color: rgba(216, 90, 48, 0.2);
  background: rgba(216, 90, 48, 0.03);
}
.room-card.status-avail {
  border-color: rgba(29, 158, 117, 0.2);
}

/* ----------------------------------------------------------
   FIX 5: Quick actions — allow <a> tags styled as .btn
   The btn class was only set up for <button> elements.
   ---------------------------------------------------------- */
a.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

a.btn:hover {
  text-decoration: none;
}

/* Room card as form button */
.cards-list > form {
  display: contents;
}
/* .cards-list > form > button {
  all: unset;
  cursor: pointer;
} */
.cards-list > form > button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: block;
  width: 100%;
  text-align: left;
}

/* ============================================================
   DATA TABLE
   ============================================================ */
.table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--card-padding);
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
  flex-wrap: wrap;
}

.table-toolbar h2 {
  font-size: 0.95rem;
  font-weight: 600;
}

.table-toolbar .toolbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Search box */
.search-box {
  display: flex;
  align-items: center;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0 10px;
  gap: 6px;
  height: 34px;
  transition: border-color 0.15s;
}

.search-box:focus-within {
  border-color: var(--color-primary);
}

.search-box span {
  font-size: 1rem;
  color: var(--color-text-muted);
}

.search-input {
  border: none;
  background: transparent;
  font-size: 0.82rem;
  color: var(--color-text-primary);
  outline: none;
  width: 200px;
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
}

table thead tr {
  background: var(--color-background);
  border-bottom: 1px solid var(--color-border);
}

table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  font-weight: 500;
  white-space: nowrap;
}

table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.82rem;
  color: var(--color-text-primary);
  vertical-align: middle;
}

table tbody tr:last-child td {
  border-bottom: none;
}

table tbody tr:hover {
  background: var(--color-background);
}

/* Action buttons in table */
#actions,
td#actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

#actions a,
#actions button,
td#actions a,
td#actions button {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

#actions span,
td#actions span {
  font-size: 0.9rem;
}

#actions a:hover,
td#actions a:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
#actions form,
td#actions form {
  width: auto;
}

span#edit-icon:hover {
  color: var(--color-warning) !important;
}
span#delete-icon {
  color: var(--color-danger) !important;
}
span#payment-icon {
  color: var(--color-success) !important;
}
span#payment-history-icon {
  color: var(--color-secondary) !important;
}
span#print-icon {
  color: var(--color-success) !important;
}

/* Status badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-boarding {
  background: var(--color-secondary-light);
  color: var(--color-secondary);
}
.badge-success {
  background: var(--color-success-light);
  color: var(--color-success);
}
.badge-warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
}
.badge-danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
}
.badge-info {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* Tenant payment-standing badges (reuse themed vars → dark mode handled) */
.standing-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}
.standing-reliable { background: var(--color-success-light); color: var(--color-success); }
.standing-usually  { background: var(--color-primary-light); color: var(--color-primary); }
.standing-late     { background: var(--color-warning-light); color: var(--color-warning); }
.standing-risk     { background: var(--color-danger-light);  color: var(--color-danger);  }
.standing-new      { background: var(--color-border);        color: var(--color-text-muted); }
.standing-behind   { font-size: 0.72rem; font-weight: 600; color: var(--color-danger); }

/* ============================================================
   FORMS
   ============================================================ */
.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--card-padding) 1.5rem;
  max-width: 680px;
}

.form-card + .form-card {
  margin-top: 20px;
}

.form-section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.form-field input,
.form-field select,
.form-field textarea,
#login-form input[type="text"],
#login-form input[type="password"],
#login-form input[type="date"],
#login-form input[type="datetime-local"],
#login-form input[type="number"],
#login-form input[type="email"],
#login-form select {
  padding: 8px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-background);
  color: var(--color-text-primary);
  font-size: 0.85rem;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  outline: none;
  width: 100%;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
#login-form input:focus,
#login-form select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
  background: var(--color-surface);
}

.form-field input::placeholder {
  color: var(--color-text-muted);
}
.form-field textarea {
  resize: vertical;
  min-height: 80px;
}

/* Password field wrapper */
.password-field {
  position: relative;
}

.password-field input {
  padding-right: 40px;
}

.password-field .toggler {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 1rem;
  color: var(--color-text-muted);
  user-select: none;
}

.password-field .toggler:hover {
  color: var(--color-primary);
}

/* Checkbox */
.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
}

.checkbox-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

.checkbox-field label {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  line-height: 1.4;
}

/* Form actions */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* Inline note */
.form-note {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 4px;
  padding: 8px 12px;
  background: var(--color-background);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-primary);
}

/* Submit button inside old form (backward compat) */
#login-form input[type="submit"],
.form-card input[type="submit"] {
  padding: 9px 20px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 16px;
}

#login-form input[type="submit"]:hover,
.form-card input[type="submit"]:hover {
  background: var(--color-primary-hover);
}

/* ============================================================
   MULTI-STEP WIZARD
   ============================================================ */
.wizard-steps {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
  position: relative;
}

.wizard-steps::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  height: 1px;
  background: var(--color-border);
  z-index: 0;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  position: relative;
  z-index: 1;
}

.wizard-step .step-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-muted);
  transition: all 0.2s;
}

.wizard-step .step-label {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  text-align: center;
}

.wizard-step.done .step-circle {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
  color: #fff;
}
.wizard-step.done .step-label {
  color: var(--color-secondary);
}

.wizard-step.active .step-circle {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  box-shadow: 0 0 0 4px var(--color-primary-light);
}
.wizard-step.active .step-label {
  color: var(--color-primary);
  font-weight: 500;
}

/* ============================================================
   SETTINGS TABS
   ============================================================ */
.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.settings-tab {
  padding: 10px 18px;
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.settings-tab:hover {
  color: var(--color-primary);
}

.settings-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 500;
}

.settings-panel {
  display: none;
}
.settings-panel.active {
  display: block;
}

.settings-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
  gap: 20px;
}
.settings-row:last-child {
  border-bottom: none;
}

.settings-row .setting-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-primary);
}

.settings-row .setting-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

.settings-row .setting-ctrl {
  flex-shrink: 0;
}

/* Toggle switch */
.toggle-switch {
  width: 40px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--color-border-strong);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-switch.on {
  background: var(--color-success);
}

.toggle-switch::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.toggle-switch.on::after {
  left: 20px;
}

/* Settings input */
.settings-input {
  padding: 7px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-background);
  font-size: 0.82rem;
  color: var(--color-text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.settings-input:focus {
  border-color: var(--color-primary);
}
.settings-input-sm {
  width: 80px;
}
.settings-input-md {
  width: 160px;
}

/* ============================================================
   CHAT / ANNOUNCEMENTS
   ============================================================ */
.chat-layout {
  display: flex;
  height: calc(100vh - var(--topbar-height) - 48px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: var(--color-surface);
}

.chat-header .chat-info h3 {
  font-size: 0.9rem;
  font-weight: 600;
}

.chat-header .chat-info p {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.online-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--color-background);
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: 4px;
}

.date-divider {
  text-align: center;
  font-size: 0.68rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.date-divider::before,
.date-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 75%;
}

.msg.left-msg {
  align-self: flex-start;
}
.msg.right-msg {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-secondary);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 600;
  color: #fff;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.5;
}

.left-msg .msg-bubble {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--color-border);
}

.right-msg .msg-bubble {
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-info {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
}
.msg-info-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}
.msg-info-time {
  font-size: 0.65rem;
  color: var(--color-text-muted);
}
.right-msg .msg-info {
  flex-direction: row-reverse;
}

/* Admin announcement badge */
.msg.announcement .msg-bubble {
  background: var(--color-primary-light);
  border: 1px solid rgba(255, 140, 1, 0.3);
  border-radius: 12px;
}

/* Chat input */
.chat-input-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-surface);
  flex-shrink: 0;
}

.chat-message-area {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  background: var(--color-background);
  font-size: 0.85rem;
  color: var(--color-text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.chat-message-area:focus {
  border-color: var(--color-primary);
  background: var(--color-surface);
}
.chat-message-area::placeholder {
  color: var(--color-text-muted);
}

.chat-send-button {
  padding: 9px 18px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-send-button:hover {
  background: var(--color-primary-hover);
}

/* ============================================================
   MODAL
   ============================================================ */
/* ----------------------------------------------------------
   FIX 7: Modal overlay — ensure it renders as flex
   The PHP sets style="display: flex;" but only if the
   CSS default is also compatible.
   ---------------------------------------------------------- */
.modal-window {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
}

/* When PHP sets display:flex via inline style, this
   keeps the backdrop blur working */
.modal-window[style*="flex"] {
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal-window > div {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 90%;
  max-width: 820px;
  max-height: 82vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--color-background);
}
.modal-close:hover {
  background: var(--color-danger-light);
  color: var(--color-danger);
}
.modal-close span {
  font-size: 1.1rem;
}

.modal-edit-info-container {
  margin-bottom: 16px;
}
.modal-edit-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-edit-info h3 {
  font-size: 1rem;
  font-weight: 600;
}
.modal-edit-info form button {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: all 0.15s;
}
.modal-edit-info form button:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* ============================================================
   NOTIFICATIONS / ALERTS
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  margin-bottom: 16px;
}
.alert span.material-icons-sharp {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-success {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid rgba(29, 158, 117, 0.25);
}
.alert-warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
  border: 1px solid rgba(186, 117, 23, 0.25);
}
.alert-danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border: 1px solid rgba(216, 90, 48, 0.25);
}
.alert-info {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid rgba(255, 140, 1, 0.25);
}

/* ----------------------------------------------------------
   FIX 2: #returnedResultDelete pink bar bleed-through
   PHP outputs whitespace even when there's no message,
   which makes :not(:empty) fire. Only show when it has
   real visible text content via JS, OR switch to display:none
   by default and only show when ?error= is present.
   This blanket reset ensures it never shows as a blank bar.
   ---------------------------------------------------------- */
#returnedResultDelete,
#returnedResult,
#returnedResultEdit,
#returnedResult-payFee {
  display: none;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  margin: 0 0 16px;
}

/* Only show when the PHP actually populates the div.
   Use the .show class added by PHP/JS, not :not(:empty). */
#returnedResultDelete.show,
#returnedResult.show,
#returnedResultEdit.show,
#returnedResult-payFee.show {
  display: block;
  color: var(--color-danger);
  background: var(--color-danger-light);
  border: 1px solid rgba(216, 90, 48, 0.25);
}

#returnedResultDelete.show-success,
#returnedResult.show-success {
  color: var(--color-success);
  background: var(--color-success-light);
  border: 1px solid rgba(29, 158, 117, 0.25);
}

#successful-payFee {
  color: var(--color-success);
  background: var(--color-success-light);
  border-color: rgba(29, 158, 117, 0.25);
}

/* ============================================================
   FAQ / HELP
   ============================================================ */
.faq-item {
  border-bottom: 1px solid var(--color-border);
}
.faq-item:last-child {
  border-bottom: none;
}

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-primary);
  gap: 12px;
}

.faq-question span.material-icons-sharp {
  font-size: 1.1rem;
  color: var(--color-text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.faq-item.open .faq-question span.material-icons-sharp {
  transform: rotate(180deg);
  color: var(--color-primary);
}
.faq-item.open .faq-question {
  color: var(--color-primary);
}

.faq-answer {
  display: none;
  padding: 0 0 14px;
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  line-height: 1.7;
}
.faq-item.open .faq-answer {
  display: block;
}

/* ============================================================
   PAYMENT RECORD / RECEIPT
   ============================================================ */
.payment-log-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-select {
  padding: 7px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: 0.82rem;
  color: var(--color-text-primary);
  outline: none;
  cursor: pointer;
}

#history-action-btns {
  display: flex;
  gap: 4px;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--color-background);
}

.login-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 48px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.login-logo .logo-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}

.login-logo .logo-text h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-primary);
}
.login-logo .logo-text p {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

#login-form {
  width: 100%;
  max-width: 360px;
  border: none;
  padding: 0;
}

#login-form .form-field {
  margin-bottom: 16px;
}

.login-right {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  background: linear-gradient(
    135deg,
    var(--color-primary) 0%,
    var(--color-primary-hover) 100%
  );
  color: #fff;
}

/* ============================================================
   RIGHT SIDEBAR (recent updates)
   ============================================================ */
.right-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  height: 100vh;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  padding: 0;
  overflow-y: auto;
  transition: transform 0.25s ease;
  z-index: 98;
}

.right-panel-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--color-border);
}

.right-panel-header h2 {
  font-size: 0.85rem;
  font-weight: 600;
}

.recent-updates {
  padding: 16px;
}
.recent-updates h2 {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.update {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.update:last-child {
  border-bottom: none;
}

.update .profile-photo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--color-secondary);
}

.update .message p {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--color-text-primary);
}
.update .message small {
  font-size: 0.68rem;
  color: var(--color-text-muted);
}
.update .message b {
  color: var(--color-primary);
  font-weight: 600;
}

/* ============================================================
   DROPDOWN (custom select)
   ============================================================ */
.input-group-dropdown .dropdown {
  width: 200px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-background);
  padding: 8px 12px;
  position: relative;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-text-primary);
  transition: border-color 0.15s;
}
.input-group-dropdown .dropdown:focus-within {
  border-color: var(--color-primary);
}
.input-group-dropdown .dropdown .dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 50;
  display: none;
  overflow: hidden;
}
.input-group-dropdown .dropdown.active .dropdown-menu {
  display: block;
}
.input-group-dropdown .dropdown-menu li {
  padding: 8px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s;
}
.input-group-dropdown .dropdown-menu li:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.dropdown-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

/* ============================================================
   TOOLTIP
   ============================================================ */
.tooltip {
  position: relative;
  cursor: help;
}
.tooltip .tooltiptext {
  visibility: hidden;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text-primary);
  color: var(--color-surface);
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* ============================================================
   PRINT / RECEIPT
   ============================================================ */
@media print {
  aside,
  .topbar,
  .right-panel,
  .quick-actions {
    display: none !important;
  }
  main {
    margin: 0 !important;
    padding: 0 !important;
  }
}

/* ============================================================
   SCROLLBAR (global)
   ============================================================ */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media screen and (max-width: 1100px) {
  .insights {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media screen and (max-width: 900px) {
  .container {
    grid-template-columns: 1fr;
  }

  aside {
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  aside.open {
    transform: translateX(0);
  }
  aside .close {
    display: flex;
  }

  main {
    grid-column: 1; /* ← THIS is the missing fix */
    margin-left: 0;
    padding: calc(var(--topbar-height) + 16px) 16px 16px;
  }

  /* .right {
    display: none;
  } */

  .top {
    display: none;
  }

  .topbar {
    left: 0;
  }
  .topbar .menu-btn {
    display: flex;
  }

  .insights {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .cards-list {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  .login-shell {
    grid-template-columns: 1fr;
  }
  .login-right {
    display: none;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media screen and (max-width: 600px) {
  .quick-actions {
    gap: 6px;
  }
  .btn {
    padding: 7px 12px;
    font-size: 0.78rem;
  }
  table thead th:nth-child(n + 4) {
    display: none;
  }
  table tbody td:nth-child(n + 4) {
    display: none;
  }
}

/* ----------------------------------------------------------
   FIX 1: Stat card internal layout
   The icon, label, value and sub-text stack vertically
   with the icon separated from the text block.
   ---------------------------------------------------------- */
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  min-height: 140px;
}

.stat-card .card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.stat-card .card-icon span.material-icons-sharp {
  font-size: 1.3rem;
}

.stat-card .card-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  font-weight: 500;
  line-height: 1;
}

.stat-card .card-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.stat-card .card-sub {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
}

.stat-card .card-sub .up {
  color: var(--color-success);
  font-weight: 500;
}
.stat-card .card-sub .down {
  color: var(--color-danger);
  font-weight: 500;
}

/* Accent border variants */
.stat-card.accent-orange {
  border-left: 3px solid var(--color-primary);
}
.stat-card.accent-green {
  border-left: 3px solid var(--color-secondary);
}
.stat-card.accent-red {
  border-left: 3px solid var(--color-danger);
}

/* ============================================================
   NOTIFICATION BELL (topbar)
   ============================================================ */
.notif {
  position: relative;
  display: flex;
  align-items: center;
}
.notif-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.notif-trigger:hover { color: var(--color-primary); }
.notif-trigger .material-icons-sharp { font-size: 1.25rem; }

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  background: var(--color-danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 17px;
  text-align: center;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-surface);
}

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  max-width: 88vw;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 200;
  overflow: hidden;
}
.notif.open .notif-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-primary);
}
.notif-markall {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.notif-markall:hover { text-decoration: underline; }

.notif-list {
  max-height: 420px;
  overflow-y: auto;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  position: relative;
  transition: background 0.12s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-background); }
.notif-item.is-unread { background: var(--color-primary-light); }
.notif-item.is-unread:hover { background: var(--color-primary-light); }

.notif-ico {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--color-background);
  color: var(--color-text-secondary);
}
.notif-ico .material-icons-sharp { font-size: 1.05rem; }
.notif-ico.sev-success { background: var(--color-success-light); color: var(--color-success); }
.notif-ico.sev-warning { background: var(--color-warning-light); color: var(--color-warning); }
.notif-ico.sev-danger  { background: var(--color-danger-light);  color: var(--color-danger); }
.notif-ico.sev-info    { background: var(--color-primary-light); color: var(--color-primary); }

.notif-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.notif-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-primary);
}
.notif-text {
  font-size: 0.74rem;
  color: var(--color-text-secondary);
  line-height: 1.35;
}
.notif-time {
  font-size: 0.66rem;
  color: var(--color-text-muted);
  margin-top: 1px;
}
.notif-dot {
  position: absolute;
  top: 16px;
  right: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  flex-shrink: 0;
}

.notif-empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--color-text-muted);
}
.notif-empty .material-icons-sharp {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}
.notif-empty p { font-size: 0.82rem; margin: 0; }

/* ============================================================
   SEGMENTED TOGGLE (Active / Archived tenant filter)
   ============================================================ */
.seg-toggle {
  display: inline-flex;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}
.seg-toggle .seg-btn {
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-toggle .seg-btn:hover { color: var(--color-text-primary); }
.seg-toggle .seg-btn.active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* Archive / restore action icons */
#actions .icon-btn:hover span,
td#actions .icon-btn:hover span { color: var(--color-primary) !important; }
