:root {
  --sidebar: #10233d;
  --sidebar-active: #1d3d66;
  --sidebar-border: rgba(255, 255, 255, .12);
  --ink: #172033;
  --muted: #657083;
  --line: #d9e0ea;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --accent: #1f7a68;
  --header-bg: #eef2f6;
  --header-ink: #3d4858;
  --group-ink: #20324a;
  --button-secondary-bg: #1d3d66;
  --button-secondary-ink: #ffffff;
  --field-bg: #ffffff;
  --field-ink: #172033;
  --field-border: #d9e0ea;
  --focus-fill: rgba(255, 255, 255, .18);
  --row-base: #ffffff;
  --row-status-strength: 30%;
  --row-dark-base: #000000;
  --row-dark-strength: 82%;
  --row-text: #172033;
  --row-dark-text: #ffffff;
  --header-height: 42px;
  --month-row-height: 36px;
  --date-row-height: 24px;
}

body[data-theme="dark"] {
  --sidebar: #111827;
  --sidebar-active: #1f2937;
  --sidebar-border: rgba(255, 255, 255, .08);
  --ink: #e5edf7;
  --muted: #9fb0c8;
  --line: #334155;
  --bg: #0f172a;
  --panel: #111827;
  --accent: #2e8a75;
  --header-bg: #1e293b;
  --header-ink: #d5dfec;
  --group-ink: #dbe5f1;
  --button-secondary-bg: #334155;
  --button-secondary-ink: #f8fafc;
  --field-bg: #162133;
  --field-ink: #e5edf7;
  --field-border: #334155;
  --focus-fill: rgba(255, 255, 255, .08);
  --row-base: #111827;
  --row-status-strength: 24%;
  --row-dark-base: #111827;
  --row-dark-strength: 34%;
  --row-text: #e5edf7;
  --row-dark-text: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

.login-view {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-view[hidden] {
  display: none;
}

.login-panel {
  display: grid;
  gap: 16px;
  width: min(380px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(15, 23, 42, .18);
}

.login-panel h1 {
  margin: 0;
  font-size: 28px;
}

.login-panel label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.login-panel input {
  min-height: 42px;
}

.login-error {
  margin: 0;
  color: #b91c1c;
  font-size: 14px;
}

body[data-auth="login"] .sidebar,
body[data-auth="login"] .main,
body[data-auth="checking"] .sidebar,
body[data-auth="checking"] .main {
  visibility: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  height: 100vh;
  overflow-y: auto;
  background: var(--sidebar);
  color: #fff;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
}

.brand {
  font-size: 22px;
  font-weight: 700;
  margin: 0 8px 28px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-divider {
  border-top: 1px solid var(--sidebar-border);
  margin: 10px 8px;
}

.sidebar-footer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding: 18px 0 0;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
  position: relative;
  min-width: 0;
}

.user-avatar-button {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--sidebar-border);
  border-radius: 999px;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.user-avatar-button:hover,
.user-avatar-button[aria-expanded="true"] {
  background: var(--sidebar-active);
}

.user-avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: #ffffff;
  background: #111827;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.user-avatar-large {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  font-size: 15px;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.person-icon {
  display: block;
  width: 58%;
  height: 58%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.user-menu-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 12px);
  z-index: 30;
  width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(15, 23, 42, .18);
}

.user-menu-popover[hidden] {
  display: none;
}

.user-menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-menu-head strong,
.user-menu-head span,
.user-menu-details dd {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-head strong {
  font-size: 14px;
}

.user-menu-head span,
.user-menu-details dt {
  color: var(--muted);
  font-size: 12px;
}

.user-menu-details {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.user-menu-details div {
  display: grid;
  gap: 2px;
}

.user-menu-details dt,
.user-menu-details dd {
  margin: 0;
}

.user-menu-details dd {
  font-size: 13px;
}

.user-menu-logout {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-buttons);
  padding: 9px 12px;
  color: var(--ink);
  background: var(--field-bg);
  cursor: pointer;
}

.user-menu-logout:hover {
  background: var(--soft-surface);
}

.theme-toggle {
  width: 46px;
  height: 46px;
  min-height: 46px;
  border: 1px solid var(--sidebar-border);
  border-radius: 999px;
  padding: 10px;
  background: transparent;
  color: #dce7f4;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.theme-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.theme-icon-sun {
  display: none;
}

body[data-theme="dark"] .theme-icon-moon {
  display: none;
}

body[data-theme="dark"] .theme-icon-sun {
  display: block;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 12px 14px;
  color: #dce7f4;
  background: transparent;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  opacity: .72;
}

.nav-item.active svg,
.nav-item:hover svg {
  opacity: 1;
}

.nav-item [data-nav-label] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item.active,
.nav-item:hover {
  color: #fff;
  background: var(--sidebar-active);
}

.main {
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  padding: 28px;
}

