*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #edf3f7;
  --surface: #ffffff;
  --surface-muted: #f6f8fb;
  --text: #0f1b2d;
  --muted: #5a6b7e;
  --accent: #0f6d6b;
  --accent-strong: #0b5250;
  --accent-soft: rgba(15, 109, 107, 0.12);
  --stroke: #e2e7ef;
  --shadow: 0 18px 50px rgba(15, 27, 45, 0.12);
}

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(15, 109, 107, 0.15), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(17, 76, 115, 0.18), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

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

.sidebar {
  width: 240px;
  padding: 24px 18px;
  background: linear-gradient(165deg, #0b1f2a 0%, #0f2c3d 48%, #114c73 100%);
  color: #e9f2ff;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.5px;
  margin-bottom: 28px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.25));
}

.menu a {
  display: block;
  padding: 10px 14px;
  border-radius: 12px;
  color: #d6e6f5;
  text-decoration: none;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.menu a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.menu a.active {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.content {
  flex: 1;
  padding: 32px 40px 40px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

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

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}

h1 {
  font-size: 32px;
  margin: 0;
}

h2 {
  margin: 0;
  font-size: 18px;
}

.subtext {
  margin: 8px 0 0;
  color: var(--muted);
}

.status-pill {
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  border: 1px solid rgba(15, 109, 107, 0.2);
}

.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
}

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

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--muted);
}

select,
button,
input[type="checkbox"] {
  font-family: inherit;
}

select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--surface-muted);
  color: var(--text);
  font-size: 14px;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 16px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 20px rgba(15, 109, 107, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 109, 107, 0.28);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.8;
  transform: none;
  box-shadow: none;
}

button.is-loading {
  cursor: progress;
}

.button-spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-header {
  padding: 20px 24px 0;
}

.muted {
  color: var(--muted);
  margin: 6px 0 0;
}

.table-wrap {
  padding: 16px 24px 24px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13px;
  min-width: 900px;
}

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

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  background: var(--surface-muted);
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover {
  background: rgba(15, 109, 107, 0.06);
}

.summary-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  align-items: center;
}

.report-summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.report-summary .summary-header {
  width: 100%;
  margin-bottom: 0;
}

.report-summary #summary {
  width: 100%;
  overflow-x: auto;
}

.summary-card .label {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.summary-card .value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 6px;
}

.summary-actions {
  display: flex;
  justify-content: flex-end;
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

#summary table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

#summary th,
#summary td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--stroke);
}

#summary:empty::before {
  content: "Summary will appear after you select a month.";
  color: var(--muted);
  display: block;
  padding: 6px 0;
}

.summary-card:has(#summary:empty) .update-button {
  display: none;
}

.summary-card:has(#summary:empty) .summary-header {
  justify-content: flex-start;
  gap: 12px;
}

.toast-container {
  position: fixed;
  top: 18px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}

.toast {
  background: #0f1b2d;
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  font-weight: 600;
  max-width: 320px;
  transform: translateY(-6px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.toast-success {
  background: #0f6d6b;
}

.toast.toast-error {
  background: #b6403f;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.sidebar-user {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-user .user-email {
  font-size: 12px;
  color: #b9cfe3;
  word-break: break-all;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: none;
  font-size: 13px;
  padding: 8px 14px;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  box-shadow: none;
}

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-wrap {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  padding: 32px;
}

.auth-brand {
  margin-bottom: 24px;
  color: var(--text);
}

.auth-title {
  font-size: 24px;
  margin: 6px 0 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--surface-muted);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-form button {
  width: 100%;
  justify-content: center;
}

.auth-error {
  color: #b6403f;
  font-size: 13px;
  margin: 0;
  min-height: 16px;
}

.auth-step.hidden {
  display: none;
}

.enroll-qr {
  margin: 16px 0 8px;
  display: flex;
  justify-content: center;
}

.enroll-qr img {
  max-width: 200px;
  width: 100%;
  height: auto;
}

.enroll-secret-label {
  margin: 4px 0 4px;
  font-size: 13px;
  text-align: center;
}

.enroll-secret {
  display: block;
  text-align: center;
  background: var(--surface-muted);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 8px;
  font-size: 13px;
  letter-spacing: 1px;
  word-break: break-all;
}

@media (max-width: 960px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .menu {
    display: flex;
    gap: 8px;
  }

  .menu a {
    margin-bottom: 0;
  }

  .content {
    padding: 24px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .summary-card {
    grid-template-columns: 1fr;
  }

  .summary-actions {
    justify-content: flex-start;
  }

  .toast-container {
    left: 16px;
    right: 16px;
  }
}
