:root {
  --bg: #f5f5f7;
  --bg-alt: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0a84ff;
  --accent-2: #34c759;
  --card: #ffffff;
  --danger: #ff3b30;
  --border: #e5e5ea;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  --glass: rgba(255, 255, 255, 0.8);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
}

h1, h2, h3 {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  margin-top: 0;
}

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

.sidebar {
  background: #111113;
  color: #f5f5f7;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.05);
  height: 100vh;
  position: sticky;
  left: auto;
  top: 0;
  width: 260px;
  transform: none;
  transition: none;
  z-index: 1;
}

.menu-toggle {
  border: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  display: none;
}

.brand-title {
  font-size: 24px;
  font-weight: 700;
}

.brand-sub {
  color: rgba(245, 245, 247, 0.7);
  margin-top: 4px;
}

.month-selector {
  display: none;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-link {
  text-decoration: none;
  color: #f5f5f7;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.14);
}

.nav-link.active {
  background: rgba(10, 132, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(10, 132, 255, 0.5);
}

.nav-icon {
  min-width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
}
.sidebar-footer {
  margin-top: auto;
  font-size: 14px;
}

.logout {
  display: inline-block;
  margin-top: 8px;
  color: #9fd0ff;
  text-decoration: none;
}

.main {
  padding: 36px;
}

.header {
  margin-bottom: 24px;
}

.header-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.header-left {
  justify-self: start;
}

.header-center {
  justify-self: center;
}

.header-right {
  justify-self: end;
}

.header-month {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.header-month span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-month input {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
}
.page-title {
  font-size: 26px;
  font-weight: 600;
}

.page-subtitle {
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.grid {
  display: grid;
  gap: 18px;
}

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

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.metric .label {
  color: var(--muted);
  font-size: 13px;
}

.metric .value {
  font-size: 20px;
  font-weight: 600;
  margin-top: 8px;
}

.metric .subvalue {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.hero {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.hero-card {
  background: linear-gradient(135deg, #ffffff 0%, #f5f7ff 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.hero-card.highlight {
  background: linear-gradient(135deg, #0a84ff 0%, #34c759 100%);
  color: #ffffff;
  border: none;
}

.hero-card.highlight .hero-label {
  color: rgba(255, 255, 255, 0.85);
}

.hero-label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 8px;
}

.form {
  display: grid;
  gap: 14px;
}

.form label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.form input,
.form select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: var(--bg-alt);
}

.form .inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border: none;
}

.btn.danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  text-align: left;
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
}

.table th {
  color: var(--muted);
  font-weight: 500;
}

.table tbody tr:nth-child(even) {
  background: var(--bg-alt);
}

.table tbody tr:nth-child(odd) {
  background: #ffffff;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

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

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(180deg, #f5f5f7 0%, #ececf1 100%);
}

.auth-card {
  background: var(--card);
  border-radius: 24px;
  padding: 32px;
  width: min(420px, 90vw);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.alert {
  background: #fce7e1;
  color: #a93c28;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.perm-section {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: var(--bg-alt);
  display: none;
  gap: 8px;
}

.perm-section.active {
  display: grid;
}

.perm-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.actions form {
  margin: 0;
}

.table input {
  width: 100%;
}

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

.floating-save {
  position: sticky;
  top: 18px;
  justify-self: end;
  display: flex;
  justify-content: flex-end;
  grid-column: 1 / -1;
  z-index: 5;
}

.segmented {
  display: inline-flex;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}

.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 50;
  padding: 40px 16px;
  overflow: auto;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(520px, 92vw);
  background: var(--card);
  border-radius: 24px;
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 2;
  max-height: 85vh;
  overflow: auto;
}

.modal-card .modal-footer {
  position: sticky;
  bottom: 0;
  background: var(--card);
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

.menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 55;
}


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

.modal-header h3 {
  margin: 0;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}

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

  .sidebar {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 12px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 60;
  }

  .menu-toggle {
    display: inline-flex;
  }

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

  body.menu-open .menu-backdrop {
    display: block;
  }

  .main {
    padding: 24px;
  }

  .header-bar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .header-center {
    justify-self: start;
  }

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

@media (max-width: 600px) {
  .main {
    padding: 16px;
  }

  .sidebar {
    padding: 20px 16px;
  }

  .nav {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .nav-link {
    width: 100%;
  }

  .page-title {
    font-size: 20px;
  }

  .page-subtitle {
    font-size: 12px;
  }

  .card {
    padding: 16px;
  }

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

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

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

  .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

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

  .inline-form {
    flex-wrap: wrap;
  }

  .modal-card {
    width: min(600px, 92vw);
    max-height: 80vh;
  }

  .header-month input {
    width: 100%;
  }
}
