:root {
  --bg: #f2f5fb;
  --surface: #ffffff;
  --surface-soft: #f7f9fd;
  --text: #15243b;
  --muted: #667a96;
  --primary: #0e6af7;
  --primary-strong: #0a55c8;
  --primary-soft: #eaf2ff;
  --danger: #d64545;
  --success: #1e9a64;
  --border: #d6e0ef;
  --shadow: 0 14px 34px rgba(19, 38, 70, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Segoe UI", "Inter", "Arial", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 0% 0%, #e6eeff, transparent 24%),
              radial-gradient(circle at 100% 100%, #dff4ed, transparent 20%),
              var(--bg);
}

.container {
  width: min(1120px, 94vw);
  margin: 0 auto;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  position: relative;
}

.mobile-overlay {
  display: none;
}

.sidebar {
  background: linear-gradient(180deg, #0d1f3b 0%, #10284a 45%, #0f2441 100%);
  color: #dce7f8;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1.1rem 0.9rem;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 120;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #f4f8ff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.96);
  padding: 0.12rem;
  box-shadow: 0 5px 12px rgba(6, 13, 25, 0.35);
}

.sidebar-role {
  display: flex;
  align-items: center;
}

.sidebar-close {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
}

.sidebar .role-chip {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #e8f1ff;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  flex: 1;
  overflow-y: auto;
}

.sidebar-highlight-menu {
  display: grid;
  gap: 0.3rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid rgba(216, 230, 252, 0.2);
}

.sidebar-group {
  display: grid;
  gap: 0.35rem;
}

.sidebar-group-toggle {
  border: none;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  width: 100%;
  text-align: left;
  padding: 0.06rem 0.2rem;
  cursor: pointer;
}

.sidebar-group-title {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  color: rgba(220, 233, 252, 0.75);
}

.sidebar-group-caret {
  color: rgba(220, 233, 252, 0.9);
  font-size: 0.72rem;
  transition: transform 0.15s ease;
}

.sidebar-group.collapsed .sidebar-group-caret {
  transform: rotate(-90deg);
}

.sidebar-list {
  list-style: disc;
  margin: 0;
  padding: 0 0 0 1.15rem;
  display: grid;
  gap: 0.18rem;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-4px);
  transition: max-height 0.24s ease, opacity 0.2s ease, transform 0.2s ease;
}

.sidebar-list li {
  color: rgba(211, 227, 251, 0.9);
}

.sidebar-group:not(.collapsed) .sidebar-list {
  opacity: 1;
  transform: translateY(0);
}

.nav-link {
  display: block;
  color: #d3e3fb;
  text-decoration: none;
  padding: 0.18rem 0.2rem;
  border-radius: 6px;
  font-size: 0.88rem;
}

.nav-link:hover {
  color: #ffffff;
  text-decoration: underline;
}

.nav-link.active {
  background: rgba(58, 133, 255, 0.18);
  color: #fff;
  font-weight: 700;
}

.nav-link-highlight {
  border: 1px solid rgba(137, 183, 255, 0.35);
  background: rgba(36, 96, 178, 0.35);
  font-weight: 700;
  padding: 0.42rem 0.56rem;
}

.nav-link-highlight:hover {
  background: rgba(62, 130, 225, 0.4);
  text-decoration: none;
}

.workspace {
  padding: 0.75rem 0.95rem 0.85rem;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.workspace-header {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 0.5rem 0.6rem;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 90;
}

.workspace-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.workspace-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  color: #607697;
}

.workspace-userbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.workspace-user-name {
  font-size: 0.82rem;
  color: #3b5579;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #eff5ff;
  border: 1px solid #d5e3fb;
}

.workspace-logout-form {
  margin: 0;
  display: inline-flex;
  gap: 0;
  width: auto;
}

.workspace-content {
  min-width: 0;
}

.workspace-footer {
  margin-top: 0.35rem;
  border-top: 1px solid #dbe4f1;
  padding-top: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  flex-wrap: wrap;
  color: #6a7f9d;
  font-size: 0.75rem;
}

.mobile-menu-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: #223a5f;
  border-radius: 9px;
  padding: 0.32rem 0.56rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: none;
}

.page-head {
  margin-bottom: 0.95rem;
}

h1,
h2,
h3 {
  margin: 0 0 0.6rem;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.3rem, 1.65vw, 1.75rem);
}

h2 {
  font-size: 1.08rem;
}

h3 {
  font-size: 0.98rem;
}

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 0.95rem;
}

.grid.cols-2 {
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
}

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 1rem;
  box-shadow: var(--shadow);
  min-width: 0;
}

.kpi-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stats-kpi-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.stats-overview-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.9rem;
  border-color: #cfe0ff;
  background: linear-gradient(145deg, #f9fbff, #f1f7ff);
}

.stats-overview-main h2 {
  margin: 0 0 0.35rem;
}

.stats-overview-main p {
  margin: 0;
}

.stats-overview-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.stats-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cfdff9;
  border-radius: 999px;
  background: #ffffff;
  color: #30527f;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.2rem 0.56rem;
}

.stats-insight-grid {
  display: grid;
  gap: 0.72rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.stats-insight-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(145deg, #ffffff, #f5f9ff);
  box-shadow: var(--shadow);
  padding: 0.8rem;
}

.stats-insight-card > span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.stats-insight-card strong {
  display: block;
  margin-top: 0.26rem;
  font-size: 1.22rem;
  color: #1f3456;
}

.stats-insight-card strong.positive,
.balance-positive {
  color: #0f8454;
}

.stats-insight-card strong.negative,
.balance-negative {
  color: #be3f3f;
}

.stats-insight-card small {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.stats-kpi-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(145deg, #ffffff, #f5f9ff);
  box-shadow: var(--shadow);
  padding: 0.78rem;
}

.stats-kpi-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.stats-kpi-card strong {
  display: block;
  margin-top: 0.28rem;
  font-size: 1.2rem;
}

.stats-kpi-card.highlight {
  border-color: #bcd4ff;
  background: linear-gradient(145deg, #f3f8ff, #e9f2ff);
}

.stats-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.6rem 0.9rem;
}

.stats-toolbar p {
  margin: 0.2rem 0 0;
  font-size: 0.81rem;
}

.stats-toolbar-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.81rem;
}

.stats-toolbar-filter span {
  font-weight: 700;
}

.stats-toolbar-filter select {
  min-width: 150px;
  width: auto;
  border-radius: 9px;
  padding: 0.34rem 0.55rem;
  font-size: 0.81rem;
}

.quick-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
}

.quick-card {
  text-decoration: none;
  color: #153055;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(145deg, #ffffff, #f4f8ff);
  padding: 0.78rem;
  box-shadow: var(--shadow);
}

.quick-card strong {
  display: block;
  font-size: 0.95rem;
}

.quick-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.quick-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: #e8f0ff;
  color: #285db2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.quick-icon svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.quick-card span {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.quick-card:hover {
  border-color: #b8cdf5;
  transform: translateY(-1px);
}

.kpi-card {
  border-radius: 14px;
  padding: 0.9rem;
  color: #fff;
  box-shadow: var(--shadow);
}

.kpi-card span {
  display: block;
  font-size: 0.82rem;
  opacity: 0.95;
}

.kpi-head {
  display: flex;
  align-items: center;
  gap: 0.42rem;
}

.kpi-head span {
  display: inline;
}

.kpi-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.kpi-icon svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kpi-card strong {
  display: block;
  margin-top: 0.3rem;
  font-size: 1.45rem;
}

.kpi-card.income {
  background: linear-gradient(135deg, #23a36b, #138855);
}

.kpi-card.expense {
  background: linear-gradient(135deg, #ef6666, #d64545);
}

.kpi-card.neutral {
  background: linear-gradient(135deg, #2d7cff, #1f67e1);
}

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

.chart-card canvas {
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #fbfdff;
  border: 1px solid #e3ecfa;
}

.stats-page .chart-card h2 {
  margin-bottom: 0.5rem;
}

.stats-page .chart-meta {
  margin: -0.1rem 0 0.58rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
}

.chart-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.chart-legend .dot.income {
  background: #1a9b5f;
}

.chart-legend .dot.expense {
  background: #e05353;
}

.dashboard-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.dashboard-chart-head h2 {
  margin: 0;
}

.dashboard-chart-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.dashboard-chart-filter span {
  font-weight: 600;
}

.dashboard-chart-filter select {
  min-width: 130px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fff;
  color: #173055;
  padding: 0.32rem 0.5rem;
  font-size: 0.82rem;
}

.admin-banner-card {
  border-color: #cfe0ff;
  background: linear-gradient(145deg, #f9fbff, #f1f7ff);
}

.admin-banner-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.admin-banner-row h2 {
  margin: 0 0 0.25rem;
}

.admin-banner-row p {
  margin: 0;
}

.admin-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #b3ccf5;
  background: #ffffff;
  color: #224a8e;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.admin-kpi-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.admin-kpi-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(145deg, #ffffff, #f5f9ff);
  box-shadow: var(--shadow);
  padding: 0.78rem;
}

.admin-kpi-card span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.admin-kpi-card strong {
  display: block;
  margin-top: 0.26rem;
  font-size: 1.24rem;
  color: #1f3c67;
}

.admin-kpi-card small {
  display: block;
  margin-top: 0.16rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.stats-list {
  display: grid;
  gap: 0.5rem;
}

.stats-list > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}

form {
  display: grid;
  gap: 0.7rem;
}

label {
  display: inline-block;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.84rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 0.58rem 0.66rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #78a8ff;
  box-shadow: 0 0 0 3px rgba(85, 149, 255, 0.2);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.inline-check input {
  width: auto;
  margin: 0;
}

.row {
  display: flex;
  gap: 0.55rem;
  align-items: end;
}

.row > * {
  flex: 1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.btn {
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  padding: 0.55rem 0.86rem;
}

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

.btn[disabled] {
  background: #bac8de;
  color: #f4f7fc;
  cursor: not-allowed;
}

.btn.ghost {
  background: #eff4fb;
  color: #2c4266;
}

.btn.ghost:hover {
  background: #e1eaf7;
}

.btn.danger {
  background: var(--danger);
}

.btn.danger:hover {
  background: #bf2f2f;
}

.btn.mini {
  font-size: 0.77rem;
  padding: 0.34rem 0.58rem;
  border-radius: 8px;
}

.btn.block {
  width: 100%;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.total-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  margin: 0.1rem 0 0.75rem;
  background: var(--primary-soft);
  color: #204d98;
  border: 1px solid #cfe0ff;
  border-radius: 999px;
  padding: 0.25rem 0.68rem;
}

.method-list {
  margin: 0.15rem 0 0.72rem;
  font-size: 0.84rem;
  color: #27415f;
}

.method-list strong {
  display: block;
  margin-bottom: 0.25rem;
}

.method-list ul {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.15rem;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.type-bars {
  display: grid;
  gap: 0.7rem;
}

.pie-chart-wrap {
  margin: 0.2rem 0 0.5rem;
}

.pie-chart-wrap canvas {
  display: block;
  width: min(100%, 420px);
  margin: 0 auto;
  border-radius: 10px;
  background: #fbfdff;
  border: 1px solid #e3ecfa;
}

.pie-legend-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: grid;
  gap: 0.32rem;
}

.pie-legend-list li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  color: #2f4667;
}

.pie-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.pie-label {
  flex: 1;
}

.pie-legend-list strong {
  font-size: 0.78rem;
}

.type-bar-item {
  display: grid;
  gap: 0.35rem;
}

.type-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.84rem;
}

.type-bar-head strong {
  font-size: 0.8rem;
  margin-left: auto;
}

.type-bar-track {
  width: 100%;
  height: 9px;
  background: #edf2fa;
  border-radius: 999px;
  overflow: hidden;
}

.type-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2d7cff, #4fa1ff);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 0.54rem 0.45rem;
  font-size: 0.86rem;
}

th {
  text-transform: uppercase;
  letter-spacing: 0.15px;
  color: var(--muted);
  font-size: 0.76rem;
}

.table-pagination {
  margin-top: 0.62rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.table-pagination-info {
  font-size: 0.78rem;
  color: var(--muted);
}

.table-pagination-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.table-pagination-btn {
  border: 1px solid #c8d7ef;
  background: #f2f7ff;
  color: #284e80;
  border-radius: 8px;
  min-height: 30px;
  padding: 0.24rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.table-pagination-btn:hover {
  background: #e6efff;
}

.table-pagination-btn[disabled] {
  opacity: 0.52;
  cursor: not-allowed;
}

.alert {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.64rem 0.75rem;
  margin: 0 0 0.9rem;
}

.confirm-modal-open {
  overflow: hidden;
}

#confirmDeleteModal.confirm-modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(9, 23, 43, 0.55);
}

#confirmDeleteModal.confirm-modal-backdrop[hidden] {
  display: none !important;
}

#confirmDeleteModal .confirm-modal {
  width: min(460px, 96vw);
  border: 1px solid #d5e0f0;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 24px 44px rgba(12, 27, 52, 0.28);
  padding: 1rem;
}

#confirmDeleteModal .confirm-modal h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

#confirmDeleteModal .confirm-modal p {
  margin: 0;
  color: #3b5578;
  font-size: 0.88rem;
  line-height: 1.42;
}

#confirmDeleteModal .confirm-modal-actions {
  margin-top: 0.92rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.42rem;
}

.alert.error {
  background: #ffecec;
  color: #942c2c;
  border-color: #f0c2c2;
}

.alert.success {
  background: #e9faef;
  color: #146944;
  border-color: #c1ecd4;
}

.back-to-top {
  position: fixed;
  right: 16px;
  bottom: 18px;
  width: 42px;
  height: 42px;
  border: 1px solid #bcd0ef;
  border-radius: 999px;
  background: #ffffff;
  color: #214877;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(12, 30, 58, 0.22);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s ease;
  z-index: 170;
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  background: #eef4ff;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.58rem;
}

.role-chip.status-active {
  background: #e7f8ee;
  color: #14724a;
  border: 1px solid #bde7cf;
}

.role-chip.status-inactive {
  background: #ffecec;
  color: #922f2f;
  border: 1px solid #f3c6c6;
}

.inline-form {
  display: inline;
  width: auto;
  margin: 0;
  padding: 0;
}

.guest-main {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(1rem + env(safe-area-inset-top)) calc(0.8rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) calc(0.8rem + env(safe-area-inset-left));
}

.guest-alert-stack {
  width: min(980px, 96vw);
  display: grid;
  gap: 0.5rem;
  margin: 0 0 0.72rem;
}

.guest-alert-stack .alert {
  margin: 0;
}

.login-wrapper {
  width: min(980px, 96vw);
}

.login-box {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 1.1rem;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(320px, 430px);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid #c9d9f2;
  background: #fff;
  box-shadow: 0 22px 52px rgba(20, 42, 77, 0.18);
}

.login-side {
  background: linear-gradient(155deg, #123766 0%, #0f2f57 58%, #0f2948 100%);
  color: #e7f0ff;
  padding: clamp(1.15rem, 2vw, 1.8rem);
  display: grid;
  align-content: center;
  gap: 0.72rem;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.48rem;
}

.login-logo {
  width: clamp(190px, 28vw, 280px);
  height: auto;
  border-radius: 10px;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 18px rgba(5, 12, 23, 0.28);
  background: rgba(255, 255, 255, 0.97);
  padding: 0.34rem 0.42rem;
}

.login-side h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.1vw, 1.75rem);
  color: #fff;
}

.login-side p {
  margin: 0;
  color: #d7e6ff;
  line-height: 1.5;
}

.login-slogan {
  margin: 0.2rem 0 0.1rem;
  padding: 0.5rem 0.65rem;
  border-left: 3px solid rgba(171, 209, 255, 0.9);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 0 10px 10px 0;
  color: #eff5ff;
  font-size: 0.9rem;
  font-style: italic;
  line-height: 1.4;
}

.login-side ul {
  margin: 0.15rem 0 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.34rem;
  color: #d8e8ff;
  font-size: 0.9rem;
}

.login-pro {
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: clamp(1rem, 2.2vw, 1.6rem);
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.login-form {
  gap: 0.72rem;
}

.login-form input {
  font-size: 16px;
  min-height: 44px;
}

.login-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.login-title h2 {
  margin: 0;
}

.login-title-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #e8f0ff;
  color: #1f5fbf;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.login-title-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-input-wrap {
  position: relative;
}

.password-input-wrap input {
  padding-right: 5.25rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.38rem;
  transform: translateY(-50%);
  border: 1px solid #c9daf8;
  border-radius: 8px;
  background: #edf4ff;
  color: #24559f;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.32rem 0.62rem;
  min-height: 34px;
  cursor: pointer;
  touch-action: manipulation;
}

.password-toggle:hover {
  background: #dceafe;
}

.remember-row {
  margin-top: -0.08rem;
}

.login-note {
  margin-top: -0.45rem;
  display: block;
  font-size: 0.76rem;
}

.login-submit {
  margin-top: 0.2rem;
  min-height: 44px;
}

.mt {
  margin-top: 1rem;
}

.guest-main-marketing {
  display: block;
  padding: 0;
}

.marketing-page {
  width: min(1200px, 96vw);
  margin: 0 auto;
  padding: 0.9rem 0 1.3rem;
}

.marketing-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}

.marketing-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.52rem;
  text-decoration: none;
  color: #0f2f57;
  font-size: 1.1rem;
  font-weight: 800;
}

.marketing-brand img {
  width: 46px;
  height: 46px;
  border-radius: 9px;
  border: 1px solid #cad8ed;
  object-fit: contain;
  background: #fff;
  padding: 0.12rem;
}

.marketing-hero {
  display: grid;
  gap: 0.95rem;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  margin-bottom: 1rem;
}

.marketing-copy {
  border: 1px solid #cfdef2;
  border-radius: 18px;
  padding: 1rem;
  background: linear-gradient(165deg, #ffffff, #f4f8ff);
  box-shadow: 0 20px 42px rgba(22, 42, 78, 0.12);
}

.hero-kicker {
  margin: 0 0 0.5rem;
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid #bbd1f4;
  background: #edf4ff;
  color: #2d5a9f;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.24rem 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.25px;
}

.marketing-copy h1 {
  margin: 0 0 0.48rem;
  font-size: clamp(1.38rem, 2.2vw, 2.1rem);
  line-height: 1.14;
}

.marketing-copy p {
  margin: 0 0 0.7rem;
  color: #4c6381;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.72rem;
}

.hero-bullets {
  margin: 0;
  padding-left: 1rem;
  color: #36506f;
  display: grid;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.hero-highlight {
  border-radius: 18px;
  display: grid;
  gap: 0.55rem;
  align-content: start;
  background: linear-gradient(155deg, #0f3460 0%, #124270 60%, #135280 100%);
  color: #e4efff;
  border: none;
  box-shadow: 0 24px 45px rgba(10, 29, 56, 0.28);
}

.hero-highlight h2 {
  margin-bottom: 0.2rem;
  color: #fff;
}

.hero-highlight p {
  margin: 0;
  color: #d5e5ff;
}

.hero-stat-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hero-stat-grid article {
  border: 1px solid rgba(184, 211, 255, 0.28);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.55rem 0.58rem;
}

.hero-stat-grid strong {
  display: block;
  color: #fff;
  font-size: 1.05rem;
}

.hero-stat-grid span {
  display: block;
  margin-top: 0.08rem;
  color: #d4e3ff;
  font-size: 0.8rem;
  line-height: 1.3;
}

.marketing-plans .section-head {
  margin-bottom: 0.75rem;
}

.plans-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.plans-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.plan-card {
  position: relative;
  border: 1px solid #cfddf4;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(20, 42, 78, 0.1);
  padding: 0.82rem;
  display: grid;
  gap: 0.48rem;
}

.plan-card.featured {
  border-color: #86b0ff;
  background: linear-gradient(170deg, #ffffff, #eef5ff);
}

.plan-badge {
  position: absolute;
  top: -0.55rem;
  right: 0.65rem;
  border-radius: 999px;
  background: #1f67e1;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
}

.plan-card h3 {
  margin-bottom: 0.08rem;
}

.plan-price {
  margin: 0.15rem 0 0;
  color: #173d70;
  font-size: 1.38rem;
  font-weight: 800;
}

.plan-price small {
  font-size: 0.8rem;
  color: #6880a1;
  font-weight: 600;
  margin-left: 0.15rem;
}

.plan-features {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.2rem;
  color: #2f4a6a;
  font-size: 0.84rem;
}

.subscription-status {
  display: grid;
  gap: 0.45rem;
}

.subscription-status > div {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fbff;
  padding: 0.55rem 0.65rem;
}

.subscription-status strong {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.94rem;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(7, 16, 31, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 110;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .mobile-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(84vw, 300px);
    height: 100vh;
    border-right: none;
    transform: translateX(-106%);
    transition: transform 0.22s ease;
    box-shadow: 0 20px 50px rgba(2, 9, 22, 0.45);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-nav {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.2rem;
  }

  .sidebar-close {
    display: inline-flex;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .workspace {
    padding: 0.75rem 0.7rem 0.85rem;
  }

  .workspace-header {
    padding: 0.45rem 0.5rem;
  }

  .workspace-userbar {
    width: 100%;
    justify-content: flex-end;
  }

  .login-wrapper {
    width: min(760px, 96vw);
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-side {
    gap: 0.55rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  }

  .marketing-page {
    width: 100%;
    padding: 0.85rem 0.58rem 1rem;
  }

  .marketing-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .grid.cols-2 {
    grid-template-columns: 1fr;
  }

  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .workspace-title {
    font-size: 0.88rem;
    white-space: nowrap;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .workspace-header {
    align-items: flex-start;
    gap: 0.32rem;
  }

  .workspace-header-left {
    width: 100%;
    justify-content: space-between;
  }

  .workspace-userbar {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.32rem;
  }

  .workspace-user-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-radius: 8px;
  }

  .workspace-logout-form .btn.mini {
    min-height: 32px;
    padding: 0.26rem 0.52rem;
    font-size: 0.73rem;
  }

  .workspace-footer {
    font-size: 0.72rem;
  }

  input,
  select,
  textarea,
  .btn {
    font-size: 16px;
  }

  .btn {
    min-height: 44px;
  }

  .btn.mini {
    min-height: 36px;
    padding: 0.35rem 0.62rem;
  }

  .actions {
    display: grid;
    gap: 0.45rem;
  }

  .actions .btn {
    width: 100%;
  }

  .action-row {
    display: grid;
    gap: 0.35rem;
    width: 100%;
  }

  .action-row .btn,
  .action-row form,
  .action-row form .btn {
    width: 100%;
  }

  .table-wrap {
    border-radius: 10px;
  }

  table,
  table.table-mobile {
    min-width: 620px;
  }

  th,
  td {
    font-size: 0.8rem;
    padding: 0.45rem 0.4rem;
  }

  th {
    font-size: 0.72rem;
  }

  .table-pagination {
    margin-top: 0.5rem;
  }

  .table-pagination-info {
    width: 100%;
    font-size: 0.74rem;
  }

  .table-pagination-controls {
    width: 100%;
    justify-content: flex-end;
  }

  .stats-kpi-card strong {
    font-size: 1.08rem;
  }

  .stats-overview-card {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-overview-chips {
    justify-content: flex-start;
  }

  .stats-insight-grid {
    grid-template-columns: 1fr;
  }

  .stats-toolbar {
    align-items: flex-start;
  }

  .stats-toolbar-filter {
    width: 100%;
    justify-content: space-between;
  }

  .stats-toolbar-filter select {
    width: auto;
    min-width: 142px;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .stats-page .chart-card h2 {
    font-size: 0.94rem;
    line-height: 1.3;
  }

  .stats-page .chart-meta {
    font-size: 0.74rem;
  }

  .dashboard-chart-head {
    align-items: flex-start;
  }

  .dashboard-chart-filter {
    width: 100%;
    justify-content: space-between;
  }

  .admin-banner-row {
    align-items: flex-start;
  }

  .admin-pill {
    font-size: 0.74rem;
  }

  .admin-kpi-grid {
    grid-template-columns: 1fr;
  }

  .chart-legend {
    gap: 0.4rem 0.6rem;
    font-size: 0.76rem;
  }

  .chart-legend span {
    line-height: 1.25;
  }

  .pie-legend-list li {
    align-items: flex-start;
  }

  .pie-legend-list strong {
    display: block;
    margin-left: 1.15rem;
    margin-top: 0.1rem;
  }

  .total-chip {
    flex-wrap: wrap;
    line-height: 1.25;
  }

  .method-list {
    font-size: 0.8rem;
  }

  .guest-main {
    align-items: stretch;
  }

  .guest-alert-stack {
    width: 100%;
  }

  .login-wrapper {
    width: 100%;
  }

  .login-side {
    padding: 1rem 0.9rem;
  }

  .login-side ul {
    font-size: 0.84rem;
  }

  .login-pro {
    padding: 0.92rem 0.82rem;
  }

  .password-toggle {
    padding: 0.24rem 0.5rem;
    font-size: 0.72rem;
  }

  .marketing-topbar {
    margin-bottom: 0.7rem;
  }

  .marketing-brand {
    font-size: 0.98rem;
  }

  .marketing-brand img {
    width: 40px;
    height: 40px;
  }

  .marketing-copy,
  .hero-highlight {
    border-radius: 14px;
    padding: 0.8rem;
  }

  .hero-bullets {
    font-size: 0.84rem;
    gap: 0.18rem;
  }

  .hero-stat-grid {
    grid-template-columns: 1fr;
  }

  .plan-card {
    padding: 0.7rem;
  }

  .plan-price {
    font-size: 1.18rem;
  }
}

@media (max-width: 560px) {
  .login-shell {
    border-radius: 16px;
  }

  .login-side {
    padding: 0.86rem 0.78rem;
    gap: 0.42rem;
  }

  .login-side h1 {
    font-size: 1.1rem;
  }

  .login-logo {
    width: clamp(165px, 62vw, 230px);
    height: auto;
    border-radius: 9px;
  }

  .login-side p {
    font-size: 0.86rem;
    line-height: 1.35;
  }

  .login-slogan {
    margin-top: 0.08rem;
    font-size: 0.8rem;
    padding: 0.42rem 0.52rem;
  }

  .login-side ul {
    display: none;
  }

  .login-pro {
    padding: 0.88rem 0.74rem;
  }

  .login-form {
    gap: 0.62rem;
  }

  .remember-row {
    align-items: flex-start;
  }

  .password-input-wrap input {
    padding-right: 4.9rem;
  }
}

@media (max-width: 390px) {
  .guest-main {
    padding-top: calc(0.65rem + env(safe-area-inset-top));
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom));
  }

  .login-side {
    padding: 0.78rem 0.68rem;
  }

  .login-pro {
    padding: 0.78rem 0.64rem;
  }

  .login-title-icon {
    width: 24px;
    height: 24px;
  }

  .login-title-icon svg {
    width: 14px;
    height: 14px;
  }

  .password-toggle {
    right: 0.3rem;
  }
}

@media (max-width: 480px) {
  .workspace {
    padding: 0.58rem 0.48rem 0.75rem;
  }

  .workspace-header {
    padding: 0.36rem 0.4rem;
    border-radius: 10px;
  }

  .workspace-user-name {
    font-size: 0.73rem;
    padding: 0.14rem 0.38rem;
  }

  .workspace-userbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .workspace-userbar .role-chip {
    display: none;
  }

  .mobile-menu-btn {
    min-height: 32px;
    padding: 0.26rem 0.44rem;
    font-size: 0.74rem;
  }

  .workspace-footer {
    justify-content: center;
    text-align: center;
    gap: 0.2rem 0.4rem;
  }

  .back-to-top {
    right: 12px;
    bottom: 12px;
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  .page-head {
    margin-bottom: 0.62rem;
  }

  .page-head p.muted {
    font-size: 0.8rem;
    line-height: 1.3;
  }

  h1 {
    font-size: 1.12rem;
  }

  h2 {
    font-size: 0.98rem;
  }

  .card {
    padding: 0.78rem;
    border-radius: 12px;
  }

  .kpi-grid,
  .stats-kpi-grid,
  .quick-grid,
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .stats-page .chart-card h2 {
    font-size: 0.88rem;
  }

  .stats-page .chart-meta {
    font-size: 0.72rem;
  }

  .stats-chip {
    font-size: 0.72rem;
  }

  .kpi-card strong {
    font-size: 1.18rem;
  }

  .quick-card {
    padding: 0.62rem;
  }

  .quick-card span {
    margin-top: 0.08rem;
    font-size: 0.78rem;
  }

  .total-chip {
    font-size: 0.76rem;
    margin-bottom: 0.55rem;
    padding: 0.22rem 0.56rem;
  }

  .method-list {
    margin-bottom: 0.52rem;
  }

  .pie-chart-wrap canvas {
    width: min(100%, 330px);
  }

  .type-bar-head {
    gap: 0.2rem 0.45rem;
  }

  .type-bar-head strong {
    margin-left: 0;
    width: 100%;
  }

  table,
  table.table-mobile {
    min-width: 560px;
  }

  .table-pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }

  .table-pagination-controls {
    justify-content: space-between;
  }

  .table-pagination-btn {
    flex: 1;
    text-align: center;
  }

  .role-chip {
    font-size: 0.7rem;
    padding: 0.22rem 0.5rem;
  }

  .sidebar {
    width: min(90vw, 290px);
  }
}

@media (max-height: 700px) and (max-width: 720px) {
  .guest-main {
    align-items: flex-start;
  }

  .login-side {
    display: grid;
    gap: 0.3rem;
  }

  .login-side > p,
  .login-slogan,
  .login-side ul {
    display: none;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }
}
