/* HHI VAULT — application styles.
   Design tokens live in tokens.css (single source of truth). */
@import url('./tokens.css');

/* Native window drag regions — the top of the sidebar and the header
   are draggable; interactive children opt out. */
.app-drag { -webkit-app-region: drag; }
.app-no-drag,
button,
a,
input,
select,
textarea,
.nav-link,
.btn,
.btn-icon { -webkit-app-region: no-drag; }

/* Reset & Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Accessibility: a consistent focus ring for keyboard users only */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 8px;
}
.btn:focus-visible,
.btn-icon:focus-visible,
.seg-btn:focus-visible,
.nav-link:focus-visible,
.profile-cell:focus-visible,
.popover-item:focus-visible {
  outline-offset: 1px;
}
.form-control:focus-visible,
.search-input:focus-visible,
.toolbar-search:focus-within {
  outline: 0;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.20);
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Tiny utility classes (so we can keep markup style-attribute-free) */
.is-hidden { display: none !important; }
.is-row    { display: flex; align-items: center; gap: 8px; }
.is-grow   { flex-grow: 1; }
.stack-sm  { display: flex; flex-direction: column; gap: 8px; }
.stack-md  { display: flex; flex-direction: column; gap: 16px; }
.muted     { color: var(--text-muted); }

/* Spacing utilities */
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mt-xl { margin-top: 32px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }

/* Action row at the right edge of a section header */
.actions-row { display: flex; gap: 8px; }

/* Grid override variants */
.grid-wide { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)) !important; gap: 18px !important; }

/* Card accents (replaces inline border-left styles) */
.is-emphasis-primary { box-shadow: inset 3px 0 0 var(--color-primary), var(--raised-shadow); }
.is-emphasis-success { box-shadow: inset 3px 0 0 var(--color-success), var(--raised-shadow); }

/* Tax disclaimer banner (was an inline-styled box) */
.tax-disclaimer {
  margin-top: 20px;
  padding: 14px 16px;
  background-color: var(--color-attention-light);
  border: 1px solid var(--hairline);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.tax-disclaimer svg { color: var(--color-attention); flex-shrink: 0; margin-top: 2px; }

/* Admin panel two-up card */
.admin-card {
  padding: 20px;
  min-height: 380px;
  display: flex;
  flex-direction: column;
}
.admin-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.admin-card p { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.admin-card .table-container { flex-grow: 1; overflow-y: auto; box-shadow: none; }
.actions-col { text-align: right; }

/* Modal scroll body */
.dialog-scroll {
  max-height: 62vh;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Tax live-preview block inside the subscription modal */
.live-calc {
  padding: 12px;
  background-color: var(--bg-hover);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.live-calc-title { font-weight: 600; color: var(--color-primary); }
.live-calc-row { display: flex; justify-content: space-between; }
.live-calc-total {
  font-weight: 600;
  border-top: 1px solid var(--hairline);
  padding-top: 6px;
  margin-top: 2px;
}
.field-hint { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.spacer-xl-bottom { margin-bottom: 32px; }
.viewer-body { display: flex; justify-content: center; align-items: center; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
  /* Native typography rendering on Mac/Win */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Platform-specific shell spacing.
   Mac: vibrant sidebar appearance + traffic-light clearance.
   Win: room for the titleBarOverlay window controls. */
[data-platform="darwin"] #sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--hairline, var(--border-color));
  padding-top: 44px;
}
[data-platform="darwin"] header {
  background-color: transparent;
  min-height: 52px;
}
[data-platform="win32"] header {
  padding-right: 156px; /* clear min/max/close overlay buttons */
  min-height: 44px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Main Layout */
#sidebar {
  width: 240px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 22px 14px 18px;
  flex-shrink: 0;
  z-index: 10;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

#main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  position: relative;
}

/* Brand Section */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  margin-bottom: 22px;
  color: var(--text-primary);
}
.brand-mark {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--text-primary);
}
.brand-mark .accent { fill: var(--color-primary); }
.brand-name {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}
.brand-name .kicker {
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

/* Nav Menu — macOS Finder-style soft selection */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  flex-grow: 1;
}

.nav-item { width: 100%; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.nav-link svg {
  width: 16px;
  height: 16px;
  opacity: 0.8;
  flex-shrink: 0;
}
.nav-link:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}
.nav-link.active {
  background-color: var(--nav-selected-bg);
  color: var(--nav-selected-fg);
}
.nav-link.active svg { opacity: 1; }

/* Sidebar section divider label */
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  padding: 12px 10px 4px;
}

/* Sidebar Header — profile cell at the top that opens the popover */
.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--hairline);
}
.profile-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-primary);
  text-align: left;
  font: inherit;
  transition: background-color var(--transition-fast);
}
.profile-cell:hover { background-color: var(--bg-hover); }
.profile-cell .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), #6ab1ff);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-cell .meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.profile-cell .meta-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-cell .meta-role {
  font-size: 11px;
  color: var(--text-muted);
}
.profile-cell .more {
  margin-left: auto;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Toolbar (unified header) */
header {
  height: 56px;
  border-bottom: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(0, 380px) auto;
  align-items: center;
  gap: 20px;
  padding: 0 22px;
  background-color: var(--bg-sidebar);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
  flex-shrink: 0;
}

.header-title h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

/* Toolbar global search */
.toolbar-search {
  position: relative;
  display: flex;
  align-items: center;
  height: var(--control-h-md);
  background-color: var(--bg-input);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--text-secondary);
}
.toolbar-search:focus-within {
  border-color: var(--color-primary);
  background-color: var(--bg-card);
}
.toolbar-search svg { flex-shrink: 0; opacity: 0.7; }
.toolbar-search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  padding: 0 8px;
}
.toolbar-search kbd {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 2px 5px;
}

/* Popover (anchored, click-outside dismiss) */
.popover {
  position: fixed;
  z-index: 200;
  min-width: 260px;
  max-width: 320px;
  background-color: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: var(--shadow-popover);
  padding: 8px;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.popover.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.popover-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}
.popover-section + .popover-section {
  border-top: 1px solid var(--hairline);
  padding-top: 6px;
  margin-top: 4px;
}
.popover-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 4px;
}
.popover-header .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}
.popover-header .role-line {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  color: var(--text-secondary);
}
.popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-primary);
  text-align: left;
  font: inherit;
  font-size: 13px;
  transition: background-color var(--transition-fast);
}
.popover-item:hover { background-color: var(--bg-hover); }
.popover-item svg { width: 14px; height: 14px; opacity: 0.75; flex-shrink: 0; }
.popover-item.is-danger { color: var(--color-danger); }

/* Base Buttons — macOS pill-style */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-h-md);
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast),
              box-shadow var(--transition-fast);
}

.btn-primary {
  background-color: var(--color-primary);
  color: #fff;
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.04), 0 1px 0 rgba(0,0,0,0.04);
}
.btn-primary:hover { background-color: var(--color-primary-hover); }

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--hairline);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background-color: var(--bg-hover); }
.btn-secondary.is-danger { color: var(--color-danger); }

.btn-icon {
  width: var(--control-h-md);
  height: var(--control-h-md);
  padding: 0;
  border-radius: 8px;
  background-color: var(--bg-card);
  border: 1px solid var(--hairline);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
  box-shadow: var(--shadow-sm);
}
.btn-icon:hover { background-color: var(--bg-hover); }
.btn-icon.is-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-icon.is-ghost:hover { background-color: var(--bg-hover); }

/* Container Views */
.view-panel {
  display: none;
  padding: 32px;
  animation: fadeIn 0.3s ease;
}
.view-panel.active {
  display: block;
}

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

/* Dashboard Widgets */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* Bento dashboard — hero + side stack + wide table */
.dashboard-bento {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  grid-template-areas:
    "hero side"
    "wide wide";
  gap: 16px;
  margin-bottom: 24px;
}
.bento-hero {
  grid-area: hero;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
}
.bento-side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.bento-wide {
  grid-area: wide;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bento-wide .section-header { margin-bottom: 0; }

.hero-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.hero-meta { display: flex; flex-direction: column; gap: 6px; }
.hero-meta .stat-value { font-size: 32px; }
.hero-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(10, 132, 255, 0.16);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hero-chart-wrap { display: flex; flex-direction: column; gap: 8px; }
.hero-chart-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
}
.hero-chart { position: relative; height: 92px; }
.hero-chart canvas { display: block; width: 100% !important; height: 100% !important; }

@media (max-width: 980px) {
  .dashboard-bento {
    grid-template-columns: 1fr;
    grid-template-areas: "hero" "side" "wide";
  }
  .bento-side { flex-direction: row; flex-wrap: wrap; }
  .bento-side .stat-card { flex: 1 1 200px; }
}

/* Surfaces */
.stat-card,
.surface {
  background-color: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--raised-shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card.is-hero {
  background-color: var(--accent-soft-bg);
  color: var(--accent-soft-fg);
}
.stat-title {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-weight: 600;
}
.stat-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* Sections & Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.section-header h2 {
  font-size: 20px;
  font-weight: 600;
}

/* Filters and Search controls */
.controls-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.search-input {
  flex-grow: 1;
  min-width: 240px;
  height: var(--control-h-md);
  background-color: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  box-shadow: var(--shadow-sm);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--color-primary); }
.filter-select {
  height: var(--control-h-md);
  background-color: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 0 32px 0 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none'%3E%3Cpath d='M2 4L5 7L8 4' stroke='%238e8e93' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* Tables — macOS list style */
.table-container {
  background-color: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--raised-shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background-color: transparent;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--hairline);
}

td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background-color: var(--bg-hover); }

/* Renewal timeline panel (Subscriptions view) */
.timeline-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--raised-shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.timeline-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.timeline-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}
.timeline-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.timeline-legend { display: flex; gap: 14px; }
.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}
.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}
.timeline-chart { position: relative; height: 180px; }
.timeline-chart canvas { display: block; width: 100% !important; height: 100% !important; }

/* Sticky table header inside any scrollable container */
.table-container { position: relative; }
.table-container thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: var(--bg-card);
}
.table-container thead th {
  background-color: var(--bg-card);
  backdrop-filter: blur(8px);
}

/* CSS empty state — appears when <tbody> has no row content */
.table-container:has(tbody:empty)::after {
  content: 'No items yet';
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.01em;
  border-top: 1px solid var(--hairline);
}

/* Card view for inventory */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.item-card {
  background-color: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--raised-shadow);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.item-img-container {
  height: 180px;
  background-color: var(--bg-hover);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.item-img-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.item-img-placeholder {
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.item-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-new {
  background-color: var(--color-success-light);
  color: var(--color-success);
}
.badge-used {
  background-color: var(--color-warning-light);
  color: var(--color-warning);
}

.item-details {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-grow: 1;
}

.item-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.item-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.item-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Command Palette (⌘K) */
dialog.palette {
  max-width: 580px;
  width: 92%;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0;
  border: 0;
  background: transparent;
  position: fixed;
}
dialog.palette::backdrop {
  background-color: rgba(0, 0, 0, 0.40);
  backdrop-filter: blur(10px);
}
@keyframes palette-in {
  from { opacity: 0; transform: translate(-50%, -8px) scale(0.98); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
dialog.palette[open] { animation: palette-in 0.16s cubic-bezier(0.2, 0, 0, 1); }

.palette-shell {
  background-color: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
}
.palette-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
  color: var(--text-secondary);
}
.palette-search svg { flex-shrink: 0; opacity: 0.7; }
.palette-search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  padding: 0;
}
.palette-search input::placeholder { color: var(--text-muted); }
.palette-search kbd {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-hover);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 2px 6px;
}

.palette-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 6px;
}
.palette-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  padding: 10px 12px 4px;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  text-align: left;
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.palette-item svg { flex-shrink: 0; opacity: 0.75; }
.palette-item .pal-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.palette-item .pal-title {
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-item .pal-sub {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-item .pal-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
}
.palette-item.is-active,
.palette-item:hover {
  background-color: var(--nav-selected-bg);
  color: var(--nav-selected-fg);
}
.palette-item.is-active .pal-title { color: var(--nav-selected-fg); }
.palette-empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.palette-foot {
  display: flex;
  gap: 18px;
  justify-content: flex-end;
  padding: 8px 18px;
  border-top: 1px solid var(--hairline);
  background-color: var(--bg-app);
  font-size: 11px;
  color: var(--text-muted);
}
.palette-foot kbd {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1px 5px;
  margin: 0 2px;
}

/* Native Dialog Styling */
dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 500px;
  width: 90%;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

.dialog-content {
  background-color: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
}
.dialog-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.form-control {
  background-color: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 8px 12px;
  height: var(--control-h-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast);
}
.form-control:focus { border-color: var(--color-primary); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { height: auto; min-height: 80px; padding: 10px 12px; }
select.form-control {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none'%3E%3Cpath d='M2 4L5 7L8 4' stroke='%238e8e93' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.file-dropzone {
  border: 1.5px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-fast),
              background-color var(--transition-fast),
              color var(--transition-fast);
  color: var(--text-secondary);
  font-size: 12px;
  background-color: transparent;
}
.file-dropzone:hover {
  border-color: var(--color-primary);
  background-color: var(--bg-hover);
}
.file-dropzone.is-dragging {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  border-style: solid;
}

.preview-container {
  margin-top: 8px;
  max-height: 120px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: none;
}
.preview-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--hairline);
  padding-top: 14px;
}
.dialog-footer .kbd-hint {
  margin-right: auto;
  font-size: 11px;
  color: var(--text-muted);
}
.dialog-footer .kbd-hint kbd {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-hover);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1px 5px;
  margin: 0 2px;
}

/* macOS-style dialog enter animation */
@keyframes dialog-in {
  from { opacity: 0; transform: translate(-50%, -54%) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
dialog[open] { animation: dialog-in 0.18s cubic-bezier(0.2, 0, 0, 1); }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
dialog[open]::backdrop { animation: backdrop-in 0.18s ease-out; }

/* Badge styles */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}
.badge-active {
  background-color: var(--color-success-light);
  color: var(--color-success);
}
.badge-renewal-soon {
  background-color: var(--color-attention-light);
  color: var(--color-attention);
}

/* Photo view modal styling */
.attachment-view {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-primary);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
}
.attachment-view:hover {
  text-decoration: underline;
}

.receipt-modal-content {
  max-width: 600px;
  width: 95%;
}
.receipt-modal-content img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
}
.receipt-modal-content iframe {
  width: 100%;
  height: 70vh;
  border: none;
}

/* Quick Alert Panel on Dashboard */
.alert-box {
  background-color: var(--color-attention-light);
  border: 1px solid var(--color-attention);
  color: var(--color-attention);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Active toggle styles */
.btn-icon.active {
  background-color: var(--color-primary) !important;
  color: white !important;
  border-color: var(--color-primary) !important;
}

/* Sync status pill (toolbar) */
.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--control-h-md);
  padding: 0 10px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--hairline);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  letter-spacing: 0.01em;
  user-select: none;
  cursor: default;
}
.sync-pill .sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-success);
  flex-shrink: 0;
}
.sync-pill.is-synced .sync-dot   { background: var(--color-success); }
.sync-pill.is-pending .sync-dot  {
  background: var(--color-attention);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
.sync-pill.is-offline .sync-dot  { background: var(--text-muted); }
.sync-pill.is-pending { color: var(--color-attention); }
.sync-pill.is-offline { color: var(--text-muted); }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}

/* macOS-style segmented control (used by the appearance switcher) */
.seg {
  display: inline-flex;
  padding: 2px;
  background-color: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  gap: 2px;
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.seg-btn:hover { color: var(--text-primary); }
.seg-btn.is-active {
  background-color: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.seg-btn svg { flex-shrink: 0; }

/* Print Styling for A4 */
@media print {
  @page {
    size: A4 portrait;
    margin: 15mm;
  }
  
  /* Reset background colors and text for readability on paper */
  body, html {
    background-color: #ffffff !important;
    color: #000000 !important;
    height: auto !important;
    overflow: visible !important;
    font-size: 11pt !important;
  }

  /* Hide navigation, sidebars, buttons, and modals */
  #sidebar,
  header,
  .controls-bar,
  dialog,
  .btn,
  .btn-primary,
  .btn-secondary,
  .btn-icon {
    display: none !important;
  }

  /* Expand main content to full width */
  #main-content {
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Force view panels to print properly */
  .view-panel {
    display: none !important;
    padding: 0 !important;
  }
  .view-panel.active {
    display: block !important;
  }

  /* Hide table action columns */
  th.actions-col,
  td:has(button),
  td button,
  table th:last-child,
  table td:last-child {
    display: none !important;
  }

  /* Table styles for printing */
  .table-container {
    box-shadow: none !important;
    border: 1px solid #000000 !important;
    border-radius: 0 !important;
    overflow: visible !important;
    margin-bottom: 20px !important;
  }

  table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  th {
    background-color: #f1f5f9 !important;
    color: #000000 !important;
    border-bottom: 2px solid #000000 !important;
    font-size: 9pt !important;
  }

  td {
    color: #000000 !important;
    border-bottom: 1px solid #e2e8f0 !important;
    font-size: 9pt !important;
  }

  /* Card layouts printed as clean rows or neat items */
  .cards-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 15px !important;
  }

  .item-card {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
    background-color: #ffffff !important;
  }

  .item-img-container {
    height: 120px !important;
  }

  /* Stat cards */
  .dashboard-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    margin-bottom: 20px !important;
  }

  .stat-card {
    border: 1px solid #d2d2d7 !important;
    background-color: #f5f5f7 !important;
    box-shadow: none !important;
    padding: 15px !important;
  }

  .stat-value {
    font-size: 20pt !important;
    color: #000000 !important;
  }

  .print-hidden {
    display: none !important;
  }

  .print-only-block {
    display: flex !important;
  }
}

.print-only-block {
  display: none !important;
}

/* ==========================================
   HHI VAULT - Supabase & Admin Styling
   ========================================== */

.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(28, 28, 30, 0.96);
  backdrop-filter: blur(16px);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

.auth-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: authFadeIn 0.4s ease-out;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  color: var(--text-primary);
  margin-bottom: 18px;
}
.auth-brand-text {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}
.auth-brand-text .kicker {
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.auth-title {
  text-align: center;
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.auth-sub {
  text-align: center;
  margin: 0 0 22px;
  font-size: 12px;
  color: var(--text-muted);
}
.auth-label {
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-muted);
}
.auth-input { width: 100%; }
.auth-submit { width: 100%; height: var(--control-h-lg); margin-top: 6px; }
.auth-help {
  text-align: center;
  margin-top: 14px;
  font-size: 11px;
  color: var(--text-muted);
}
#auth-form .form-group { margin-bottom: 14px; }

@keyframes authFadeIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.user-profile-section {
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

/* Badge variants — macOS system colors */
.badge-admin {
  background-color: rgba(255, 69, 58, 0.18);
  color: #ff453a;
  border: 1px solid rgba(255, 69, 58, 0.30);
}

.badge-member {
  background-color: rgba(10, 132, 255, 0.18);
  color: #0a84ff;
  border: 1px solid rgba(10, 132, 255, 0.30);
}

.badge-online {
  background-color: rgba(48, 209, 88, 0.18);
  color: #30d158;
  border: 1px solid rgba(48, 209, 88, 0.30);
}

.badge-offline {
  background-color: rgba(255, 159, 10, 0.18);
  color: #ff9f0a;
  border: 1px solid rgba(255, 159, 10, 0.30);
}

/* ============================================================
 * macOS Tahoe — clean system UI
 * Solid, adaptive app surfaces with hairline borders and soft,
 * near-invisible shadows. Real OS translucency is reserved for
 * the sidebar (window vibrancy) and floating chrome (toolbar,
 * popovers, dialogs) where it reads cleanly in both themes.
 * No specular gradients, no full-window transparency — those
 * looked broken when the desktop didn't show through.
 * Appended last so these rules win over the base definitions.
 * ============================================================ */

/* App body stays solid and adaptive */
body { background-color: var(--bg-app); }
#main-content { background-color: transparent; }

/* Sidebar — let the OS 'sidebar' vibrancy show through a translucent tint */
[data-platform="darwin"] #sidebar {
  background: var(--glass-sidebar);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-right: 1px solid var(--hairline);
}

/* Toolbar — subtle frost over the content scrolling beneath it */
[data-platform="darwin"] header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--glass-panel);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-bottom: 1px solid var(--hairline);
}

/* Cards / panels — solid, crisp, flat (Tahoe-clean) */
.surface,
.card,
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--raised-shadow);
  transition: box-shadow var(--transition-normal), transform var(--transition-fast);
}

/* Quiet hover lift on interactive cards */
.surface:hover { box-shadow: var(--shadow-md); }

/* Dialog (native <dialog>) — solid surface, blurred backdrop */
.dialog-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.28);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* Popover — floating chrome gets a light frost */
.popover {
  background: var(--glass-panel-strong);
  -webkit-backdrop-filter: blur(var(--glass-blur-strong)) saturate(var(--glass-saturate));
  backdrop-filter: blur(var(--glass-blur-strong)) saturate(var(--glass-saturate));
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-popover);
}

/* Active nav item — clean rounded selection */
.nav-link.active { border-radius: 10px; }

/* Fallback: where vibrancy/backdrop-filter is unavailable, stay solid */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  [data-platform="darwin"] #sidebar { background: var(--bg-sidebar); }
  [data-platform="darwin"] header { background: var(--bg-app); }
  .popover { background: var(--bg-card); }
}

