:root {
  --bg-body: #f4f7fb;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-nav: rgba(255, 255, 255, 0.95);
  --bg-sidebar: rgba(255, 255, 255, 0.98);
  --bg-input: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: rgba(15, 23, 42, 0.08);
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-orange: #f59e0b;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 18px rgba(15, 23, 42, 0.06);
  --container: 1240px;
}

[data-theme="dark"] {
  --bg-body: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.72);
  --bg-nav: rgba(10, 15, 30, 0.95);
  --bg-sidebar: rgba(8, 12, 24, 0.96);
  --bg-input: rgba(255, 255, 255, 0.04);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
  --shadow-soft: 0 8px 18px rgba(0, 0, 0, 0.15);
}

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

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(
      circle at top left,
      rgba(99, 102, 241, 0.16),
      transparent 28%
    ),
    radial-gradient(
      circle at top right,
      rgba(16, 185, 129, 0.11),
      transparent 24%
    ),
    var(--bg-body);
  color: var(--text-main);
  transition:
    background-color 0.25s ease,
    color 0.25s ease;
  padding-top: 60px;
}

body.sidebar-open {
  overflow: hidden;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.empty-state,
.empty-note {
  text-align: center;
  color: var(--text-muted);
  padding: 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: rgba(99, 102, 241, 0.12);
}

.pill-success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-green);
}

.navbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 60px;
  display: grid;
  grid-template-columns: 60px 1fr 60px;
  align-items: center;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  z-index: 200;
  box-shadow: var(--shadow-soft);
  padding: 0 10px;
}

.nav-left,
.nav-right {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
}

.nav-center {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  white-space: nowrap;
  user-select: none;
}

.brand span {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-logo-small,
.mini-logo,
.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 20px rgba(99, 102, 241, 0.25);
}

.brand-logo-small {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  font-size: 0.8rem;
}

.menu-btn,
.theme-toggle-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.menu-btn {
  font-size: 1.45rem;
  line-height: 1;
}

.menu-btn:hover,
.theme-toggle-btn:hover {
  background: rgba(127, 127, 127, 0.12);
  transform: translateY(-1px);
}

.theme-toggle-btn.spin .theme-icon {
  transform: rotate(180deg) scale(1.12);
}

.theme-icon {
  display: inline-block;
  font-size: 1.1rem;
  transition: transform 0.35s ease;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(16px);
  transform: translateX(-105%);
  transition: transform 0.28s ease;
  z-index: 300;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  gap: 1rem;
}

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

.sidebar .brand-area {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.mini-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 0.9rem;
}

.brand-area span {
  font-weight: 700;
}

.sidebar-profile {
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.sidebar-profile .label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.sidebar-profile .value {
  font-weight: 700;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-left: 0;
  margin: 0;
  flex: 1;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: all 0.2s ease;
  font-weight: 600;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-main);
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(99, 102, 241, 0.18);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
  z-index: 250;
}

.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.page-shell {
  width: min(var(--container), calc(100% - 32px));
  margin: 0 auto;
  padding: 1.2rem 0 2rem;
}

.main-content {
  width: 100%;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
}

.page-header h2 {
  font-size: clamp(1.5rem, 2vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-header p {
  color: var(--text-muted);
}

.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.2rem;
  backdrop-filter: blur(18px);
}

.stat-card h6 {
  color: var(--text-muted);
  margin-bottom: 0.65rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-card .value {
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  font-weight: 800;
}

.stat-card.blue .value {
  color: var(--primary);
}
.stat-card.green .value {
  color: var(--accent-green);
}
.stat-card.orange .value {
  color: var(--accent-orange);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 90px 16px 24px;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-top {
  text-align: center;
  margin-bottom: 1.3rem;
}

.brand-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  margin: 0 auto 0.9rem;
  font-size: 1.4rem;
}

.auth-top h1,
.auth-top h2 {
  font-size: 1.55rem;
  margin-bottom: 0.3rem;
}

.auth-top p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label,
.form-label {
  display: block;
  margin-bottom: 0.45rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.form-control,
.form-select,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"] {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.form-control:focus,
.form-select:focus,
input:focus {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}

.form-select {
  appearance: none;
}

.form-actions,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0.85rem 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease,
    opacity 0.2s ease;
  text-decoration: none;
  line-height: 1;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  box-shadow: 0 12px 24px rgba(99, 102, 241, 0.24);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  color: #fda4af;
  border-color: rgba(239, 68, 68, 0.18);
}

.btn-sm {
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
  border-radius: 12px;
}

.message-bar {
  border-radius: 14px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  border: 1px solid transparent;
}

.message-bar.error {
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.18);
}

.message-bar.success {
  background: rgba(16, 185, 129, 0.12);
  color: #a7f3d0;
  border-color: rgba(16, 185, 129, 0.18);
}

.message-bar.info {
  background: rgba(99, 102, 241, 0.12);
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.18);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

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

.roommate-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.roommate-info {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: white;
  flex: 0 0 auto;
}

.roommate-name {
  font-weight: 800;
  margin-bottom: 0.15rem;
}

.roommate-sub {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.member-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  user-select: none;
}

.member-chip input {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 16px;
}

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

.custom-table thead th {
  text-align: left;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.custom-table tbody td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.custom-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.action-cell {
  white-space: nowrap;
}

.text-green {
  color: var(--accent-green);
  font-weight: 700;
}

.text-red {
  color: var(--accent-red);
  font-weight: 700;
}

.settlement-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.settlement-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.95rem 1rem;
}

.auth-footer-main {
  text-align: center;
  color: var(--text-muted);
  padding: 1rem 0 1.5rem;
  font-size: 0.9rem;
}
.app-footer {
  width: 100%;
  margin-top: 2rem;
  padding: 1rem 0;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--bg-nav);
  backdrop-filter: blur(10px);
}

.footer-content {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-content strong {
  color: var(--text-main);
}
@media (max-width: 900px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .page-shell {
    width: min(var(--container), calc(100% - 20px));
  }
}

@media (max-width: 768px) {
  .navbar {
    grid-template-columns: 54px 1fr 54px;
    padding: 0 6px;
  }

  .nav-left,
  .nav-right {
    width: 54px;
  }

  .brand span {
    font-size: 0.92rem;
  }

  .brand-logo-small {
    width: 28px;
    height: 28px;
    border-radius: 9px;
  }

  .page-shell {
    width: calc(100% - 16px);
  }

  .grid-4 {
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
  }

  .roommate-card,
  .settlement-card {
    flex-direction: column;
    align-items: stretch;
  }

  .action-cell {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .custom-table {
    min-width: 860px;
  }
}

@media (max-width: 560px) {
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 1.2rem;
  }

  .sidebar {
    width: min(88vw, 300px);
  }

  .page-header {
    margin-bottom: 1rem;
  }

  .brand {
    gap: 0.45rem;
  }

  .brand span {
    font-size: 0.84rem;
  }

  .menu-btn,
  .theme-toggle-btn {
    width: 38px;
    height: 38px;
  }
  .footer-content {
    flex-direction: column;
    gap: 0.3rem;
  }
}
