:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #3c8b5c;
  --red: #b84a4a;
  --yellow: #c48a2b;
  --gray-100: #f3f6fa;
  --gray-200: #e1e6eb;
  --gray-300: #c7d0d8;
  --gray-700: #394653;
  --gray-900: #1e252c;
  --white: #ffffff;
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-soft: #fbfcfd;
  --surface-strong: #f8fafc;
  --text: #1e252c;
  --text-muted: #556372;
  --border: #e1e6eb;
  --sidebar-bg: #ffffff;
  --shadow: 0 8px 24px rgba(30, 37, 44, 0.04);
}

[data-theme="dark"] {
  --bg: #101418;
  --surface: #171d23;
  --surface-soft: #1d242c;
  --surface-strong: #222b34;
  --text: #eef3f8;
  --text-muted: #aab7c5;
  --border: #2d3945;
  --sidebar-bg: #151b21;
  --gray-100: #101418;
  --gray-200: #2d3945;
  --gray-300: #435262;
  --gray-700: #c8d2dc;
  --gray-900: #eef3f8;
  --white: #171d23;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Poppins, "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

.hidden {
  display: none !important;
}

.muted {
  color: #eef4ff;
  font-size: 13px;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-box {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 2px 12px rgba(30, 37, 44, 0.08);
}

.brand-mark,
.brand {
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  color: var(--blue);
  font-size: 31px;
  margin-bottom: 8px;
}

h1,
h2,
h3 {
  margin: 0 0 16px;
  font-weight: 600;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 23px;
}

h3 {
  font-size: 17px;
}

.form-stack,
.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.expense-form {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(47, 111, 173, 0.25);
  border-color: var(--blue);
}

.btn {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 13px;
  cursor: pointer;
  white-space: nowrap;
  background: var(--white);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

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

.btn-primary {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 52%, #db2777 100%);
  border-color: transparent;
  color: var(--white);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.btn-primary:hover {
  box-shadow: 0 10px 22px rgba(124, 58, 237, 0.28);
}

.btn-secondary {
  border-color: var(--gray-300);
  color: var(--text-muted);
  background: var(--surface);
}

.btn-light {
  background: var(--surface-strong);
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-small {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 13px;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
}

.mobile-topbar {
  display: none;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-content: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.icon-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.mobile-brand {
  font-weight: 700;
  font-size: 21px;
  color: var(--blue-dark);
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-brand {
  padding: 8px 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--blue-dark);
  font-size: 28px;
  font-weight: 700;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.sidebar-theme {
  padding: 8px 4px 0;
}

.theme-switch {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.theme-switch:hover {
  border-color: var(--blue);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.12);
}

.theme-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  line-height: 1;
  opacity: 0.58;
  transition: transform 0.18s ease, opacity 0.18s ease, color 0.18s ease;
}

.theme-switch:not(.is-dark) .sun,
.theme-switch.is-dark .moon {
  color: var(--blue-dark);
  opacity: 1;
  transform: scale(1.08);
}

.theme-switch-track {
  width: 52px;
  height: 28px;
  position: relative;
  display: inline-block;
  border-radius: 999px;
  background: linear-gradient(135deg, #fbbf24 0%, #60a5fa 100%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18);
}

.theme-switch-thumb {
  width: 22px;
  height: 22px;
  position: absolute;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(30, 37, 44, 0.26);
  transition: transform 0.22s cubic-bezier(.2, .8, .2, 1), background 0.18s ease;
}

.theme-switch.is-dark .theme-switch-track {
  background: linear-gradient(135deg, #312e81 0%, #db2777 100%);
}

.theme-switch.is-dark .theme-switch-thumb {
  transform: translateX(24px);
  background: #eef3f8;
}

.theme-switch.compact {
  width: auto;
  min-height: 40px;
  padding: 0 9px;
  gap: 7px;
  background: var(--surface);
}

.theme-switch.compact .theme-switch-track {
  width: 46px;
  height: 26px;
}

.theme-switch.compact .theme-switch-thumb {
  width: 20px;
  height: 20px;
}

.theme-switch.compact.is-dark .theme-switch-thumb {
  transform: translateX(20px);
}

.nav-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 12px;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: #eaf1ff;
  color: var(--blue-dark);
}

.sidebar-user {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

.content {
  width: 100%;
  padding: 26px;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.clock-widget {
  min-width: 240px;
  text-align: right;
  color: var(--text);
}

#current-time {
  font-size: 31px;
  font-weight: 700;
  line-height: 1.1;
}

#current-date-label {
  color: var(--text-muted);
  font-size: 14px;
}

.page-subtitle,
.table-note {
  color: var(--text-muted);
  font-size: 13px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.stat .value {
  font-size: 30px;
  font-weight: 700;
}

.stat .label {
  color: var(--text-muted);
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.chart-panel h3 {
  margin-bottom: 10px;
}

.chart-box {
  position: relative;
  height: 280px;
}

.chart-fallback {
  display: grid;
  align-content: center;
  gap: 10px;
  height: 100%;
}

.fallback-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 10px;
  align-items: center;
}

.fallback-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.fallback-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 52%, #db2777 100%);
}

.quick-glance {
  border-color: #cfe0ff;
}

.quick-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.quick-head strong {
  display: block;
  font-size: 17px;
}

.quick-head small {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
}

.quick-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.accordion-caret {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-content: center;
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--text-muted);
  font-size: 18px;
  transition: transform 0.16s ease;
}

.quick-head[aria-expanded="false"] .accordion-caret {
  transform: rotate(-90deg);
}

.quick-list {
  display: grid;
  gap: 8px;
}

.quick-item {
  width: 100%;
  display: grid;
  grid-template-columns: 110px minmax(140px, 1fr) 110px auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.quick-item:hover {
  border-color: var(--blue);
  background: #f2f7ff;
}

[data-theme="dark"] .quick-item:hover {
  background: #202b3a;
}

.quick-type {
  color: var(--blue-dark);
  font-weight: 700;
  font-size: 13px;
}

.quick-title {
  font-weight: 600;
}

.quick-date,
.quick-empty {
  color: var(--text-muted);
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 10px 9px;
  vertical-align: middle;
}

th {
  color: var(--text-muted);
  background: var(--surface-strong);
  font-size: 13px;
}

.badge {
  display: inline-block;
  border-radius: 3px;
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 700;
}

.badge-pending {
  background: #fff5df;
  color: var(--yellow);
}

.badge-done {
  background: #e5f4eb;
  color: var(--green);
}

.badge-skipped,
.badge-off,
.badge-overdue {
  background: #f8e5e5;
  color: var(--red);
}

.badge-on {
  background: #e5f4eb;
  color: var(--green);
}

.badge-active {
  background: #e5f4eb;
  color: var(--green);
}

.badge-paused {
  background: var(--surface-strong);
  color: var(--text-muted);
}

.badge-verifying {
  background: #eaf1ff;
  color: var(--blue-dark);
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-soft);
}

.list-title {
  font-weight: 700;
}

.check-list {
  grid-column: span 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  align-self: stretch;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-soft);
}

.check-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 0;
  color: var(--text-muted);
}

.share-editor {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-soft);
}

.share-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 130px 1fr;
  gap: 10px;
  align-items: center;
}

.expense-item {
  display: grid;
  gap: 10px;
}

.expense-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.notification-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notification-item .btn {
  flex: 0 0 auto;
}

.share-list {
  display: grid;
  gap: 6px;
}

.share-line {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 110px 90px auto;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}

.total-line {
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid #cfe0ff;
  border-radius: 8px;
  background: #f2f7ff;
  color: var(--blue-dark);
  font-weight: 700;
}

.secret-box {
  margin: 14px 0 0;
  padding: 12px;
  background: #fff8e6;
  border: 1px solid #ecd28a;
  border-radius: 4px;
  color: #1e252c !important;
  -webkit-text-fill-color: #1e252c;
  white-space: pre-wrap;
}

[data-theme="dark"] .secret-box {
  background: #fff8e6;
  border-color: #ecd28a;
  color: #1e252c !important;
  -webkit-text-fill-color: #1e252c;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--gray-900);
  color: var(--white);
  padding: 11px 14px;
  border-radius: 4px;
  box-shadow: 0 4px 18px rgba(30, 37, 44, 0.25);
  max-width: 320px;
}

@media (max-width: 900px) {
  .mobile-topbar {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 25;
    padding: 9px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 58px auto 0 0;
    z-index: 30;
    width: min(82vw, 310px);
    min-height: auto;
    height: calc(100vh - 58px);
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    box-shadow: 14px 0 30px rgba(0, 0, 0, 0.18);
  }

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

  .sidebar-nav {
    display: grid;
    overflow: visible;
  }

  .sidebar-theme {
    padding: 4px 0;
  }

  .nav-item {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

  .cards,
  .two-col,
  .chart-grid,
  .form-grid,
  .expense-form {
    grid-template-columns: 1fr;
  }

  .check-list {
    grid-column: span 1;
    grid-template-columns: 1fr;
  }

  .share-row,
  .share-line {
    grid-template-columns: 1fr;
  }

  .quick-item {
    grid-template-columns: 1fr;
  }

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

  .content {
    padding: 16px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 10px 12px;
  }

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

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

  .clock-widget {
    min-width: 0;
    text-align: left;
  }

  .btn {
    width: 100%;
  }

  .theme-switch.compact {
    padding: 0 7px;
  }

  .theme-switch.compact .theme-icon {
    display: none;
  }
}
