/* ==========================================================================
   KALLYSOFT MATERIAL DESIGN SYSTEM
   Core Stylesheet - Version 2.0 (Design Token Architecture)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS (VARIABLES)
   -------------------------------------------------------------------------- */
:root {
  /* ===========================
     REF PALETTE (Primitives)
     =========================== */
  /* Neutral Palette */
  --ref-palette-white: #ffffff;
  --ref-palette-black: #000000;
  
  --ref-palette-neutral-50:  #f8fafc;
  --ref-palette-neutral-100: #f1f5f9;
  --ref-palette-neutral-200: #e2e8f0;
  --ref-palette-neutral-300: #cbd5e1;
  --ref-palette-neutral-400: #94a3b8;
  --ref-palette-neutral-500: #64748b;
  --ref-palette-neutral-600: #475569;
  --ref-palette-neutral-700: #334155;
  --ref-palette-neutral-800: #1e293b;
  --ref-palette-neutral-900: #0f172a;

  /* Primary Palette (Blue) */
  --ref-palette-primary-50:  #eff6ff;
  --ref-palette-primary-100: #dbeafe;
  --ref-palette-primary-200: #bfdbfe;
  --ref-palette-primary-400: #60a5fa;
  --ref-palette-primary-500: #3b82f6;
  --ref-palette-primary-600: #2563eb;
  --ref-palette-primary-700: #1d4ed8;
  --ref-palette-primary-800: #1e40af;
  --ref-palette-primary-900: #1e3a8a;

  /* Functional Palettes */
  --ref-palette-error-50:  #fef2f2;
  --ref-palette-error-100: #fee2e2;
  --ref-palette-error-600: #dc2626;
  --ref-palette-error-700: #b91c1c;

  --ref-palette-success-50:  #f0fdf4;
  --ref-palette-success-600: #16a34a;
  --ref-palette-success-700: #15803d;

  --ref-palette-warning-50:  #fffbeb;
  --ref-palette-warning-100: #fef3c7;
  --ref-palette-warning-600: #d97706;

  /* ===========================
     SYS TOKENS (Functional)
     =========================== */
  
  /* --- Color: Primary --- */
  --sys-color-primary: var(--ref-palette-primary-600);
  --sys-color-on-primary: var(--ref-palette-white);
  --sys-color-primary-container: var(--ref-palette-primary-100);
  --sys-color-on-primary-container: var(--ref-palette-primary-900);
  --sys-color-primary-inverse: var(--ref-palette-primary-400);

  /* --- Color: Surface & Background --- */
  --sys-color-background: #F0F6FF; 
  --sys-color-on-background: var(--ref-palette-neutral-900);
  
  --sys-color-surface: var(--ref-palette-white);
  --sys-color-on-surface: var(--ref-palette-neutral-800);
  --sys-color-on-surface-variant: var(--ref-palette-neutral-500); 
  
  --sys-color-surface-container: var(--ref-palette-neutral-50);
  --sys-color-surface-highlight: var(--ref-palette-neutral-100);

  /* --- Color: Outlines --- */
  --sys-color-outline: var(--ref-palette-neutral-200);
  --sys-color-outline-focus: var(--sys-color-primary);
  --sys-color-outline-variant: var(--ref-palette-neutral-300);

  /* --- Color: States (Functional) --- */
  --sys-color-success: var(--ref-palette-success-600);
  --sys-color-on-success: var(--ref-palette-white);
  --sys-color-success-container: var(--ref-palette-success-50);
  --sys-color-on-success-container: var(--ref-palette-success-700);

  --sys-color-error: var(--ref-palette-error-600);
  --sys-color-on-error: var(--ref-palette-white);
  --sys-color-error-container: var(--ref-palette-error-50);
  --sys-color-on-error-container: var(--ref-palette-error-700);

  --sys-color-warning: var(--ref-palette-warning-600);
  --sys-color-on-warning: var(--ref-palette-white);
  --sys-color-warning-container: var(--ref-palette-warning-50);
  --sys-color-on-warning-container: var(--ref-palette-warning-600);
  
  --sys-color-info-container: var(--ref-palette-primary-50);
  --sys-color-on-info-container: var(--ref-palette-primary-700);

  /* --- Elevation & Shadows --- */
  --sys-shadow-color: 0 0 0;
  --sys-shadow-opacity-sm: 0.05;
  --sys-shadow-opacity-md: 0.1;

  --sys-elevation-level-1: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --sys-elevation-level-2: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --sys-elevation-level-3: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --sys-elevation-hero: 0 20px 40px -10px rgba(37, 99, 235, 0.1);

  /* --- Shape --- */
  --sys-shape-corner-xs: 4px;
  --sys-shape-corner-sm: 8px;
  --sys-shape-corner-md: 16px;
  --sys-shape-corner-lg: 24px;
  --sys-shape-corner-full: 9999px;

  /* --- Typography & Layout --- */
  --sys-typescale-body-font: 'Inter', system-ui, -apple-system, sans-serif;
  --sys-layout-max-width: 1024px;
  --sys-layout-nav-height: 80px;

  /* --- Z-Index Layers --- */
  --sys-z-nav: 100;
  --sys-z-scrim: 200;
  --sys-z-popover: 300;
  --sys-z-modal: 1000;
  --sys-z-toast: 2000;

  /* === COMPATIBILITY BINDINGS === */
  --color-primary: var(--sys-color-primary);
  --color-primary-hover: var(--ref-palette-primary-700);
  --color-primary-light: var(--ref-palette-primary-50);
  --text-main: var(--sys-color-on-surface);
  --text-muted: var(--sys-color-on-surface-variant);
  --bg-surface: var(--sys-color-surface);
  --bg-subtle: var(--sys-color-surface-container);
  --bg-highlight: var(--sys-color-surface-highlight);
  --border: var(--sys-color-outline);
}

/* --------------------------------------------------------------------------
   2. RESET & BASE
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'Material Symbols Outlined';
  font-style: normal;
  src: url('../fonts/MaterialSymbolsOutlined.woff2') format('woff2');
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
}

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

html {
  scrollbar-gutter: stable;
}

body {
  font-family: var(--sys-typescale-body-font);
  background-color: var(--sys-color-background);
  background-image: radial-gradient(circle at 10% 10%, rgba(225, 235, 255, 1) 0%, rgba(240, 246, 255, 1) 100%);
  background-attachment: fixed;
  color: var(--sys-color-on-background);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   3. TYPOGRAPHY
   -------------------------------------------------------------------------- */
h1, .h1 {
  font-size: 3.5rem;
  line-height: 1.1;
  font-weight: 800;
  color: var(--sys-color-on-surface);
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

h2, .h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--sys-color-on-surface);
}

h3, .h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--ref-palette-neutral-900);
}

h4, .h4 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--sys-color-on-surface);
}

h5, .h5 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--sys-color-on-surface);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

h6, .h6 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--sys-color-on-surface-variant);
}

p {
  color: var(--sys-color-on-surface-variant);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.text-small { font-size: 0.875rem; }
.text-tiny  { font-size: 0.75rem; }
.text-large { font-size: 1.125rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.text-primary { color: var(--sys-color-primary); }
.text-muted { color: var(--sys-color-on-surface-variant); }
.text-success { color: var(--sys-color-success); }
.text-error { color: var(--sys-color-error); }
.text-warning { color: var(--sys-color-warning); }

/* --------------------------------------------------------------------------
   4. LAYOUT & NAVIGATION
   -------------------------------------------------------------------------- */
.top-nav {
  padding: 0 40px;
  background: var(--sys-color-surface);
  box-shadow: var(--sys-elevation-level-1);
  position: sticky;
  top: 0;
  z-index: var(--sys-z-nav);
  height: var(--sys-layout-nav-height);
  display: flex;
  align-items: center;
}

.nav-container {
  max-width: var(--sys-layout-max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-link {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--sys-color-on-surface-variant);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--sys-shape-corner-sm);
  transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
  color: var(--sys-color-primary);
  background: var(--sys-color-surface-container);
}

.nav-actions {
  display: flex;
  align-items: center;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 24px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--sys-color-on-surface-variant);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.brand-icon {
  font-size: 24px;
  color: var(--sys-color-on-surface);
  cursor: pointer;
}

.brand-text {
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--sys-shape-corner-sm);
  transition: all 0.2s;
}

.brand-text:hover {
  color: var(--sys-color-primary);
  background: var(--sys-color-surface-container);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  gap: 40px;
  width: 100%;
}

main > section {
    width: 100%;
    display: flex;
    justify-content: center;
}

.ui-container {
    width: 100%;
    max-width: var(--sys-layout-max-width);
    margin: 0 auto;
}

.dashboard-container {
    width: 100%;
    max-width: var(--sys-layout-max-width);
    margin: 0 auto;
}

.ui-section { margin-bottom: 60px; }
.section-header { margin-bottom: 24px; }


/* --------------------------------------------------------------------------
   5. COMPONENT ARCHITECTURE (Material Like)
   -------------------------------------------------------------------------- */

/* --- Buttons --- */
button {
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 16px;
  border-radius: var(--sys-shape-corner-sm);
  transition: all 0.2s;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background-color: var(--sys-color-primary);
  color: var(--sys-color-on-primary);
  box-shadow: var(--sys-elevation-level-2);
  padding: 12px 24px;
  border-radius: var(--sys-shape-corner-full);
}

.btn-primary:hover {
  background-color: var(--ref-palette-primary-700);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--sys-color-primary-container);
  color: var(--sys-color-primary);
  border: 1px solid var(--ref-palette-primary-200);
  padding: 12px 24px;
  border-radius: var(--sys-shape-corner-full);
}

.btn-secondary:hover {
  background-color: var(--ref-palette-primary-200);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--sys-color-outline-variant);
  color: var(--sys-color-on-surface-variant);
  padding: 8px 20px;
  border-radius: var(--sys-shape-corner-full);
}

.btn-outline:hover {
  border-color: var(--sys-color-primary);
  color: var(--sys-color-primary);
  background: var(--sys-color-surface-container);
}

/* Legacy mapped buttons for convenience */
.btn-filled { @extend .btn-primary; background-color: var(--sys-color-primary); color: var(--sys-color-on-primary); }
.btn-outlined { @extend .btn-outline; border: 1px solid var(--sys-color-outline); color: var(--sys-color-primary); }
.btn-text { background: transparent; color: var(--sys-color-primary); }
.btn-text:hover { background: var(--sys-color-surface-container); }

.btn-icon {
  background: transparent;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  line-height: 1;
  color: var(--sys-color-on-surface);
  border: 1px solid transparent;
}
.btn-icon:hover { background-color: var(--sys-color-surface-container); }

/* --- Cards --- */
.card {
  background: var(--sys-color-surface);
  padding: var(--sys-shape-corner-lg);
  border-radius: var(--sys-shape-corner-lg);
  border: 1px solid var(--sys-color-outline);
  box-shadow: var(--sys-elevation-level-1);
}

.card.card-nopadding {
    padding: 0;
}

/* --- Hero Section --- */
.hero-section {
    width: 100%;
}

/* --- Page Header (Universal Component) --- */
.page-header {
  background: radial-gradient(circle at top right, var(--ref-palette-primary-50) 0%, var(--sys-color-surface) 60%);
  border-radius: var(--sys-shape-corner-lg);
  padding: 40px;
  box-shadow: var(--sys-elevation-level-1);
  display: flex;
  justify-content: space-between;
  align-items: center; /* Vertically center status card */
  gap: 40px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--sys-color-outline);
  width: 100%;
  box-sizing: border-box;
}

.page-header-content {
    flex: 1;
}

.page-header h1 {
    font-size: 2.25rem; /* Smaller than global H1 */
    margin-bottom: 12px;
    line-height: 1.2;
}

.page-header p {
    font-size: 1rem;
    color: var(--sys-color-on-surface-variant);
    margin-bottom: 0;
}

/* Status Card inside Header */
.header-status-card {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  padding: 24px;
  border-radius: var(--sys-shape-corner-md);
  width: 300px;
  border: 1px solid var(--sys-color-surface-highlight);
  box-shadow: var(--sys-elevation-level-2);
  z-index: 2;
  flex-shrink: 0;
}

.hero-card {
    /* Legacy / Deprecated - use .page-header */
    display: none; 
}

.info-card {
  background: var(--sys-color-surface);
  padding: 24px;
  border-radius: var(--sys-shape-corner-md);
  box-shadow: var(--sys-elevation-level-1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 180px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.info-card:hover { transform: translateY(-4px); box-shadow: var(--sys-elevation-level-2); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  width: 100%;
  box-sizing: border-box;
}

/* --- Status/Stats --- */
.hero-status-card { /* Legacy map */
    @extend .header-status-card;
}

.status-badge-blue {
  background: var(--sys-color-primary-container);
  color: var(--sys-color-on-primary-container);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
}

.status-badge {
    display: inline-flex;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}
.status-badge-pill {
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
}
.status-badge.new { background: var(--sys-color-primary-container); color: var(--sys-color-on-primary-container); }
.status-badge.success { background: var(--sys-color-success-container); color: var(--sys-color-on-success-container); }
.status-badge.warning { background: var(--sys-color-warning-container); color: var(--sys-color-on-warning-container); }
.status-badge.error { background: var(--sys-color-error-container); color: var(--sys-color-on-error-container); }
.status-badge.inactive { background: var(--sys-color-surface-container); color: var(--sys-color-on-surface-variant); }

.status-value {
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 24px;
  color: var(--sys-color-on-surface);
}

/* --- Alerts --- */
.alert {
    padding: 16px;
    border-radius: var(--sys-shape-corner-md);
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
}
.alert-title { font-weight: 600; display: block; margin-bottom: 2px; }
.alert.info { background: var(--sys-color-info-container); border: 1px solid var(--ref-palette-primary-200); color: var(--sys-color-on-info-container); }
.alert.success { background: var(--sys-color-success-container); border: 1px solid var(--sys-color-success); color: var(--sys-color-on-success-container); }
.alert.warning { background: var(--sys-color-warning-container); border: 1px solid var(--sys-color-warning); color: var(--sys-color-on-warning-container); }
.alert.error { background: var(--sys-color-error-container); border: 1px solid var(--sys-color-error); color: var(--sys-color-on-error-container); }

/* --- Forms & Inputs --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-bottom: 1rem;
}

.input-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--sys-color-on-surface-variant);
}

.input-text, .input-select, textarea {
  padding: 10px 14px;
  border: 1px solid var(--sys-color-outline);
  border-radius: var(--sys-shape-corner-sm);
  background: var(--sys-color-surface);
  color: var(--sys-color-on-surface);
  font-size: 0.95rem;
  transition: all 0.15s;
  width: 100%;
  font-family: inherit;
}

.input-text:focus, .input-select:focus {
  outline: none;
  border-color: var(--sys-color-primary);
  box-shadow: 0 0 0 3px var(--sys-color-primary-container);
}

/* Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.95rem;
    color: var(--sys-color-on-surface);
    min-height: 24px;
}
.checkbox-container input {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--sys-color-primary);
    cursor: pointer;
    margin: 0;
}

.checkbox-group {
    display: flex;
    flex-direction: row; 
    align-items: center; 
    gap: 16px;
}

/* Radio */
.radio-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.95rem;
  color: var(--sys-color-on-surface);
  min-height: 24px;
}

.radio-container input[type="radio"] {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--sys-color-primary);
  cursor: pointer;
  margin: 0;
}

.radio-group {
    display: flex;
    flex-direction: row; 
    align-items: center; 
    gap: 16px;
}

/* Switch Component */
.switch-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.95rem;
  color: var(--sys-color-on-surface);
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: -4px;
  bottom: 0;
  background-color: var(--sys-color-outline-variant); 
  transition: .4s;
  border-radius: 34px;
  border: 2px solid transparent; 
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 2px;
  background-color: var(--ref-palette-white); 
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--sys-color-primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: var(--ref-palette-white);
}

/* Search */
.search-component {
    position: relative;
    max-width: 400px;
    width: 100%;
}
.search-component .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sys-color-on-surface-variant);
    pointer-events: none;
}
.search-component .input-search {
    padding-left: 40px;
    padding-right: 16px;
    border-radius: var(--sys-shape-corner-md);
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    align-items: center;
}
.filter-bar .input-group { margin-bottom: 0; }

.search-column {
    display: flex;
    align-items: flex-end;
    flex: 0 0 auto;
    gap: 24px;
}

.filters-column {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 24px;
}

.flex-grow-1 {
    flex-grow: 1;
}


/* --------------------------------------------------------------------------
   6. WEB COMPONENTS & COMPLEX UI
   -------------------------------------------------------------------------- */

/* --- Date Range Picker (Styled via Layout Parts) --- */
date-range-picker {
    display: inline-block;
    width: 220px;
}

/* Trigger Button */
date-range-picker::part(trigger) {
    background-color: var(--sys-color-surface);
    border: 1px solid var(--sys-color-outline);
    border-radius: var(--sys-shape-corner-sm);
    padding: 10px 14px;
    color: var(--sys-color-on-surface);
    font-size: 0.95rem; /* Match input size */
    transition: all 0.15s;
    width: 100%;
    justify-content: space-between;
}

date-range-picker::part(trigger):hover {
    border-color: var(--sys-color-on-surface-variant);
}

/* Icons */
date-range-picker::part(icon), 
date-range-picker::part(icon-chevron) {
    color: var(--sys-color-on-surface-variant);
}

/* Popover Modal */
date-range-picker::part(popover) {
    background: var(--sys-color-surface);
    border: 1px solid var(--sys-color-outline);
    border-radius: var(--sys-shape-corner-md);
    box-shadow: var(--sys-elevation-level-3);
    padding: 12px;
    margin-top: 4px;
    animation: fadeIn 0.1s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Calendar Header */
date-range-picker::part(month-label) {
    font-weight: 600;
    color: var(--sys-color-on-surface);
    font-size: 0.9rem;
}

date-range-picker::part(nav-button) {
    color: var(--sys-color-on-surface-variant);
    border: 1px solid transparent; /* Cleaner look */
    border-radius: 6px;
    padding: 4px;
    cursor: pointer;
    background: transparent;
}

date-range-picker::part(nav-button):hover {
    background-color: var(--sys-color-surface-container);
    color: var(--sys-color-primary);
}

/* Calendar Grid */
date-range-picker::part(weekday) {
    color: var(--sys-color-on-surface-variant);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    padding-bottom: 8px;
    text-align: center;
}

date-range-picker::part(day) {
    font-size: 0.8rem;
    color: var(--sys-color-on-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

date-range-picker::part(day other-month) {
    color: var(--sys-color-outline-variant);
}

/* Selection States */
date-range-picker::part(selected) {
    background-color: var(--sys-color-primary);
    color: var(--sys-color-on-primary);
}

date-range-picker::part(in-range) {
    background-color: var(--sys-color-primary-container);
    color: var(--sys-color-primary);
    border-radius: 0;
}

/* --- Data Tables (Enhanced) --- */
.flex-table {
  background: var(--sys-color-surface);
  border-radius: var(--sys-shape-corner-lg);
  box-shadow: var(--sys-elevation-level-1);
  overflow: hidden;
  border: 1px solid var(--sys-color-outline);
  display: flex;
  flex-direction: column;
  margin-bottom: 24px;
}

.flex-table.table-flush {
    box-shadow: none;
    border-radius: 0;
    margin-bottom: 0;
    border: none;
}

.table-header {
  display: flex;
  padding: 12px 24px;
  background: var(--sys-color-surface-container);
  border-bottom: 1px solid var(--sys-color-outline);
  font-weight: 600;
  color: var(--sys-color-on-surface-variant);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Project Section/Grouping */
.project-section {
  border-bottom: 1px solid var(--sys-color-outline);
}

.project-section:last-child {
  border-bottom: none;
}

.project-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background-color: var(--sys-color-surface-container);
  border-bottom: 1px dashed var(--sys-color-outline);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}

.project-header-row:hover {
    background-color: var(--sys-color-surface-highlight);
}

/* Project Collapsing Logic */
.project-section .table-group {
    display: block;
}

.project-section.collapsed .table-group {
    display: none;
}

.project-header-row .chevron {
    transition: transform 0.2s;
    margin-right: 0.5rem;
    font-size: 1.25rem;
    color: var(--sys-color-on-surface-variant);
}

.project-section.collapsed .project-header-row .chevron {
    transform: rotate(-90deg);
}

.project-title h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--sys-color-on-surface);
}
.project-meta {
    font-size: 0.85rem;
    color: var(--sys-color-on-surface-variant);
}

/* Table Group (Expandable) */
.table-group {
    border-bottom: 1px solid var(--sys-color-outline);
    background-color: var(--sys-color-surface);
}
.table-group:last-child {
    border-bottom: none;
}

.table-row {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  transition: background-color 0.2s;
  border-left: 3px solid transparent; 
  text-decoration: none;
  color: inherit;
  min-height: 56px;
  cursor: pointer;
}

.table-row:hover {
  background-color: var(--sys-color-surface-highlight); 
}

/* Active/Expanded State on Row */
.table-row.active-row, 
.table-row.active, 
.table-group.expanded .table-row {
  background-color: var(--sys-color-primary-container); 
  border-left-color: var(--sys-color-primary);
}

/* Columns */
.col {
  flex: 1;
  padding: 0 8px;
  display: flex;
  align-items: center;
}
.col:first-child { padding-left: 0; }
.col:last-child { padding-right: 0; }
.col.grow { flex-grow: 1; }

.col.col-narrow { flex: 0 0 60px; justify-content: center; } 
.col.col-date { flex: 0 0 140px; color: var(--sys-color-on-surface-variant); font-size: 0.9em; }
.col.col-hours { flex: 0 0 100px; font-family: monospace; font-size: 1.1em; color: var(--sys-color-on-surface); }
.col.col-status { flex: 0 0 120px; justify-content: center; }
.col.col-person { flex: 0 0 100px; }
.col.col-subproject { flex: 1; color: var(--sys-color-on-surface-variant); min-width: 150px; }

/* Align Status Icon exactly with Action Buttons */
.col.col-status .material-symbols-outlined {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px; 
    width: 40px;
}

.col.col-task { flex: 1; font-weight: 500; color: var(--sys-color-on-surface); min-width: 150px; }
.col.col-desc { flex: 2; display: flex; min-width: 200px; color: var(--sys-color-on-surface-variant); }
.col.col-actions { flex: 0 0 80px; display: flex; justify-content: flex-end; gap: 8px; }
.col.col-small-icon { flex: 0 0 40px; justify-content: flex-end; }

/* Truncation Helpers */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  max-height: 2.8em;
  color: var(--sys-color-on-surface-variant);
}

/* Detail View (Grid Animation) */
.table-detail-view {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease-out, background-color 0.3s, opacity 0.3s ease-out, visibility 0.3s;
  background-color: var(--sys-color-surface-highlight); 
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  margin-top: -1px; /* Hack: Hide any sub-pixel rendering gaps */
  padding: 0 !important;
  border: none !important;
}

.table-detail-view.open,
.table-group.expanded .table-detail-view {
  grid-template-rows: 1fr;
  opacity: 1;
  visibility: visible;
  margin-top: 0;
}

.detail-content-wrapper {
    overflow: hidden;
    /* Removed padding/border from here to fix collapse height */
    min-height: 0;
}

/* Detail Grid Layout */
.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 24px 24px 24px;
  border-top: 1px dashed var(--sys-color-outline);
}

.detail-item .label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sys-color-on-surface-variant);
  margin-bottom: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-item p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--sys-color-on-surface);
  background: var(--sys-color-surface);
  padding: 16px;
  border-radius: var(--sys-shape-corner-sm);
  border: 1px solid var(--sys-color-outline);
}

.detail-actions {
  padding: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 16px;
}

/* Icon Rotation for Details */
.expand-icon span,
.table-detail-button {
  transition: transform 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.table-detail-button.open,
.table-group.expanded .col-small-icon span, 
.table-group.expanded .expand-icon span {
    transform: rotate(180deg);
}


/* --- Accordion (Details & Summary) --- */
details.accordion, 
details.activity-detail { /* alias for compatibility */
  border: 1px solid var(--sys-color-outline);
  border-radius: var(--sys-shape-corner-md);
  margin-bottom: 16px;
  background-color: var(--sys-color-surface);
  transition: all 0.3s ease;
  overflow: hidden;
}

details.accordion[open],
details.activity-detail[open] {
  border-color: var(--sys-color-primary); 
  box-shadow: 0 4px 12px rgba(37,99,235,0.08);
}

details.accordion summary,
details.activity-detail summary {
  padding: 16px 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  position: relative;
  background-color: var(--sys-color-surface);
  transition: background-color 0.2s;
}

details.accordion summary::-webkit-details-marker,
details.activity-detail summary::-webkit-details-marker {
  display: none;
}

details.accordion summary:hover,
details.activity-detail summary:hover {
  background-color: var(--sys-color-surface-highlight);
}

details.accordion summary::after,
details.activity-detail summary::after {
  content: 'expand_more';
  font-family: 'Material Symbols Outlined';
  font-size: 24px;
  transition: transform 0.3s ease;
  color: var(--sys-color-on-surface-variant);
}

details.accordion[open] summary::after,
details.activity-detail[open] summary::after {
  transform: rotate(180deg);
  color: var(--sys-color-primary);
}

details.accordion[open] summary,
details.activity-detail[open] summary {
  border-bottom: 1px solid var(--sys-color-outline);
  background-color: var(--sys-color-primary-container);
}

/* Summary Content Layout */
.summary-content {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.summary-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-info strong {
  color: var(--sys-color-on-surface);
  font-size: 1rem;
}

.meta-text, .meta-date {
  color: var(--sys-color-on-surface-variant);
  font-size: 0.875rem;
}

.detail-content {
  padding: 24px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-row {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sys-color-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Popovers & Menus --- */
.popover-menu {
  padding: 8px 0;
  margin: 0;
  background-color: var(--sys-color-surface);
  border-radius: var(--sys-shape-corner-md);
  box-shadow: var(--sys-elevation-level-2);
  border: 1px solid var(--sys-color-outline);
  min-width: 200px;
  z-index: var(--sys-z-popover);
  
  /* Anchor Positioning */
  position: absolute;
  top: anchor(bottom);
  left: anchor(center);
  translate: -50% 8px;
  position-try-options: flip-block, flip-inline;
  
  /* Transition/Animation */
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease-out, transform 0.2s ease-out, display 0.2s allow-discrete;
}

.popover-menu:popover-open {
  opacity: 1;
  transform: translateY(0);
}

@starting-style {
  .popover-menu:popover-open {
      opacity: 0;
      transform: translateY(-8px);
  }
}

.popover-menu.menu-right {
  left: auto;
  right: anchor(right);
  translate: 0 8px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--sys-color-on-surface);
  font-family: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s;
  text-decoration: none;
}

.menu-item .material-symbols-outlined {
  font-size: 20px;
  color: var(--sys-color-on-surface-variant);
}

.menu-item:hover {
  background-color: var(--sys-color-surface-container);
  color: var(--sys-color-primary);
}
.menu-item:hover .material-symbols-outlined {
  color: var(--sys-color-primary);
}

.menu-item.danger { color: var(--sys-color-error); }
.menu-item.danger .material-symbols-outlined { color: var(--sys-color-error); }
.menu-item.danger:hover { background-color: var(--sys-color-error-container); }

.menu-header {
    padding: 8px 20px;
    font-size: 0.75rem;
    color: var(--sys-color-on-surface-variant);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.menu-divider {
    height: 1px;
    background: var(--sys-color-outline);
    margin: 8px 0;
}

/* --- Dialogs --- */
dialog {
    border: none;
    border-radius: var(--sys-shape-corner-lg);
    box-shadow: var(--sys-elevation-level-3);
    background: var(--sys-color-surface);
    padding: 0;
    width: 100%;
    max-width: 480px;
    margin: auto;
    color: var(--sys-color-on-surface);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}

.dialog-header { 
    padding: 32px 32px 16px; 
    position: relative; 
    text-align: left;
}

.dialog-close-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--sys-color-on-surface-variant);
    cursor: pointer;
    border-radius: 50%;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.dialog-close-icon:hover {
    background-color: var(--sys-color-surface-container);
    color: var(--sys-color-on-surface);
}

.dialog-title { 
    font-size: 1.5rem; 
    font-weight: 700; 
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    color: var(--sys-color-on-surface);
}

.dialog-title .material-symbols-outlined {
    font-size: 28px;
    color: var(--sys-color-primary);
}

.dialog-subtitle {
    font-size: 0.95rem;
    color: var(--sys-color-on-surface-variant);
    margin: 0;
}

.dialog-body { padding: 0 32px 32px; display: flex; flex-direction: column; gap: 20px; }

.dialog-footer { 
    padding: 24px 32px; 
    background: transparent; 
    display: flex; 
    justify-content: flex-end; 
    gap: 16px; 
    border-top: none; 
}

/* --- Snackbar --- */
.snackbar-container {
    position: fixed;
    z-index: var(--sys-z-toast);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
    width: 100%;
    bottom: 24px; left: 0;
}

.snackbar {
    background-color: var(--ref-palette-neutral-800);
    color: var(--ref-palette-white);
    box-shadow: var(--sys-elevation-level-3);
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-width: 280px;
    max-width: 400px;
    pointer-events: auto;
    padding: 12px 24px;
    border-radius: var(--sys-shape-corner-md);
}

.snackbar.success { background-color: var(--sys-color-success-container); color: var(--sys-color-on-success-container); border: 1px solid var(--sys-color-success); }
.snackbar.error { background: var(--sys-color-error-container); color: var(--sys-color-on-error-container); border: 1px solid var(--sys-color-error); }


/* --------------------------------------------------------------------------
   7. UTILITIES & HELPERS
   -------------------------------------------------------------------------- */
/* Layout */
.d-flex { display: flex; }
.d-flex-col { display: flex; flex-direction: column; }
.d-none { display: none !important; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }

/* Grid */
.grid { display: grid; gap: 24px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Spacing */
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }

.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mt-xl { margin-top: 40px; }

.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.mb-xl { margin-bottom: 40px; }

.p-sm { padding: 8px; }
.p-md { padding: 16px; }
.p-lg { padding: 24px; }

/* Backgrounds & Colors (Mapped to System Tokens) */
.bg-white { background: var(--sys-color-surface); }
.bg-subtle { background: var(--sys-color-surface-container); }

/* Explicit Overrides (using sys variables) */
.text-primary { color: var(--sys-color-primary); }
.text-muted { color: var(--sys-color-on-surface-variant); }
.text-success { color: var(--sys-color-success); }
.text-error { color: var(--sys-color-error); }
.text-warning { color: var(--sys-color-warning); }

.border-radius-sm { border-radius: var(--sys-shape-corner-sm); }
.border-radius-md { border-radius: var(--sys-shape-corner-md); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.hidden { display: none; }

/* --- Extended Utilities (Refactoring) --- */
.font-bold { font-weight: 700; }
.font-normal { font-weight: 400; }
.font-mono { font-family: 'Consolas', 'Monaco', monospace; }
.uppercase { text-transform: uppercase; }
.tracking-wider { letter-spacing: 0.05em; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-xl { font-size: 1.5rem; }

.min-w-100 { min-width: 100%; }
.min-w-200 { min-width: 200px; }

.pt-xl { padding-top: 40px; }
.pb-xl { padding-bottom: 40px; }
.p-0 { padding: 0 !important; }
.p-lg { padding: 24px; }

.mb-0 { margin-bottom: 0 !important; }
.mr-sm { margin-right: 8px; }
.ml-sm { margin-left: 8px; }
.mt-xxl { margin-top: 64px; }

.relative { position: relative; }
.opacity-50 { opacity: 0.5; }
.border-none { border: none !important; }

.divider-vertical {
  width: 1px;
  height: 40px;
  background: var(--sys-color-outline);
}

.icon-sm { font-size: 18px !important; }
.icon-xl { font-size: 64px !important; }

.code-block {
    border: 1px solid var(--sys-color-outline);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--sys-color-on-surface-variant);
}

/* --- Popover Anchors --- */
#btn-demo-1 { anchor-name: --anchor-demo-1; }
#menu-demo-1 { position-anchor: --anchor-demo-1; margin-top: 8px; }

#btn-demo-2 { anchor-name: --anchor-demo-2; }
#menu-demo-2 { position-anchor: --anchor-demo-2; margin-top: 8px; }

#btn-p1 { anchor-name: --anchor-p1; }
#menu-p1 { position-anchor: --anchor-p1; }

/* Projects Table Anchors */
#btn-p1-1 { anchor-name: --anchor-p1-1; }
#menu-p1-1 { position-anchor: --anchor-p1-1; margin-top: 4px; }

#btn-p1-2 { anchor-name: --anchor-p1-2; }
#menu-p1-2 { position-anchor: --anchor-p1-2; margin-top: 4px; }

#btn-p1-3 { anchor-name: --anchor-p1-3; }
#menu-p1-3 { position-anchor: --anchor-p1-3; margin-top: 4px; }

#btn-p2-1 { anchor-name: --anchor-p2-1; }
#menu-p2-1 { position-anchor: --anchor-p2-1; margin-top: 4px; }

#btn-p2-2 { anchor-name: --anchor-p2-2; }
#menu-p2-2 { position-anchor: --anchor-p2-2; margin-top: 4px; }


/* Responsive */
@media (max-width: 768px) {
  .nav-link:not(.active) {
      display: none;
  }
}

@media (max-width: 1024px) {
  .hero-card { flex-direction: column; padding: 40px; }
  .hero-status-card { width: 100%; }
  .grid-cols-3, .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  h1 { font-size: 2.5rem; }
  .card-grid { grid-template-columns: 1fr; }
  .grid-cols-2 { grid-template-columns: 1fr; }
  .table-header { display: none; }
  .table-row { flex-wrap: wrap; padding: 12px; height: auto; }
  .col { flex: 1 1 100%; padding: 4px 8px; }
}
