/* ---- Reset & Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---- MD3 Color Tokens — Light (seed #E8738A) ---- */
:root {
  --primary: #9C2751;
  --on-primary: #FFFFFF;
  --primary-container: #FFD9E2;
  --on-primary-container: #3B0020;
  --secondary: #74565B;
  --on-secondary: #FFFFFF;
  --secondary-container: #FFD9DF;
  --on-secondary-container: #2C1519;
  --tertiary: #7B5630;
  --on-tertiary: #FFFFFF;
  --tertiary-container: #FFDDB5;
  --on-tertiary-container: #2B1700;
  --error: #BA1A1A;
  --error-container: #FFDAD6;
  --on-error-container: #410002;
  --surface: #FFF8F8;
  --on-surface: #201A1B;
  --on-surface-variant: #534247;
  --outline: #857378;
  --outline-variant: #D8C2C5;
  --surface-container-lowest: #FFFFFF;
  --surface-container-low: #FAF0F1;
  --surface-container: #F5E9EB;
  --surface-container-high: #EFE3E5;

  /* Glass (light mode): translucent, tintStrength=0 */
  --glass-bg: rgba(255, 248, 248, 0.55);
  --glass-border: rgba(133, 115, 120, 0.38);
  --glass-blur: 18px;

  /* Canvas gradient */
  --canvas-from: #FCE4EC;
  --canvas-mid:  #F8BBD0;
  --canvas-to:   #F48FB1;
}

/* ---- MD3 Color Tokens — Dark ---- */
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #FFB1C5;
    --on-primary: #5C0028;
    --primary-container: #7D0038;
    --on-primary-container: #FFD9E2;
    --secondary: #E5BDC2;
    --on-secondary: #422730;
    --secondary-container: #5A3F44;
    --on-secondary-container: #FFD9DF;
    --tertiary: #EFBE90;
    --on-tertiary: #432100;
    --tertiary-container: #613F17;
    --on-tertiary-container: #FFDDB5;
    --error: #FFB4AB;
    --on-error: #690005;
    --error-container: #93000A;
    --on-error-container: #FFDAD6;
    --surface: #1A1113;
    --on-surface: #EEE0E1;
    --on-surface-variant: #D8C2C5;
    --outline: #A08488;
    --outline-variant: #534247;
    --surface-container-lowest: #140C0D;
    --surface-container-low: #221517;
    --surface-container: #2D2022;
    --surface-container-high: #382A2C;

    /* Glass (dark mode): more opaque, nearly invisible border, tintStrength=0.35 */
    --glass-bg: rgba(20, 12, 13, 0.85);
    --glass-border: rgba(83, 66, 71, 0.07);
    --glass-blur: 18px;

    /* Canvas gradient */
    --canvas-from: #1A0A10;
    --canvas-mid:  #2D1520;
    --canvas-to:   #1E0E1A;
  }
}

/* ---- Base ---- */
html, body {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  color: var(--on-surface);
}

body {
  background: linear-gradient(135deg, var(--canvas-from) 0%, var(--canvas-mid) 55%, var(--canvas-to) 100%);
}

/* ---- App Shell ---- */
/* Canvas background fills the whole viewport.
   layout-outer is the width-constrained column (toolbar + shell-row)
   floating in the center of the canvas. */
.app {
  display: flex;
  flex-direction: column;
  align-items: center;      /* center layout-outer horizontally */
  height: 100vh;
  overflow: hidden;
  padding: 10px;
  gap: 0;
}

/* layout-outer: column containing toolbar + shell-row */
.layout-outer {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  gap: 8px;
}

.layout-centered {
  width: 100%;
  max-width: 1100px;
}

.layout-wide {
  width: 100%;
}

/* ---- Toolbar ---- */
/* Fully transparent — sits on the canvas, no background */
.toolbar {
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  /* no background, no border, no backdrop */
}

.toolbar-brand {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--primary);
  user-select: none;
  padding: 0 12px;
}

.toolbar-brand-wide {
  padding: 0 8px 0 4px;
}

.toolbar-left {
  position: absolute;
  left: 0;
  display: flex;
  gap: 2px;
  align-items: center;
}

.toolbar-right {
  position: absolute;
  right: 0;
  display: flex;
  gap: 2px;
  align-items: center;
}

.toolbar-btn {
  height: 28px;
  padding: 0 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--on-surface-variant);
  transition: background 0.15s;
  white-space: nowrap;
}

.toolbar-btn:hover {
  background: rgba(128, 128, 128, 0.12);
}

.toolbar-btn .ms {
  font-size: 16px;
}

.toolbar-btn-label {
  font-size: 12px;
  font-weight: 500;
}

.toolbar-btn-active {
  color: var(--primary);
}

.toolbar-btn-active:hover {
  background: rgba(128, 128, 128, 0.12);
}

/* ---- Shell Row (nav + content) ---- */
.shell-row {
  display: flex;
  gap: 10px;
  flex: 1;
  min-height: 0;
  align-items: center;   /* nav rail centered vertically */
}

/* ---- Glass Surface ---- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 28px;
}

/* ---- Material Symbols helper ---- */
.ms {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 22px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ---- Navigation Rail ---- */
/* align-self: center is set by parent .shell-row (align-items: center)
   height is intrinsic — only as tall as children, not stretched */
.nav-rail {
  width: 80px;
  flex-shrink: 0;
  align-self: center;   /* vertical centering within shell-row */
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 6px;
  gap: 2px;
}

.nav-fab {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.nav-fab:hover {
  background: var(--primary-container);
  color: var(--on-primary-container);
}

.nav-fab .ms {
  font-size: 22px;
}

.nav-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px;
  border-radius: 50px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--on-surface-variant);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(32, 26, 27, 0.07);
}

.nav-item.active {
  background: var(--primary-container);
  color: var(--on-primary-container);
}

.nav-item .ms {
  font-size: 22px;
}

.nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1;
}

/* ---- Content Area ---- */
/* Takes remaining width; height = shell-row height (intrinsic, centered by parent) */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  min-height: 0;
  align-self: stretch;   /* content area itself stretches, nav rail doesn't */
  scrollbar-width: thin;
  scrollbar-color: rgba(133, 115, 120, 0.3) transparent;
}

.content-area::-webkit-scrollbar {
  width: 5px;
}

.content-area::-webkit-scrollbar-track {
  background: transparent;
}

.content-area::-webkit-scrollbar-thumb {
  background: rgba(133, 115, 120, 0.3);
  border-radius: 3px;
}

/* ---- Header ---- */
.header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.header-greeting {
  flex: 3;
  min-width: 0;
}

.header-greeting-text {
  font-size: 20px;
  font-weight: 400;
  color: var(--on-surface);
  line-height: 1.2;
}

.header-company {
  font-size: 12px;
  color: var(--on-surface-variant);
  margin-top: 3px;
}

.header-metrics {
  flex: 5;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.hmetric {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hmetric .ms {
  font-size: 16px;
}

.hmetric-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--on-surface);
  white-space: nowrap;
}

.hmetric-label {
  font-size: 11px;
  color: var(--on-surface-variant);
}

.hmetric-primary .ms { color: var(--primary); }
.hmetric-tertiary .ms { color: var(--tertiary); }
.hmetric-secondary .ms { color: var(--secondary); }
.hmetric-outline .ms { color: var(--outline); }

/* ---- Avatar ---- */
.avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--on-primary-container);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: outline 0.15s;
  font-family: 'Roboto', sans-serif;
}

.avatar-btn:hover {
  outline: 2px solid var(--outline-variant);
  outline-offset: 1px;
}

.avatar-menu {
  position: absolute;
  right: 0;
  top: 44px;
  background: var(--surface-container-lowest);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--outline-variant);
  min-width: 210px;
  z-index: 200;
  overflow: hidden;
}

.avatar-menu-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--outline-variant);
}

.avatar-menu-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface);
}

.avatar-menu-email {
  font-size: 11px;
  color: var(--on-surface-variant);
  margin-top: 2px;
}

.avatar-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  cursor: pointer;
  transition: background 0.12s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: 'Roboto', sans-serif;
}

.avatar-menu-item:hover {
  background: rgba(32, 26, 27, 0.05);
}

.avatar-menu-item .ms {
  font-size: 17px;
  color: var(--on-surface-variant);
  flex-shrink: 0;
}

.avatar-menu-item-label {
  font-size: 13px;
  color: var(--on-surface);
  flex: 1;
}

.avatar-menu-item-check .ms {
  color: var(--primary);
}

.avatar-menu-item-destructive .ms {
  color: var(--error);
}

.avatar-menu-item-destructive .avatar-menu-item-label {
  color: var(--error);
}

.avatar-menu-divider {
  height: 1px;
  background: var(--outline-variant);
  margin: 4px 0;
}

/* ---- Block Tint Colors (design guide: each section has a tint from colorScheme) ---- */
/* Light mode tintStrength=0: icon color + subtle border only */
.block-tint-error    .block-icon { color: var(--error); }
.block-tint-tertiary .block-icon { color: var(--tertiary); }
.block-tint-primary  .block-icon { color: var(--primary); }
.block-tint-secondary .block-icon { color: var(--secondary); }
.block-tint-outline  .block-icon { color: var(--outline); }

.block-tint-error    { border-left: 2.5px solid rgba(186, 26, 26, 0.35); }
.block-tint-tertiary { border-left: 2.5px solid rgba(123, 86, 48, 0.35); }
.block-tint-primary  { border-left: 2.5px solid rgba(156, 39, 81, 0.35); }
.block-tint-secondary { border-left: 2.5px solid rgba(116, 86, 91, 0.35); }
.block-tint-outline  { border-left: 2.5px solid rgba(133, 115, 120, 0.35); }

/* Dark mode tintStrength=0.35:
   Calculated as lerp(surfaceContainerLowest #140C0D, tintContainer, 0.35) @ 0.85 alpha
   error-container  #93000A → lerp → #40080C
   tertiary-container #613F17 → lerp → #2F1E10
   primary-container  #7D0038 → lerp → #39081C
   secondary-container #5A3F44 → lerp → #2D1E20
   outline #534247 → lerp → #2A1F21 */
@media (prefers-color-scheme: dark) {
  .block-tint-error    { background: rgba(64, 8, 12, 0.85);  border-left-color: rgba(255, 180, 171, 0.2); }
  .block-tint-tertiary { background: rgba(47, 30, 16, 0.85); border-left-color: rgba(239, 190, 144, 0.2); }
  .block-tint-primary  { background: rgba(57, 8, 28, 0.85);  border-left-color: rgba(255, 177, 197, 0.2); }
  .block-tint-secondary { background: rgba(45, 30, 32, 0.85); border-left-color: rgba(229, 189, 194, 0.2); }
  .block-tint-outline  { background: rgba(42, 31, 33, 0.85); border-left-color: rgba(160, 132, 136, 0.2); }
}

/* ---- Collapsible Block ---- */
.block {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  border: none;
  background: transparent;
  border-radius: 28px;
  transition: background 0.15s;
  width: 100%;
  text-align: left;
  font-family: 'Roboto', sans-serif;
}

.block-header:hover {
  background: rgba(32, 26, 27, 0.04);
}

.block-header .ms {
  font-size: 18px;
  color: var(--on-surface-variant);
}

/* block-icon is the leading icon — inherits tint color when parent has block-tint-* */
.block-icon {
  font-size: 18px;
  color: var(--on-surface-variant);
}

.block-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface);
  flex: 1;
  text-align: left;
}

.block-badge {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: 50px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.block-badge-error {
  background: var(--error-container);
  color: var(--on-error-container);
}

.block-trailing {
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
  white-space: nowrap;
}

.block-chevron {
  font-size: 18px !important;
  color: var(--on-surface-variant) !important;
  transition: transform 0.2s ease;
}

.block-chevron.collapsed {
  transform: rotate(-90deg);
}

.block-content {
  padding: 0 16px 14px;
}

/* ---- Home Grid ---- */
.home-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.home-row {
  display: flex;
  gap: 10px;
}

.flex-3 { flex: 3; min-width: 0; }
.flex-2 { flex: 2; min-width: 0; }
.flex-1 { flex: 1; min-width: 0; }

/* ---- Metrics Block ---- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.metric-card .ms {
  font-size: 22px;
}

.metric-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--on-surface);
  line-height: 1;
}

.metric-label {
  font-size: 11px;
  color: var(--on-surface-variant);
}

.metric-primary .ms { color: var(--primary); }
.metric-tertiary .ms { color: var(--tertiary); }
.metric-secondary .ms { color: var(--secondary); }
.metric-outline .ms { color: var(--outline); }

/* ---- List Items ---- */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
}

.list-item + .list-item {
  border-top: 1px solid rgba(133, 115, 120, 0.25);
}

.list-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.list-icon .ms {
  font-size: 17px;
}

.list-icon-error {
  background: var(--error-container);
  color: var(--on-error-container);
}

.list-icon-primary {
  background: var(--primary-container);
  color: var(--on-primary-container);
}

.list-icon-secondary {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

.list-main {
  flex: 1;
  min-width: 0;
}

.list-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-subtitle {
  font-size: 11px;
  color: var(--on-surface-variant);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-chevron {
  font-size: 16px !important;
  color: var(--on-surface-variant) !important;
  flex-shrink: 0;
}

/* ---- Form Badge ---- */
.form-type-badge {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---- Trend Block ---- */
.trend-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.trend-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.trend-sub {
  font-size: 12px;
  color: var(--on-surface-variant);
}

.sparkline-wrap {
  width: 100%;
}

.sparkline-wrap svg {
  width: 100%;
  height: 52px;
  display: block;
  overflow: visible;
}

.sparkline-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
}

.sparkline-lbl {
  font-size: 10px;
  color: var(--on-surface-variant);
  flex: 1;
  text-align: center;
}

/* ---- Activity Feed ---- */
.activity-row {
  display: grid;
  grid-template-columns: 44px auto 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 4px 0;
}

.activity-row + .activity-row {
  border-top: 1px solid rgba(133, 115, 120, 0.15);
}

.activity-time {
  font-size: 11px;
  color: var(--on-surface-variant);
  white-space: nowrap;
}

.activity-who {
  font-size: 12px;
  white-space: nowrap;
}

.activity-who strong {
  font-weight: 700;
  color: var(--on-surface);
}

.activity-who span {
  color: var(--on-surface-variant);
}

.activity-target {
  font-size: 12px;
  color: var(--on-surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Project stats ---- */
.proj-stats {
  display: flex;
  gap: 12px;
  margin-top: 2px;
}

.proj-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--on-surface-variant);
}

.proj-stat .ms {
  font-size: 13px;
}
