:root {
  --app-bg: #f4f6f9;
  --app-surface: #ffffff;
  --app-border: #e5e7eb;
  --app-text: #1f2937;
  --app-muted: #6b7280;
  --app-primary: #2563eb;
  --app-hover: #f1f5f9;
}

/* =========================
   DARK THEME
========================= */

html[data-theme="dark"] {
  --app-bg: #111827;
  --app-surface: #1f2937;
  --app-border: #374151;
  --app-text: #f3f4f6;
  --app-muted: #9ca3af;
  --app-primary: #3b82f6;
  --app-hover: #374151;
}

/* =========================
   RESET
========================= */

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--app-bg);
  color: var(--app-text);

  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  overflow-x: hidden;
  overflow-y: auto;

  -webkit-overflow-scrolling: touch;
}

/* =========================
   APPLICATION SHELL
========================= */

.app-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;

  display: flex;
  flex-direction: column;
}

/* =========================
   TOP BAR
========================= */

.app-topbar {
  height: 60px;
  min-height: 60px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 0 18px;

  background: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-brand-icon {
  width: 36px;
  height: 36px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 10px;

  background: var(--app-primary);
  color: #fff;
}

.app-brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.app-brand-subtitle {
  font-size: 11px;
  color: var(--app-muted);
}

.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-icon-btn,
.app-user {
  height: 38px;

  border: 0;
  border-radius: 8px;

  padding: 0 10px;

  background: transparent;
  color: var(--app-text);

  cursor: pointer;
}

.app-icon-btn:hover,
.app-user:hover {
  background: var(--app-hover);
}

.app-user {
  display: flex;
  align-items: center;
  gap: 7px;
}
/* =========================================================
   ADMIN MENU
========================================================= */

.app-admin-menu {
  min-width: 160px;

  padding: 6px;

  border: 1px solid var(--app-border);
  border-radius: 9px;

  background: var(--app-surface);

  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

/* =========================================================
   LOGOUT
========================================================= */

.app-admin-menu .app-logout {
  display: flex;

  align-items: center;
  gap: 10px;

  padding: 9px 11px;

  border-radius: 6px;

  color: #dc3545;

  font-size: 13px;

  text-decoration: none;
}

.app-admin-menu .app-logout i {
  font-size: 15px;
}

.app-admin-menu .app-logout:hover {
  background: rgba(220, 53, 69, 0.08);

  color: #dc3545;
}

/* =========================================================
   DARK MODE - ADMIN MENU
========================================================= */

html[data-theme="dark"] .app-admin-menu {
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.45);
}

/* =========================================================
   HEADER ACTION BUTTONS
========================================================= */

.app-header-action {
  width: 36px;
  height: 36px;

  display: inline-flex;

  align-items: center;
  justify-content: center;

  border: 0;
  border-radius: 8px;

  background: transparent;

  color: var(--app-text);

  transition:
    background 0.15s ease,
    color 0.15s ease;
}

/* =========================================================
   HOVER / FOCUS
========================================================= */

.app-header-action:hover,
.app-header-action:focus {
  background: var(--app-hover);

  color: var(--app-text);

  outline: none;
}

/* =========================================================
   ACTIVE / DROPDOWN OPEN
========================================================= */

.app-header-action.active,
.app-header-action[aria-expanded="true"] {
  background: var(--app-hover);

  color: var(--app-text);
}

/* =========================================================
   HEADER ICON
========================================================= */

.app-header-action i {
  font-size: 17px;
}

/* =========================================================
   REMOVE BOOTSTRAP DROPDOWN ARROW
========================================================= */

.app-header-action.dropdown-toggle::after {
  display: none;
}

/* =========================================================
   DARK MODE - HEADER ACTIONS
========================================================= */

html[data-theme="dark"] .app-header-action {
  color: #ffffff;
}

html[data-theme="dark"] .app-header-action:hover,
html[data-theme="dark"] .app-header-action:focus,
html[data-theme="dark"] .app-header-action.active,
html[data-theme="dark"] .app-header-action[aria-expanded="true"] {
  background: #343a5c;

  color: #ffffff;
}
/* =========================
   WORKSPACE
========================= */

.app-workspace {
  position: relative;

  flex: 1 1 auto;
  min-height: 0;

  display: flex;

  overflow: hidden;
}

/* =========================
   APPLICATION DESKTOP
========================= */

.app-desktop {
  width: 100%;
  min-height: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;

  overflow: hidden;
}

/* =========================
   DESKTOP APPLICATION PANEL
========================= */

.app-desktop-panel {
  min-width: 520px;
  min-height: 260px;

  padding: 35px;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 18px;

  border: 1px solid rgba(229, 231, 235, 0.85);
  border-radius: 24px;

  background: color-mix(in srgb, var(--app-surface) 35%, transparent);
}

/* =========================
   APPLICATION BUTTON
========================= */

.desktop-app {
  width: 100px;
  height: 100px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  gap: 8px;

  border: 0;
  border-radius: 14px;

  background: transparent;
  color: var(--app-text);

  cursor: pointer;

  transition:
    background 0.15s ease,
    transform 0.15s ease;
}

.desktop-app:hover {
  background: var(--app-hover);
}

.desktop-app:active {
  transform: scale(0.95);
}

/* =========================
   APPLICATION ICON
========================= */

.desktop-app-icon {
  width: 54px;
  height: 54px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 15px;

  background: var(--app-surface);
  border: 1px solid var(--app-border);

  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);

  color: var(--app-primary);

  font-size: 24px;
}

/* =========================
   APPLICATION NAME
========================= */

.desktop-app-name {
  font-size: 12px;
  font-weight: 500;

  white-space: nowrap;
}

/* =========================
   TASKBAR
========================= */

.app-taskbar {
  height: 38px;
  min-height: 38px;

  display: flex;
  align-items: center;

  gap: 4px;

  padding: 0 8px;

  background: var(--app-surface);
  border-top: 1px solid var(--app-border);

  overflow-x: auto;
  overflow-y: hidden;

  scrollbar-width: none;
}

.app-taskbar::-webkit-scrollbar {
  display: none;
}

/* =========================
   MOBILE
========================= */

@media (max-width: 768px) {
  .app-topbar {
    height: 56px;
    min-height: 56px;

    padding: 0 12px;
  }

  .app-brand-subtitle,
  .app-user span {
    font-size: 9px;
  }

  /* Desktop */

  .app-desktop {
    padding: 15px;
  }

  /* Application panel */

  .app-desktop-panel {
    width: 100%;
    max-width: 360px;

    min-width: 0;
    min-height: 0;

    padding: 15px;

    display: grid;

    grid-template-columns: repeat(3, 1fr);

    gap: 8px;

    border-radius: 20px;
  }

  /* Application buttons */

  .desktop-app {
    width: 90px;
    height: 90px;

    justify-self: center;
  }

  /* Application icons */

  .desktop-app-icon {
    width: 52px;
    height: 52px;

    font-size: 22px;
  }

  /* Application names */

  .desktop-app-name {
    font-size: 11px;

    white-space: normal;
    text-align: center;
  }

  /* Taskbar */

  .app-taskbar {
    height: 42px;
    min-height: 42px;

    padding: 0 8px;
  }
}

/* =========================
   SMALL MOBILE
========================= */

@media (max-width: 400px) {
  .app-topbar {
    padding: 0 8px;
  }

  .app-brand-icon {
    width: 32px;
    height: 32px;
  }

  .app-brand-name {
    font-size: 13px;
  }

  .app-icon-btn,
  .app-user {
    padding: 0 7px;
  }

  /* Desktop panel */

  .app-desktop {
    padding: 10px;
  }

  .app-desktop-panel {
    max-width: 300px;

    padding: 10px;

    gap: 4px;

    border-radius: 18px;
  }

  /* Application buttons */

  .desktop-app {
    width: 82px;
    height: 84px;
  }

  /* Application icons */

  .desktop-app-icon {
    width: 48px;
    height: 48px;

    font-size: 20px;

    border-radius: 13px;
  }

  /* Application names */

  .desktop-app-name {
    font-size: 10px;
  }
}
/* =========================
   TASKBAR APPLICATION
========================= */

.app-task {
  height: 30px;

  display: flex;
  align-items: center;

  gap: 6px;

  padding: 0 12px;

  border: 0;
  border-radius: 6px;

  background: transparent;
  color: var(--app-text);

  font-size: 11px;

  white-space: nowrap;

  cursor: pointer;

  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.app-task:hover {
  background: var(--app-hover);
}

.app-task.active {
  background: var(--app-primary);
  color: #ffffff;
}

.app-task i {
  font-size: 12px;
}

/* =========================================================
   LOGIN MODAL POSITION
========================================================= */

#loginModal .modal-dialog {
  min-height: 100vh;

  margin: 0 auto;

  display: flex;
  align-items: center;
  justify-content: center;
}

#loginModal .modal-content {
  margin: 0;
}
/* =========================================================
   LOGIN IFRAME
========================================================= */

.usbf-login-modal {
  width: 500px;
  max-width: 100%;

  padding: 0;

  border: 1px solid var(--app-border);
  border-radius: 18px;

  background: var(--app-surface);

  overflow: hidden;

  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.2);
}

.usbf-login-frame {
  display: block;

  width: 100%;
  height: 460px;

  border: 0;

  background: transparent;
}

@media (max-width: 540px) {
  .usbf-login-modal {
    width: calc(100vw - 30px);
  }

  .usbf-login-frame {
    height: 500px;
  }
}

/* =========================================================
   USBF MODULE - DARK MODE
========================================================= */

html[data-theme="dark"] .us-module-page .card {
  background: var(--app-surface);
  color: var(--app-text);

  border-color: var(--app-border);
}

html[data-theme="dark"] .us-module-page .card-body {
  background: var(--app-surface);
  color: var(--app-text);
}

/* =========================================================
   TABLE
========================================================= */

html[data-theme="dark"] .us-module-page .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--app-text);
  --bs-table-border-color: var(--app-border);

  color: var(--app-text);
}

html[data-theme="dark"] .us-module-page .table > :not(caption) > * > * {
  background-color: transparent;
  color: var(--app-text);
  border-color: var(--app-border);
}

/* =========================================================
   TABLE HEADER
========================================================= */

html[data-theme="dark"] .us-module-page .table thead th {
  color: var(--app-text);
  background: transparent;
}

/* =========================================================
   TABLE HOVER
========================================================= */

html[data-theme="dark"] .us-module-page .table-hover > tbody > tr:hover > * {
  background-color: var(--app-hover);
  color: var(--app-text);
}

/* =========================================================
   MUTED TEXT
========================================================= */

html[data-theme="dark"] .us-module-page .text-muted {
  color: var(--app-muted) !important;
}
/* =========================================================
   USBF FORM CONTROLS - DARK MODE
========================================================= */

html[data-theme="dark"] .us-module-page .form-control,
html[data-theme="dark"] .us-module-page .form-select {
  background-color: #182131;
  border-color: #3a4558;
  color: #f1f5f9;
}

/* =========================================================
   PLACEHOLDER
========================================================= */

html[data-theme="dark"] .us-module-page .form-control::placeholder {
  color: #8b95a7;
}

/* =========================================================
   FOCUS
========================================================= */

html[data-theme="dark"] .us-module-page .form-control:focus,
html[data-theme="dark"] .us-module-page .form-select:focus {
  background-color: #182131;
  border-color: #56627a;
  color: #ffffff;

  box-shadow: 0 0 0 2px rgba(86, 98, 122, 0.25);
}

/* =========================================================
   LABEL
========================================================= */

html[data-theme="dark"] .us-module-page .form-label {
  color: #e5e7eb;
}

/* =========================================================
   DISABLED
========================================================= */

html[data-theme="dark"] .us-module-page .form-control:disabled,
html[data-theme="dark"] .us-module-page .form-select:disabled {
  background-color: #111827;
  color: #6b7280;
}
/* =========================================================
   INPUT GROUP
========================================================= */

html[data-theme="dark"] .us-module-page .input-group-text {
  background-color: #182131;
  border-color: #3a4558;
  color: #cbd5e1;
}

/* =========================================================
   CHECKBOX / RADIO
========================================================= */

html[data-theme="dark"] .us-module-page .form-check-label {
  color: #e5e7eb;
}
/* =========================================================
   DARK MODE - MUTED TEXT
========================================================= */

html[data-theme="dark"] .us-module-page .text-muted {
  color: #477e49 !important;
}
