/* ===== Chat Message List & Bubble ===== */
.msg-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 18px 22px 8px 22px;
  overflow-y: auto;
  min-height: 0;
  max-height: 100%;
  height: 100%;
  scroll-behavior: smooth;
}
.msg-bubble-wrap {
  display: flex;
  margin-bottom: 2px;
}
.msg-bubble-wrap.me {
  justify-content: flex-end;
}
.msg-bubble-wrap.friend {
  justify-content: flex-start;
}
.msg-bubble {
  max-width: 80%;
  padding: 8px 14px;
  border-radius: 16px;
  font-size: 1em;
  word-break: break-word;
  box-shadow: 0 1px 4px 0 rgba(25,118,210,0.06);
  display: inline-block;
  line-height: 1.5;
}
.msg-me {
  background: #e3f0ff;
  color: #1976d2;
  border-radius: 16px 16px 4px 16px;
  margin-left: 12%;
}
.msg-friend {
  background: #f1f5f9;
  color: #64748B;
  border-radius: 16px 16px 16px 4px;
  margin-right: 12%;
}
.msg-meta {
  text-align: right;
  font-size: 0.85em;
  color: #b0b8c9;
  margin-top: 2px;
}
.msg-time {
  margin-left: 8px;
}
@media (max-width: 600px) {
  .chat-window-popup, .chat-panel {
    width: 99vw;
    min-width: unset;
    max-width: 99vw;
    right: 0 !important;
    left: 0;
    border-radius: 0;
    margin: 0;
  }
  .msg-list {
    padding: 12px 6vw 8px 6vw;
    height: 38vh;
    max-height: 38vh;
  }
}
/* ===== ChatWindow Message Bubble ===== */
.chat-window-msg {
  background: #e3f0ff;
  color: #1976d2;
  border-radius: 12px 12px 4px 12px;
  padding: 8px 14px;
  margin: 6px 0 6px auto;
  max-width: 80%;
  font-size: 1em;
  word-break: break-word;
  box-shadow: 0 1px 4px 0 rgba(25,118,210,0.06);
  display: inline-block;
}
.chat-window-msg-me {
  background: #e3f0ff;
  color: #1976d2;
  align-self: flex-end;
}
/* ===== ChatWindow Popup ===== */
.chat-window-popup {
  position: fixed;
  right: 410px; /* ถัดจาก ChatPanel (370px + margin) */
  bottom: 24px;
  width: 370px;
  max-width: 98vw;
  min-height: 340px;
  max-height: 340px;
  height: 340px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 32px 0 rgba(25,118,210,0.13), 0 2px 8px 0 rgba(0,0,0,0.06);
  z-index: 1400;
  display: flex;
  flex-direction: column;
  animation: chatPanelIn 0.18s cubic-bezier(.4,1.4,.6,1) 1;
}
.chat-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 8px 22px;
  border-bottom: 1px solid #e3e8ef;
}
.chat-window-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-window-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #f1f5f9;
  border: 2px solid #e3e8ef;
}
.chat-window-userinfo {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-window-username {
  font-size: 1.08em;
  font-weight: 600;
  color: #1976d2;
}
.chat-window-caption {
  font-size: 0.98em;
  color: #64748B;
}
.chat-window-close {
  background: none;
  border: none;
  font-size: 1.6em;
  color: #64748B;
  cursor: pointer;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.chat-window-close:hover {
  background: #f1f5f9;
}
.chat-window-body {
  flex: 1 1 0;
  padding: 18px 22px 8px 22px;
  font-size: 1em;
  color: #64748B;
  overflow-y: auto;
}
.chat-window-empty {
  color: #b0b8c9;
  text-align: center;
  padding: 18px 0 18px 0;
  font-size: 1.02em;
}
.chat-window-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px 12px 22px;
  border-top: 1px solid #e3e8ef;
  background: #f8fafc;
}
.chat-window-input {
  flex: 1 1 0;
  border-radius: 8px;
  border: 1px solid #e3e8ef;
  padding: 7px 14px;
  font-size: 1em;
  background: #fff;
  color: #1976d2;
  outline: none;
  transition: border 0.18s;
}
.chat-window-input:focus {
  border: 1.5px solid #1976d2;
}
.chat-window-send {
  background: #1976d2;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 600;
  padding: 7px 18px;
  cursor: pointer;
  transition: background 0.18s;
}
.chat-window-send:disabled {
  background: #cbd5e1;
  color: #fff;
  cursor: not-allowed;
}
/* ===== Floating Chat Button ===== */
.floating-chat-btn {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 1200;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e3f0ff 60%, #f8fafc 100%);
  box-shadow: 0 4px 24px 0 rgba(25,118,210,0.10), 0 1.5px 6px 0 rgba(0,0,0,0.04);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: box-shadow 0.18s, background 0.18s;
  outline: none;
}
.floating-chat-btn:hover {
  box-shadow: 0 8px 32px 0 rgba(25,118,210,0.16), 0 2px 8px 0 rgba(0,0,0,0.06);
  background: linear-gradient(135deg, #e3f0ff 80%, #e0e7ef 100%);
}
.floating-chat-btn svg {
  display: block;
}
.floating-chat-unread {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 20px;
  height: 20px;
  background: #1976d2;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(25,118,210,0.10);
  pointer-events: none;
}

@media (max-width: 600px) {
  .floating-chat-btn {
    right: 14px;
    bottom: 14px;
    width: 52px;
    height: 52px;
  }
}

/* ===== Chat Panel Overlay ===== */
.chat-panel-overlay {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  top: 0;
  z-index: 1300;
  background: rgba(30,41,59,0.08);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}
.chat-panel {
  background: #fff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 8px 32px 0 rgba(25,118,210,0.13), 0 2px 8px 0 rgba(0,0,0,0.06);
  width: 370px;
  max-width: 98vw;
  min-height: 340px;
  max-height: 80vh;
  margin: 0 24px 24px 0;
  display: flex;
  flex-direction: column;
  animation: chatPanelIn 0.18s cubic-bezier(.4,1.4,.6,1) 1;
}
@keyframes chatPanelIn {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 8px 22px;
  font-size: 1.18em;
  font-weight: 700;
  color: #1976d2;
  border-bottom: 1px solid #e3e8ef;
}
.chat-panel-close {
  background: none;
  border: none;
  font-size: 1.6em;
  color: #64748B;
  cursor: pointer;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.chat-panel-close:hover {
  background: #f1f5f9;
}
.chat-panel-search-wrap {
  padding: 10px 22px 8px 22px;
  border-bottom: 1px solid #e3e8ef;
}
.chat-panel-search {
  width: 100%;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #e3e8ef;
  font-size: 1em;
  background: #f8fafc;
  color: #1976d2;
  outline: none;
  transition: border 0.18s;
}
.chat-panel-search:focus {
  border: 1.5px solid #1976d2;
}
.chat-panel-list {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 10px 0 10px 0;
  min-height: 120px;
}
.chat-panel-empty {
  color: #94A3B8;
  text-align: center;
  padding: 38px 0 38px 0;
  font-size: 1.08em;
}

/* ===== User List Item ===== */
.chat-user-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 22px 10px 22px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.13s;
}
.chat-user-item:last-child {
  border-bottom: none;
}
.chat-user-item:hover {
  background: #f5faff;
}
.chat-user-avatar-wrap {
  position: relative;
  width: 48px;
  height: 48px;
}
.chat-user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #f1f5f9;
  border: 2px solid #e3e8ef;
}
.chat-user-status {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #cbd5e1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.chat-user-status.online {
  background: #22c55e;
}
.chat-user-status.offline {
  background: #cbd5e1;
}
.chat-user-info {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-user-name {
  font-size: 1.08em;
  font-weight: 600;
  color: #1976d2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-user-caption {
  font-size: 0.98em;
  color: #64748B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-user-role {
  font-size: 0.92em;
  color: #94A3B8;
  margin-top: 1px;
}
.badge-name {
  font-size: 15px;
  color: #0F172A;
  font-weight: 600;
  margin-right: 8px;
  letter-spacing: 0.01em;
}
.badge-role {
  display: inline-flex;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  border-radius: 6px;
  padding: 2px 10px 2px 7px;
  margin-left: 0px;
  margin-right: 0;
  background: #F1F5F9;
  color: #64748B;
  gap: 5px;
}
.badge-role-icon {
  font-size: 16px;
  margin-right: 4px;
  display: inline-block;
}
/* ตัวอย่างสี role */
.badge-role--admin {
  background: #FDE68A;
  color: #B45309;
}
.badge-role--user {
  background: #DBEAFE;
  color: #2563EB;
}
.badge-role--owner {
  background: #FCA5A5;
  color: #B91C1C;
}
.badge-role--staff {
  background: #D1FAE5;
  color: #047857;
}
.modal.avatar-picker-modal-content {
  background: rgba(0,0,0,0.18);
}
.avatar-picker-modal-content {
  background: #fff;
  border-radius: 14px;
  padding: 28px 24px 18px 24px;
  min-width: 340px;
  max-width: 400px;
  box-shadow: 0 2px 16px 0 rgba(0,0,0,0.10);
  text-align: center;
}
.avatar-picker-title {
  font-size: 1.1rem;
  color: #334155;
  margin-bottom: 16px;
}
.avatar-picker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin-bottom: 18px;
}
.avatar-picker-item {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  transition: border 0.18s, box-shadow 0.18s;
}
.avatar-picker-item:hover {
  border: 2px solid #3B82F6;
  box-shadow: 0 2px 8px 0 rgba(59,130,246,0.10);
}
.avatar-picker-upload {
  margin: 12px 0 18px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.avatar-upload-label {
  color: #64748B;
  font-size: 13px;
  cursor: pointer;
}
.avatar-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.avatar-upload-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}
#avatarUploadInput {
  display: none;
}
#avatarUploadFileName {
  font-size: 12px;
  color: #94a3b8;
}
.modal-close-btn {
  margin-top: 8px;
  background: #CBD5E1;
  color: #334155;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  padding: 8px 24px;
  cursor: pointer;
  transition: background 0.2s;
}
.modal-close-btn:hover {
  background: #94A3B8;
  color: #fff;
}
.profile-avatar-container {
  position: relative;
  display: inline-block;
}
.profile-modal-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  display: block;
}
.profile-avatar-edit-btn {
  position: absolute;
  right: 0;
  bottom: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  box-shadow: 0 1px 4px 0 rgba(0,0,0,0.08);
  transition: box-shadow 0.15s;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-avatar-edit-btn:hover {
  box-shadow: 0 2px 8px 0 rgba(59,130,246,0.10);
  background: #e0e7ef;
}
/* ===== PROFILE MODAL BEAUTIFY ===== */
.profile-modal-content {
  max-width: 420px;
  padding: 0;
}
.profile-modal-body {
  padding: 0 24px 24px 24px;
}
.profile-card {
  background: #f8fbff;
  border-radius: 14px;
  box-shadow: 0 1px 6px rgba(43,125,197,0.07);
  padding: 14px 14px 12px 14px;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.profile-avatar-wrap {
  margin-bottom: 10px;
}
.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.profile-info-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  margin-top: 8px;
}
.profile-info-table td {
  padding: 0 0 0 0;
  font-size: 1rem;
}
.profile-info-label {
  color: var(--tc-muted);
  min-width: 110px;
  font-size: 0.98rem;
  font-weight: 500;
}
.profile-info-value {
  color: var(--tc-heading);
  font-weight: 600;
}
.profile-section-title {
  font-size: 1.08rem;
  font-weight: 600;
  margin: 10px 0 6px 0;
  color: var(--tc-heading);
  align-self: flex-start;
}
.profile-edit-btn {
  margin-left: 8px;
  font-size: 0.92rem;
  padding: 2px 12px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}
.profile-edit-btn:hover {
  background: var(--primary);
  color: #fff;
}
.profile-name-input {
  font-size: 1rem;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #ccc;
  min-width: 120px;
  max-width: 180px;
}
.profile-modal-content form button[type="submit"] {
  margin-top: 16px;
  width: 100%;
}
/* ===== PROFILE MODAL FORM EXTENSIONS ===== */
.profile-section-title {
  font-size: 1.08rem;
  font-weight: 600;
  margin: 10px 0 6px 0;
  color: var(--tc-heading);
}
.profile-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.profile-info-row > span:first-child {
  min-width: 110px;
  color: var(--tc-muted);
  font-size: 0.98rem;
}
.profile-input, .profile-pass-input, .profile-username-input, .profile-name-input {
  font-size: 1rem;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #ccc;
  min-width: 160px;
  max-width: 220px;
}
.pw-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pw-input-wrap .profile-input {
  flex: 1;
  max-width: unset;
  min-width: unset;
  width: 100%;
}
.pw-eye-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  color: #94a3b8;
  flex-shrink: 0;
  line-height: 1;
}
.pw-eye-btn:hover { color: #475569; }
.pw-eye-btn.active { color: #3b82f6; }
.profile-pass-input {
  min-width: 120px;
  max-width: 180px;
}
.profile-username-input {
  background: #f3f4f6;
  font-weight: 600;
  color: #888;
  }


  .profile-readonly-input[disabled], .profile-readonly-input[readonly] {
    background: #F1F5F9;
    color: #64748B;
    border: 1px solid #e2e8f0;
    cursor: not-allowed;
    font-size: 14px;
    font-weight: 400;
    box-shadow: none;
  }
  .profile-readonly-input[disabled]:focus, .profile-readonly-input[readonly]:focus {
    outline: none;
    border: 1px solid #e2e8f0;
    box-shadow: none;
  }

  .profile-editable-input {
    background: #fff;
    color: #0F172A;
    border: 1px solid #CBD5E1;
    font-size: 14px;
    border-radius: 6px;
    padding: 4px 10px;
    width: 100%;
    max-width: 260px;
    transition: border-color 0.2s;
  }
  .profile-editable-input:focus {
    border: 1.5px solid #3B82F6;
    outline: none;
  }

  .profile-info-label {
    font-size: 12px;
    color: #64748B;
    font-weight: 500;
    padding-bottom: 2px;
    vertical-align: top;
    text-align: left;
    width: 110px;
  }
  .profile-info-table td {
    padding: 0 0 16px 0;
    vertical-align: top;
  }
  .profile-info-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0;
    margin-bottom: 8px;
  }
  .profile-hint {
    color: #94A3B8;
    font-size: 11px;
    margin-top: 2px;
    margin-bottom: 0;
  }
  .profile-error {
    color: #dc2626;
    font-size: 12px;
    margin-top: 2px;
    margin-bottom: 0;
  }
  .profile-save-btn {
    margin-top: 8px;
    width: 100%;
    background: #3B82F6;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    padding: 10px 0;
    cursor: pointer;
    transition: background 0.2s;
  }
  .profile-save-btn:disabled {
    background: #CBD5E1;
    color: #64748B;
    cursor: not-allowed;
  }

  /* Profile Entity Display */
  .profile-entity-display {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
  }
  .profile-entity-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1.5px solid;
    white-space: nowrap;
    transition: transform 0.15s, box-shadow 0.15s;
  }
  .profile-entity-badge--active {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    transform: scale(1.02);
  }
  .profile-entity-empty {
    color: #94A3B8;
    font-size: 13px;
    font-style: italic;
  }

  .profile-modal-content {
    padding: 24px 24px 18px 24px;
    border-radius: 12px;
    background: #fff;
    min-width: 340px;
    max-width: 370px;
    box-shadow: 0 2px 16px 0 rgba(0,0,0,0.08);
  }

  .profile-hint {
    color: #64748B;
    font-size: 0.9em;
    margin-top: 4px;
  }

  .profile-error {
    color: #dc2626;
    font-size: 0.95em;
    margin-top: 4px;
}
.profile-modal-content form button[type="submit"] {
  margin-top: 10px;
  width: 100%;
}
/* ===== USER BADGE HEADER STYLE ===== */
.user-badge-avatar-wrap {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
}
.user-badge-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.user-badge-name {
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--tc-heading);
  margin-right: 6px;
}
/* ===== PROFILE MODAL ===== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }
#profileModal {
  align-items: center;
  overflow-y: hidden;
  padding: 0;
  padding-top: 72px;
}
.modal-backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.25);
}
.modal-content.profile-modal-content {
  position: relative;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 32px rgba(0,0,0,0.13);
  padding: 20px 20px 16px 20px;
  min-width: 340px;
  max-width: 96vw;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  z-index: 1;
}
.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  font-size: 2rem;
  color: #888;
  cursor: pointer;
}
.modal-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 12px;
  text-align: center;
}
.profile-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.profile-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.profile-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.profile-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.profile-info-row {
  display: flex;
  gap: 8px;
  font-size: 1rem;
  align-items: center;
}
.profile-name-input {
  font-size: 1rem;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #ccc;
  min-width: 120px;
}
.btn.btn-success {
  background: var(--success);
  color: #fff;
}
/* ========== CSS VARIABLES ========== */
:root {
  --primary: #0EA5E9;
  --primary-light: #7DD3FC;
  --primary-dark: #0284C7;
  --success: #10b981;
  --success-light: #d1fae5;
  --success-bg: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --purple-light: #EBF4FB;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #EAF4FB;
  --white: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --radius: 14px;
  --radius-sm: 8px;

  /* ── Typography Fonts ── */
  --font-brand:  'Kanit', 'Noto Sans Thai', sans-serif;
  --font-ui:     'IBM Plex Sans Thai', 'Noto Sans Thai', sans-serif;

  /* ── Typography Scale ── */
  /* Display */
  --fs-display-lg:  2rem;       /* 32px */
  --fs-display-md:  1.625rem;   /* 26px */
  /* Headings */
  --fs-h1:   1.375rem;   /* 22px */
  --fs-h2:   1.25rem;    /* 20px */
  --fs-h3:   1.125rem;   /* 18px */
  --fs-h4:   1rem;       /* 16px */
  /* Content */
  --fs-title:    0.9375rem;  /* 15px */
  --fs-subtitle: 0.875rem;   /* 14px */
  --fs-body-lg:  0.9375rem;  /* 15px */
  --fs-body:     0.875rem;   /* 14px */
  --fs-body-sm:  0.8125rem;  /* 13px */
  --fs-label:    0.8125rem;  /* 13px */
  --fs-caption:  0.75rem;    /* 12px */
  --fs-micro:    0.6875rem;  /* 11px */

  /* ── Font Weights ── */
  --fw-regular:   400;
  --fw-medium:    500;
  --fw-semibold:  600;
  --fw-bold:      700;
  --fw-extrabold: 800;

  /* ── Line Heights ── */
  --lh-tight:   1.3;
  --lh-normal:  1.6;
  --lh-relaxed: 1.75;

  /* ── Text Colors ── */
  --tc-heading:  #1e293b;   /* ข้อความหัวเรื่อง */
  --tc-primary:  #334155;   /* body หลัก */
  --tc-secondary:#475569;   /* secondary */
  --tc-muted:    #64748b;   /* muted / placeholder */
  --tc-disabled: #94a3b8;   /* disabled */
  --tc-brand:    #2B7DC5;   /* interactive / link */
  --tc-error:    #dc2626;
  --tc-success:  #059669;
  --tc-number:   #1e293b;   /* ตัวเลขสำคัญ */
  --tc-number-positive: #059669;
  --tc-number-negative: #dc2626;
}

/* ========== RESET ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Force browser form controls to inherit typography system ── */
input, select, textarea, button, optgroup, option {
  font-family: var(--font-ui);
  font-size: inherit;
  line-height: inherit;
}

/* ── Hide number input spinners globally ── */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

body {
  font-family: var(--font-ui);
  background: linear-gradient(150deg, #EAF4FB 0%, #DCEEFF 100%) fixed;
  color: var(--tc-primary);
  min-height: 100vh;
  font-size: var(--fs-body-lg);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  padding-top: calc(80px + env(safe-area-inset-top)); /* Space for header (68px) + small breathing room + iOS safe area */
}

/* ========== HEADER — Dashboard Control Bar ========== */
.header {
  background: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 300;
  box-shadow: 0 2px 12px rgba(43,125,197,.10);
  border-bottom: 1px solid #d4e8f5;
}
.header-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 68px;
}

/* ── Logo ── */
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.logo-emblem {
  width: 44px; height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
}
.logo-img { width: 44px; height: 44px; display: block; object-fit: contain; }
.logo-info { display: flex; flex-direction: column; }
.logo-text {
  font-size: var(--fs-h3);
  font-weight: var(--fw-bold);
  font-family: var(--font-brand);
  color: #3A7CA5;
  letter-spacing: -.3px;
  line-height: var(--lh-tight);
}
.logo-sub {
  font-size: var(--fs-caption);
  color: #7EB3D4;
  font-weight: var(--fw-medium);
}

/* ── Header Right ── */
.header-right {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
}

.header-clock {
  display: flex;
  align-items: center;
  gap: 0;
  line-height: 1;
}
.clock-date {
  font-size: 13px;
  color: #475569;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.clock-sep {
  font-size: 13px;
  color: #94a3b8;
  margin: 0 4px;
}
.clock-time {
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-medium);
  font-family: var(--font-ui);
  color: #334155;
  white-space: nowrap;
  min-height: 50px;
}
.user-badge > img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}
.user-badge::before { content: ''; }
.badge-name { color: #334155; font-weight: var(--fw-semibold); }
.badge-sep  { color: #CBD5E1; margin: 0 4px; }
.badge-role { color: #64748B; font-weight: 500; font-size: 12px; letter-spacing: 0.2px; }
.badge-entity-sep {
  display: inline-block;
  width: 1px; height: 13px;
  background: #E2E8F0;
  margin: 0 8px;
  vertical-align: middle;
}
.badge-entity {
  color: #475569;
  font-weight: 600;
  font-size: 12px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 6px 12px;
  white-space: nowrap;
  transition: all 0.2s ease;
  min-height: 50px;
  display: inline-flex;
  align-items: center;
}
.badge-entity--clickable {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}
.badge-entity--clickable:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
  color: #334155;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Entity Switcher Dropdown */
.entity-switcher-menu {
  position: fixed;
  z-index: 2000;
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
  min-width: 240px;
  max-width: 320px;
  overflow: hidden;
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.entity-switcher-menu.hidden { display: none; }
.esm-head {
  padding: 12px 16px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #64748B;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: #F8FAFC;
  border-bottom: 1px solid #E2E8F0;
}
.esm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: #334155;
  transition: background 0.15s ease;
}
.esm-item:hover { 
  background: #F8FAFC;
}
.esm-active { 
  background: #EFF6FF;
}
.esm-active .esm-name { 
  font-weight: 600; 
  color: #1E40AF;
}
.esm-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; 
  align-items: center; 
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.06);
}
.esm-icon svg { 
  width: 16px; 
  height: 16px; 
}
.esm-name { 
  flex: 1; 
  min-width: 0; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  white-space: nowrap;
  font-weight: 500;
}
.esm-check { 
  color: #3B82F6; 
  flex-shrink: 0; 
  display: flex; 
  align-items: center; 
}

/* Role Badge Pills */
.role-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 500; letter-spacing: 0.2px;
  border: 1px solid transparent;
  transition: filter .15s;
  cursor: default; white-space: nowrap;
}
.role-badge:hover { filter: brightness(0.94); }
.role-badge--superadmin { background: #EDE9FE; color: #6D28D9; border-color: #DDD6FE; }
.role-badge--owner      { background: #DBEAFE; color: #1E40AF; border-color: #BFDBFE; }
.role-badge--staff      { background: #D1FAE5; color: #065F46; border-color: #A7F3D0; }

/* Role Filter Pills (search bar) */
.role-filter-pill {
  display: inline-flex; align-items: center;
  padding: 5px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 500; letter-spacing: 0.2px;
  border: 1.5px solid #E2E8F0;
  background: #F8FAFC; color: #64748B;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.role-filter-pill:hover { background: #F1F5F9; color: #334155; }
.role-filter-pill.active { box-shadow: 0 0 0 2px currentColor; }
.role-filter-pill--all.active { background: #F1F5F9; color: #334155; border-color: #94A3B8; }
.role-filter-pill.role-badge--superadmin.active { box-shadow: 0 0 0 2px #6D28D9; }
.role-filter-pill.role-badge--owner.active      { box-shadow: 0 0 0 2px #1E40AF; }
.role-filter-pill.role-badge--staff.active      { box-shadow: 0 0 0 2px #065F46; }

/* Role Dropdown Menu Items */
.role-dd-item {
  display: flex; align-items: center; width: 100%;
  padding: 7px 10px; border: none; background: none;
  border-radius: 7px; cursor: pointer; font-size: 13px;
  color: #334155; text-align: left;
  transition: background .12s;
}
.role-dd-item:hover { background: #F1F5F9; }

/* ── Logo Group (logo + menu trigger side by side) ── */
.logo-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Menu Trigger (hamburger icon) ── */
.menu-trigger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px; height: 40px;
  background: #EBF4FB;
  border: 1px solid #d4e8f5;
  border-radius: 10px;
  cursor: pointer;
  padding: 9px 10px;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.menu-trigger-bar {
  display: block;
  height: 2px;
  background: #7EB3D4;
  border-radius: 2px;
  transition: transform .22s, opacity .22s, background .15s;
}
.menu-trigger:hover { background: #DCEEFF; border-color: #7EB3D4; }
.menu-trigger:hover .menu-trigger-bar { background: #2B7DC5; }
.menu-trigger.open { background: #2B7DC5; border-color: #5FA8D8; box-shadow: 0 2px 12px rgba(43,125,197,.5); }
.menu-trigger.open .menu-trigger-bar { background: #fff; }

/* ── Active Pill (legacy — kept for JS refs) ── */
.active-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(43,125,197,.18);
  border: 1px solid rgba(95,168,216,.35);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 700;
  color: #5FA8D8;
  white-space: nowrap;
  flex: 1;
}

/* ── Dropdown Overlay ── */
.dd-overlay {
  position: fixed;
  inset: 0;
  z-index: 298;
  background: rgba(0,0,0,.25);
}

/* ── Dropdown Panel ── */
.dd-panel {
  position: fixed;
  top: 76px;
  left: 24px;
  z-index: 299;
  width: 230px;
  background: #ffffff;
  border: 1px solid #d4e8f5;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(43,125,197,.12);
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - 96px);
  overscroll-behavior: contain;
  animation: ddIn .18s cubic-bezier(.4,0,.2,1);
}
@keyframes ddIn {
  from { opacity: 0; transform: translateY(-8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.dd-head {
  padding: 11px 16px 9px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: #7EB3D4;
  border-bottom: 1px solid #d4e8f5;
}
.dd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  color: var(--tc-secondary);
  text-align: left;
  transition: background .12s, color .12s;
}
.dd-item:hover { background: #EBF4FB; color: #2B7DC5; }
.dd-item.active { background: rgba(43,125,197,.2); color: #5FA8D8; }
.dd-icon { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; }
.dd-icon svg { width: 18px; height: 18px; display: block; }

/* Submenu styles */
.dd-item-group { position: relative; }
.dd-parent { position: relative; }
.dd-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: #F8FAFC;
  border-left: 2px solid #CBD5E1;
  margin-left: 12px;
}
.dd-item-group.open .dd-submenu {
  max-height: 200px;
}
.dd-item-group.open .dd-chevron {
  transform: rotate(180deg);
}
.dd-sub {
  padding: 10px 16px 10px 32px;
  font-size: 14px;
  font-weight: 500;
}
.dd-sub .dd-icon {
  width: 16px;
  height: 16px;
  font-size: 16px;
}

.dd-divider { height: 1px; background: #d4e8f5; margin: 4px 0; }
.dd-logout { color: #ef4444; }
.dd-logout:hover { background: rgba(239,68,68,.08); color: #dc2626; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .logo-sub { display: none; }
  .user-badge { display: none; }
  .active-pill { font-size: 13px; padding: 5px 10px; }
  .dd-panel { left: 12px; right: 12px; width: auto; }
}


/* ========== UTILITY ========== */

/* ── Entity Multi-Select Combobox ── */
.entity-combobox {
  position: relative;
  font-family: var(--font-ui);
}
.entity-combobox-trigger {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 42px;
  padding: 6px 36px 6px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: text;
  transition: border-color .15s;
  position: relative;
}
.entity-combobox-trigger:focus-within,
.entity-combobox.open .entity-combobox-trigger {
  border-color: var(--primary);
  outline: none;
}
.entity-combobox-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 12px;
  pointer-events: none;
  transition: transform .15s;
}
.entity-combobox.open .entity-combobox-arrow { transform: translateY(-50%) rotate(180deg); }
.entity-combobox-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 8px;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entity-combobox-tag-x {
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  opacity: .8;
  flex-shrink: 0;
}
.entity-combobox-tag-x:hover { opacity: 1; }
.entity-combobox-placeholder {
  color: var(--text-muted);
  font-size: var(--fs-body);
  padding: 2px 4px;
  pointer-events: none;
}
.entity-combobox-input {
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  color: var(--tc-primary);
  min-width: 80px;
  flex: 1;
  padding: 2px 4px;
}
.entity-combobox-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--white);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
}
.entity-combobox.open .entity-combobox-dropdown { display: block; }
.entity-combobox-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: var(--fs-body);
  color: var(--tc-primary);
  transition: background .1s;
  user-select: none;
}
.entity-combobox-option:hover { background: #EBF4FB; }
.entity-combobox-option.selected { background: #EBF4FB; font-weight: 600; }
.entity-combobox-empty {
  padding: 10px 14px;
  color: var(--text-muted);
  font-size: var(--fs-body-sm);
  text-align: center;
}
/* ── Customer Autocomplete ── */
.cust-ac-wrap { position: relative; }
.cust-ac-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--white);
  border: 1.5px solid var(--primary);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 300;
  max-height: 240px;
  overflow-y: auto;
}
.cust-ac-dropdown.open { display: block; }
.cust-ac-item {
  display: flex;
  flex-direction: column;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--tc-primary, #111827);
  border-bottom: 1px solid #f1f5f9;
  transition: background .1s;
}
.cust-ac-item:last-child { border-bottom: none; }
.cust-ac-item:hover, .cust-ac-item.ac-active { background: #EBF4FB; }
.cust-ac-item .ac-name { font-weight: 600; font-size: 13px; }
.cust-ac-item .ac-sub { font-size: 11px; color: #6b7280; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-ac-empty {
  padding: 10px 14px;
  color: var(--text-muted, #9ca3af);
  font-size: 12px;
  text-align: center;
}
/* legacy (entity-users modal ยังใช้ checkbox list) */
.entity-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
}
.entity-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  color: var(--tc-primary);
  transition: background .12s;
  user-select: none;
}
.entity-checkbox-item:hover { background: #EBF4FB; }
.entity-checkbox-item input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}

/* ── Utility ── */
.t-display   { font-family: var(--font-brand); font-size: var(--fs-display-md); font-weight: var(--fw-bold); line-height: var(--lh-tight); color: var(--tc-heading); }
.t-h1        { font-family: var(--font-brand); font-size: var(--fs-h1); font-weight: var(--fw-bold); line-height: var(--lh-tight); color: var(--tc-heading); }
.t-h2        { font-family: var(--font-brand); font-size: var(--fs-h2); font-weight: var(--fw-semibold); line-height: var(--lh-tight); color: var(--tc-heading); }
.t-h3        { font-family: var(--font-brand); font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: var(--lh-tight); color: var(--tc-heading); }
.t-title     { font-family: var(--font-ui); font-size: var(--fs-title); font-weight: var(--fw-semibold); color: var(--tc-heading); }
.t-subtitle  { font-family: var(--font-ui); font-size: var(--fs-subtitle); font-weight: var(--fw-regular); color: var(--tc-muted); }
.t-body      { font-family: var(--font-ui); font-size: var(--fs-body); font-weight: var(--fw-regular); line-height: var(--lh-normal); color: var(--tc-primary); }
.t-label     { font-family: var(--font-ui); font-size: var(--fs-label); font-weight: var(--fw-medium); color: var(--tc-secondary); }
.t-caption   { font-family: var(--font-ui); font-size: var(--fs-caption); font-weight: var(--fw-regular); color: var(--tc-muted); }
/* Number display — tabular nums for alignment */
.t-number    { font-family: var(--font-ui); font-variant-numeric: tabular-nums lining-nums; font-weight: var(--fw-semibold); color: var(--tc-number); }
.t-number-lg { font-family: var(--font-brand); font-size: var(--fs-h1); font-variant-numeric: tabular-nums lining-nums; font-weight: var(--fw-bold); }
.t-positive  { color: var(--tc-number-positive); }
.t-negative  { color: var(--tc-number-negative); }

.hidden { display: none !important; }

/* ========== MAIN LAYOUT ========== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}
.tab-content { display: block; }
.tab-content.hidden { display: none; }

/* ========== CARDS ========== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 4px 16px rgba(43,125,197,.07);
  margin-bottom: 20px;
  border: 1px solid #e8f3fb;
}
.card-title {
  font-size: var(--fs-h4);
  font-weight: var(--fw-semibold);
  font-family: var(--font-ui);
  margin-bottom: 16px;
  color: var(--tc-heading);
}
.card-subtitle {
  font-size: var(--fs-body-sm);
  color: var(--tc-muted);
  margin-top: -12px;
  margin-bottom: 16px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header .card-title { margin-bottom: 0; }

/* ========== PERIOD BAR ========== */
.period-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  flex-wrap: wrap;
}
.period-label { font-size: 14px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.period-buttons { display: flex; gap: 6px; flex-wrap: wrap; }

.period-btn {
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--tc-muted);
  padding: 5px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  font-weight: var(--fw-semibold);
  transition: all .2s;
}
.period-btn:hover { border-color: var(--primary); color: var(--primary); }
.period-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.custom-range {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.custom-range.hidden { display: none; }
.custom-range input[type="date"] {
  padding: 5px 10px;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: var(--fs-label);
  font-family: var(--font-ui);
  color: var(--tc-primary);
  outline: none;
}
.custom-range input:focus { border-color: var(--primary); }

/* ========== SUMMARY GRID ========== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.summary-grid.two-col { grid-template-columns: repeat(2, 1fr); }

.summary-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform .2s;
}
.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.summary-icon {
  font-size: 32px;
  width: 56px; height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.income-card .summary-icon { background: var(--success-light); }
.expense-card .summary-icon { background: var(--danger-light); }
.net-card .summary-icon { background: var(--purple-light); }

.summary-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.summary-amount { font-size: 22px; font-weight: 800; margin-top: 2px; }
.income-card .summary-amount { color: var(--success); }
.expense-card .summary-amount { color: var(--danger); }
.net-card .summary-amount { color: var(--primary); }

/* ========== FORM ========== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-family: var(--font-ui); font-size: var(--fs-label); font-weight: var(--fw-semibold); color: var(--tc-secondary); }

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--fs-body-lg);
  font-weight: var(--fw-regular);
  color: var(--tc-primary);
  background: var(--white);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(43,125,197,.12); }

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--tc-disabled); font-weight: var(--fw-regular); }

/* Type toggle */
.type-toggle { display: flex; gap: 8px; flex-wrap: wrap; }
.type-toggle input[type="radio"] { display: none; }
.type-label {
  flex: 1; text-align: center;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-body);
  transition: all .2s;
}
.type-label.income { color: var(--success); }
.type-label.expense { color: var(--danger); }
input[type="radio"]:checked + .type-label.income { background: var(--success-light); border-color: var(--success); }
input[type="radio"]:checked + .type-label.expense { background: var(--danger-light); border-color: var(--danger); }

/* File upload */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all .2s;
  background: var(--bg);
}
.file-upload-area:hover, .file-upload-area.drag-over {
  border-color: var(--primary);
  background: #f0f1ff;
}
.file-input {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}
.file-upload-content { display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.upload-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  opacity: 0.7;
}
.upload-icon svg { width: 40px; height: 40px; }
.upload-text { font-weight: 600; color: var(--text-muted); font-size: 14px; }
.upload-hint { font-size: 12px; color: var(--text-muted); }

.file-preview {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: left;
  pointer-events: none;
}
.file-preview img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; }
.file-preview .btn-icon { pointer-events: all; }

/* ========== ADMIN DASHBOARD ========== */
.admin-stat-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.admin-stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.admin-stat-num {
  font-size: 22px;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.1;
}
.admin-stat-label {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}
.admin-entity-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s, transform .15s;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.admin-entity-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(99,102,241,.13);
  transform: translateY(-2px);
}
.admin-entity-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.admin-entity-card-name {
  font-weight: 700;
  font-size: 15px;
  color: #1e293b;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-entity-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.admin-entity-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.admin-entity-stat-label {
  font-size: 11px;
  color: #94a3b8;
}
.admin-entity-stat-val {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}
.admin-entity-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  flex-wrap: wrap;
  gap: 6px;
}

/* ========== BUTTONS ========== */
.btn {
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--fs-body-lg);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(79,70,229,.3); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--bg); color: var(--text-muted); border: 2px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: var(--fs-label); }
.btn.full-width { width: 100%; justify-content: center; margin-top: 12px; }

.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s; color: #64748B;
  line-height: 1;
}
.btn-icon:hover { background: #F1F5F9; color: #334155; }
.btn-icon.view { color: #64748B; }
.btn-icon.view:hover { background: #EFF6FF; color: #2563EB; }
.btn-icon.edit { color: #64748B; }
.btn-icon.edit:hover { background: #FFFBEB; color: #D97706; }
.btn-icon.users { color: #64748B; }
.btn-icon.users:hover { background: #F0FDF4; color: #16A34A; }
.btn-icon.delete { color: #64748B; }
.btn-icon.delete:hover { background: #FEF2F2; color: #DC2626; }
.btn-icon.edit { color: #2563eb; }
.btn-icon.edit:hover { background: #eff6ff; color: #1d4ed8; }
.btn-icon svg { width: 16px; height: 16px; stroke-width: 1.6; display: block; }

/* ── Entity Type Custom Picker ─────────────── */
.etype-picker { position: relative; }
.etype-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%;
  height: 39px; padding: 0 12px; border: 1.5px solid #e2e8f0; border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 14px; text-align: left;
  color: #1e293b; transition: border-color .15s; font-family: inherit; box-sizing: border-box;
}
.etype-trigger:hover { border-color: #94a3b8; }
.etype-picker.open .etype-trigger { border-color: #7EB3D4; box-shadow: 0 0 0 3px rgba(126,179,212,.15); }
.etype-trigger-inner { flex: 1; display: flex; align-items: center; gap: 8px; }
.etype-chevron { flex-shrink: 0; color: #94a3b8; transition: transform .2s; }
.etype-picker.open .etype-chevron { transform: rotate(180deg); }
.etype-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  min-width: 260px;
  background: #fff; border: 1.5px solid #e2e8f0; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.09); z-index: 300; overflow: hidden;
}
.etype-opt {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  cursor: pointer; font-size: 13px; color: #334155; transition: background .12s;
  white-space: nowrap;
}
.etype-opt:hover { background: #f8fafc; }
.etype-opt.selected { background: #f0f9ff; }
.etype-icon {
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; flex-shrink: 0;
}
.etype-icon svg { stroke-width: 1.6; display: block; }

/* password toggle wrapper */
.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap input { flex: 1; padding-right: 38px !important; }
.pw-toggle {
  position: absolute; right: 6px;
  background: none; border: none; cursor: pointer; padding: 4px;
  color: #9CA3AF; display: flex; align-items: center;
  border-radius: 4px; transition: color .15s;
}
.pw-toggle:hover { color: #4A90E2; }
.pw-toggle svg { width: 16px; height: 16px; stroke-width: 1.8; display: block; }

/* ========== TRANSACTION LIST ========== */
/* ── Transaction Table Header ── */
.tx-table-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 2px;
}
.tx-th-icon  { width: 40px; flex-shrink: 0; }
.tx-th-info  { flex: 0 0 200px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.tx-th-col   { flex-shrink: 0; width: 110px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.tx-th-col-wide { flex: 1; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.tx-th-date  { flex: 0 0 100px; }
.tx-th-amount { width: 120px; flex-shrink: 0; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; text-align: right; }
.tx-th-actions { width: 36px; flex-shrink: 0; }

.transaction-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
  min-width: 0;
}
.transaction-item:last-child { border-bottom: none; }

.tx-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tx-icon.income { background: var(--success-light); }
.tx-icon.expense { background: var(--danger-light); }

.tx-info { flex: 0 0 200px; min-width: 0; }
.tx-category { font-weight: 700; font-size: 14px; }
.tx-desc { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Transaction Columns ── */
.tx-col {
  flex-shrink: 0;
  width: 110px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tx-col-pm { }
.tx-col-wide {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tx-col-date { flex: 0 0 100px; }
.tx-col-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.tx-col-val {
  font-size: 12px;
  font-weight: 500;
  color: var(--tc-primary);
  line-height: 1.4;
}
.tx-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 4px;
}
.tx-meta span {
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
}

.tx-col-acc {
  font-size: 12px;
  color: #475569;
  font-family: var(--font-ui);
  line-height: 1.5;
}

.tx-amount { 
  width: 120px;
  font-weight: 800; 
  font-size: 15px; 
  white-space: nowrap;
  text-align: right;
  flex-shrink: 0;
}
.tx-amount.income { color: var(--success); }
.tx-amount.expense { color: var(--danger); }
.tx-actions { display: flex; gap: 4px; flex-shrink: 0; }

.slip-badge {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--warning-light); color: #92400e;
  border: none; border-radius: 12px; padding: 2px 8px;
  font-size: 11px; font-weight: 700; cursor: pointer;
  transition: background .2s;
}
.slip-badge:hover { background: var(--warning); color: #fff; }

/* Filter bar */
.filter-bar { display: flex; gap: 8px; }
.filter-bar select,
.filter-bar input[type="month"] {
  padding: 7px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  font-weight: var(--fw-regular);
  color: var(--tc-primary);
  background: var(--white);
  outline: none;
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--primary); }

/* ========== CATEGORY LIST (DASHBOARD) ========== */
.cat-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cat-item:last-child { border-bottom: none; }
.cat-bar-wrap { flex: 1; }
.cat-label { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.cat-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.cat-fill-income { height: 100%; background: var(--success); border-radius: 3px; transition: width .4s; }
.cat-fill-expense { height: 100%; background: var(--danger); border-radius: 3px; transition: width .4s; }
.cat-amount { font-size: 13px; font-weight: 700; white-space: nowrap; }

/* ========== TAX CALCULATOR ========== */
.tax-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

.income-input-row { display: flex; gap: 8px; }
.income-input-row input { flex: 1; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.deductions-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 18px 0;
}
.deductions-title {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .6px;
  margin-bottom: 12px;
}
.deduction-row {
  display: flex; align-items: center;
  gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.deduction-row:last-child { border-bottom: none; }
.ded-group-title {
  font-size: 11px; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: .5px;
  padding: 10px 0 4px; margin-top: 6px;
  border-top: 1px dashed var(--border);
}
.ded-note { font-size: 10px; color: var(--text-muted); font-weight: 400; }
.ded-sub { background: #f8faff; padding-left: 12px; border-left: 3px solid var(--primary-light); }
.tax-custom-months { display: flex; align-items: center; gap: 6px; }
.tax-custom-months.hidden { display: none; }
.exp-readonly-box {
  flex: 1; padding: 8px 14px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: #f8fafc;
  font-family: var(--font-ui);
  font-size: var(--fs-body-lg);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--success); min-height: 42px; display: flex; align-items: center;
}
.deduction-row:has(> label.ded-check > input[type="checkbox"]:not(:checked)) > .ded-fixed {
  visibility: hidden;
}
.ded-name { flex: 1; font-size: 13px; }
.ded-check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.ded-fixed { font-size: 13px; font-weight: 700; color: var(--success); white-space: nowrap; }
.ded-input-row { display: flex; align-items: center; gap: 6px; }
.ded-input {
  width: 110px; padding: 5px 10px;
  border: 2px solid var(--border); border-radius: 6px;
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  font-weight: var(--fw-regular);
  color: var(--tc-primary);
  text-align: right; outline: none;
}
.ded-input.small { width: 60px; text-align: center; }
.ded-input:focus { border-color: var(--primary); }
.ded-unit { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* Tax result */
.tax-highlight {
  background: linear-gradient(135deg, #EBF4FB, #D0EAFA);
  border-radius: var(--radius-sm);
  padding: 22px;
  text-align: center;
  margin: 12px 0;
}
.tax-hl-label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.tax-hl-amount { font-size: 38px; font-weight: 900; color: var(--primary); line-height: 1.1; }
.tax-hl-rate { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

.tax-per-period {
  background: var(--success-bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  text-align: center;
  margin-bottom: 14px;
}
.tax-pp-label { font-size: 12px; color: var(--text-muted); }
.tax-pp-amount { font-size: 22px; font-weight: 800; color: var(--success); }

.tax-table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px; }
.tax-table td { padding: 9px 0; border-bottom: 1px solid var(--border); }
.tax-table td:last-child { text-align: right; font-weight: 700; }
.tax-table tr.total-row td { border-top: 2px solid var(--border); font-weight: 800; border-bottom: none; }

.bracket-section-title { font-size: 13px; font-weight: 700; margin: 16px 0 8px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.bracket-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bracket-range { font-size: 11px; color: var(--text-muted); width: 170px; flex-shrink: 0; }
.bracket-track { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.bracket-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #1B9DD9); border-radius: 4px; transition: width .5s ease; }
.bracket-tax-amt { font-size: 12px; font-weight: 700; color: var(--primary); width: 85px; text-align: right; flex-shrink: 0; }

/* ========== MODAL ========== */
.modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.modal-content {
  position: relative; background: #fff;
  border-radius: var(--radius); padding: 20px;
  max-width: 90vw; max-height: 90vh;
  z-index: 1; overflow: auto;
}
.modal-close {
  position: absolute; top: 10px; right: 10px;
  background: var(--danger); color: #fff;
  border: none; border-radius: 50%;
  width: 28px; height: 28px;
  cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.slip-full-img { max-width: 80vw; max-height: 80vh; object-fit: contain; border-radius: 8px; display: block; }
.slip-pdf-link { display: block; padding: 20px; text-align: center; font-size: 40px; }
.slip-pdf-link span { display: block; font-size: 14px; color: var(--primary); margin-top: 8px; font-weight: 600; }
#smImageDropzone.dragover { border-color: var(--primary); background: #eff6ff; }
#smImageDropzone:hover { border-color: #94a3b8; background: #f1f5f9; }

/* ========== TOAST ========== */
#toastContainer { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: #fff;
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: slideIn .3s ease;
  display: flex; align-items: center; gap: 8px;
  min-width: 200px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ========== EMPTY STATE ========== */
.empty-state { text-align: center; padding: 36px 20px; color: var(--text-muted); }
.empty-state p { font-size: 14px; line-height: 1.8; }

/* ========== DASHBOARD MODULE CARDS ========== */
.dash-mod-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .2s, transform .15s;
}
.dash-mod-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.dash-mod-accent { height: 3px; }
.dash-mod-body { padding: 14px 16px; }
.dash-mod-hd { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.dash-mod-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.dash-mod-name { font-size: 12.5px; font-weight: 700; color: var(--tc-heading); letter-spacing: .1px; }
.dash-mod-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0;
  border-top: 1px solid var(--border);
}
.dash-mod-lbl { font-size: 11.5px; color: var(--tc-muted); }
.dash-mod-val { font-size: 13px; font-weight: 700; color: var(--tc-heading); }
.dash-mod-val.warn { color: var(--danger); }
.dash-mod-unit { font-size: 10px; font-weight: 400; color: var(--tc-disabled); margin-left: 2px; }

/* ========== DASHBOARD ACTIVITY FEED ========== */
.dash-act-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
}
.dash-act-row:last-child { border-bottom: none; }
.dash-act-type {
  font-size: 10.5px; font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap; flex-shrink: 0;
  min-width: 62px; text-align: center;
}
.dash-act-info { flex: 1; min-width: 0; }
.dash-act-label { font-size: 12.5px; font-weight: 600; color: var(--tc-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-act-sub   { font-size: 11px; color: var(--tc-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-act-meta  { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.dash-act-status { font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.dash-act-date  { font-size: 10.5px; color: var(--tc-disabled); }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .tax-layout { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .summary-grid { grid-template-columns: 1fr; }
  .summary-grid.two-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .tax-layout { grid-template-columns: 1fr; }
  #dashChartsRow { grid-template-columns: 1fr !important; }
}

/* ========== PDF EXPORT OPTIONS ========== */
.pdf-option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}
.pdf-option-btn:hover {
  border-color: #2B7DC5;
  background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(43, 125, 197, 0.1);
}
.pdf-option-btn:hover .pdf-option-icon svg {
  transform: scale(1.05);
  stroke: #1976d2;
}
.pdf-option-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #EBF4FB;
  border-radius: 10px;
}
.pdf-option-icon svg {
  width: 28px;
  height: 28px;
  transition: all 0.2s;
}
.pdf-option-text {
  flex: 1;
}
.pdf-option-title {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}
.pdf-option-desc {
  font-size: 13px;
  color: #64748b;
  line-height: 1.4;
}

/* ═══════════════════════════════════════════
   Payment Method Selector
═══════════════════════════════════════════ */
.form-label-standalone {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  font-weight: var(--fw-semibold);
  color: var(--tc-secondary);
  margin-bottom: 8px;
}
.pm-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pm-option {
  position: relative;
  cursor: pointer;
}
.pm-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.pm-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  background: #fff;
  min-width: 88px;
  user-select: none;
}
.pm-card:hover { border-color: var(--primary); background: #F0F9FF; }
.pm-option input:checked + .pm-card {
  border-color: var(--primary);
  background: #F0F9FF;
  box-shadow: 0 0 0 3px rgba(14,165,233,0.15);
}
.pm-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
}
.pm-option input:checked + .pm-card .pm-icon { color: var(--primary); }
.pm-label {
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  text-align: center;
  white-space: nowrap;
}
.pm-option input:checked + .pm-card .pm-label { color: var(--primary-dark); font-weight: 600; }

/* Payment Detail Boxes */
.pm-detail { margin-top: 12px; }
.pm-detail-box {
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  padding: 16px;
  background: #F8FAFC;
}
.pm-detail-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  color: #334155;
  margin-bottom: 14px;
}
.pm-ocr-note {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary-dark);
  background: #E0F2FE;
  border: 1px solid #BAE6FD;
  padding: 3px 8px;
  border-radius: 20px;
  margin-left: auto;
}

/* Transfer 3-col grid */
.pm-transfer-grid {
  display: grid;
  grid-template-columns: 1fr 32px 1fr;
  gap: 12px;
  align-items: start;
}
.pm-subgrid-col { display: flex; flex-direction: column; gap: 8px; }
.pm-subgrid-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  padding-bottom: 6px;
  border-bottom: 1px solid #E2E8F0;
  margin-bottom: 2px;
}
.pm-subgrid-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 28px;
  color: #94a3b8;
}

/* Simple multi-col grid for card/wallet/check */
.pm-subgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

@media (max-width: 600px) {
  .pm-transfer-grid {
    grid-template-columns: 1fr;
  }
  .pm-subgrid-divider { display: none; }
  .pm-selector { gap: 6px; }
  .pm-card { min-width: 72px; padding: 8px 10px; }
  .pm-label { font-size: 11px; }
}

/* ═══════════════════════════════════════════
   Payment Badge in Transaction List
═══════════════════════════════════════════ */
.pm-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 10px;
  vertical-align: middle;
  white-space: nowrap;
}
.pm-badge svg { width: 11px; height: 11px; flex-shrink: 0; }
.pm-badge--cash     { background: #F0FDF4; color: #15803D; border: 1px solid #BBF7D0; }
.pm-badge--transfer { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.pm-badge--card     { background: #FDF4FF; color: #7E22CE; border: 1px solid #E9D5FF; }
.pm-badge--ewallet  { background: #FFF7ED; color: #C2410C; border: 1px solid #FED7AA; }
.pm-badge--check    { background: #FFFBEB; color: #B45309; border: 1px solid #FDE68A; }

.pm-badge-wrap { display: flex; flex-direction: column; gap: 3px; }
.pm-badge-detail {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.pm-badge-detail span {
  font-size: 11px;
  color: #475569;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 128px;
}

/* Transfer info chips */
.tx-transfer-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.tx-transfer-chip {
  font-size: 11px;
  color: #475569;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  padding: 1px 7px;
  border-radius: 6px;
}

/* Form action buttons with SVG icons */
.form-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
