/* ==========================================================================
   ManicTime Timesheet Modern UI Stylesheet
   Version: 1.0 (Milestone 3)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties / Design Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Default: Dark Theme (matches ManicTime reference screenshot) */
  --bg-primary: #18181B;
  --bg-card: #222226;
  --bg-surface-elevated: #2A2A2F;
  --bg-surface-hover: #2F2F36;
  --bg-input: #1E1E22;
  --bg-input-focus: #26262B;
  
  --border-color: #2E2E33;
  --border-prominent: #3F3F46;
  --border-focus: #10B981;

  --text-primary: #F4F4F5;
  --text-secondary: #A1A1AA;
  --text-dimmed: #52525B;
  --text-inverse: #111827;

  --accent-emerald: #10B981;
  --accent-emerald-hover: #059669;
  --accent-emerald-active: #047857;
  --accent-emerald-bg: rgba(16, 185, 129, 0.15);
  --accent-emerald-focus: rgba(16, 185, 129, 0.35);

  --status-live: #10B981;
  --status-error: #EF4444;
  --status-warn: #F59E0B;

  --radius-card: 10px;
  --radius-btn: 6px;
  --radius-input: 6px;

  --font-stack: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-tabular: system-ui, -apple-system, "Segoe UI", monospace;
  
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-dropdown: 0 4px 12px rgba(0, 0, 0, 0.4);

  --z-sticky-th: 10;
  --z-sticky-col: 5;
  --z-sticky-corner: 15;
}

/* Explicit Light Mode Override */
:root[data-theme="light"],
[data-theme="light"] {
  --bg-primary: #F3F4F6;
  --bg-card: #FFFFFF;
  --bg-surface-elevated: #F9FAFB;
  --bg-surface-hover: #F3F4F6;
  --bg-input: #FFFFFF;
  --bg-input-focus: #FFFFFF;

  --border-color: #E5E7EB;
  --border-prominent: #D1D5DB;
  --border-focus: #059669;

  --text-primary: #111827;
  --text-secondary: #4B5563;
  --text-dimmed: #9CA3AF;
  --text-inverse: #FFFFFF;

  /* Accessible contrast on light background */
  --accent-emerald: #059669;
  --accent-emerald-hover: #047857;
  --accent-emerald-active: #065F46;
  --accent-emerald-bg: rgba(5, 150, 105, 0.12);
  --accent-emerald-focus: rgba(5, 150, 105, 0.25);

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-dropdown: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Automatic OS Preference (when no explicit data-theme is set) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-primary: #F3F4F6;
    --bg-card: #FFFFFF;
    --bg-surface-elevated: #F9FAFB;
    --bg-surface-hover: #F3F4F6;
    --bg-input: #FFFFFF;
    --bg-input-focus: #FFFFFF;

    --border-color: #E5E7EB;
    --border-prominent: #D1D5DB;
    --border-focus: #059669;

    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-dimmed: #9CA3AF;
    --text-inverse: #FFFFFF;

    --accent-emerald: #059669;
    --accent-emerald-hover: #047857;
    --accent-emerald-active: #065F46;
    --accent-emerald-bg: rgba(5, 150, 105, 0.12);
    --accent-emerald-focus: rgba(5, 150, 105, 0.25);

    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-dropdown: 0 4px 12px rgba(0, 0, 0, 0.12);
  }
}

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

html, body {
  height: 100%;
  width: 100%;
  font-family: var(--font-stack);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color-scheme: dark;
}

:root[data-theme="light"],
[data-theme="light"] {
  color-scheme: light;
}

/* --------------------------------------------------------------------------
   2b. Dark Theme Native Scrollbars (Webkit & Standard)
   -------------------------------------------------------------------------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-prominent) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-prominent);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dimmed);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* --------------------------------------------------------------------------
   3. Application Shell & Split-Pane Grid (Feature 18)
   -------------------------------------------------------------------------- */
.app-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  padding: 12px;
  gap: 12px;
}

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

/* --------------------------------------------------------------------------
   4. Sidebar Layout & Controls
   -------------------------------------------------------------------------- */
.sidebar-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  gap: 16px;
}

.sidebar-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

/* Quick Preset Pill Buttons (Invoice, Day, Week) */
.quick-preset-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: -4px;
}

.preset-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: all 0.16s ease;
}

.preset-pill svg {
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.preset-pill:hover {
  transform: translateY(-1px);
  color: var(--text-primary);
  border-color: var(--border-prominent);
}

.preset-pill:active {
  transform: translateY(0);
}

/* Color Coding for Pills */
/* 1. Invoice: Emerald / Live theme color */
.preset-pill.pill-invoice:hover {
  background-color: var(--accent-emerald-bg);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}
.preset-pill.pill-invoice.active {
  background-color: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

/* 2. Day: Pixel Art Cyan / Turquoise color */
.preset-pill.pill-day:hover {
  background-color: rgba(30, 203, 163, 0.15);
  border-color: #1ecba3;
  color: #1ecba3;
}
.preset-pill.pill-day.active {
  background-color: #1ecba3;
  border-color: #1ecba3;
  color: #111827;
  box-shadow: 0 2px 8px rgba(30, 203, 163, 0.35);
}

/* 3. Week: Blender Purple / Violet color */
.preset-pill.pill-week:hover {
  background-color: rgba(168, 85, 247, 0.15);
  border-color: #a855f7;
  color: #c084fc;
}
.preset-pill.pill-week.active {
  background-color: #9333ea;
  border-color: #9333ea;
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(147, 51, 234, 0.35);
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.section-label {
  display: block;
  font-size: 11.5px;
  font-style: italic;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field-label-inline {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 40px;
}

/* Range Selector & Shift Arrows */
.range-nav-group {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.range-select {
  flex: 1;
}

.shift-btn-group {
  display: flex;
  gap: 2px;
}

.shift-btn {
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
}

.date-picker-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.form-row .form-input,
.form-row .form-select {
  flex: 1;
}

/* Form Inputs & Selects */
.form-select,
.form-input {
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-input);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-select:focus,
.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-emerald-focus);
}

.form-input[type="date"] {
  min-height: 30px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-btn);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-primary {
  background-color: var(--accent-emerald);
  color: #FFFFFF;
}

.btn-primary:hover {
  background-color: var(--accent-emerald-hover);
}

.btn-primary:active {
  background-color: var(--accent-emerald-active);
}

.btn-secondary {
  background-color: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-prominent);
}

.btn-block {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-btn);
  padding: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-prominent);
}

/* Checkbox & Radio Controls */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.form-checkbox,
.form-radio {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border: 1px solid var(--border-prominent);
  background-color: var(--bg-input);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

.form-radio {
  border-radius: 50%;
}

.form-checkbox:checked {
  background-color: var(--accent-emerald);
  border-color: var(--accent-emerald);
}

.form-checkbox:checked::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 4px;
  width: 4px;
  height: 8px;
  border: solid #FFFFFF;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.form-radio:checked {
  border-color: var(--accent-emerald);
  background-color: var(--bg-input);
}

.form-radio:checked::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
}

/* --------------------------------------------------------------------------
   5. Sidebar Tabs (Feature 21: Basic vs Advanced)
   -------------------------------------------------------------------------- */
.sidebar-tabs-container {
  border-bottom: 1px solid var(--border-color);
}

.sidebar-tabs {
  display: flex;
  gap: 16px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 2px 8px 2px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--accent-emerald);
}

.tab-content-container {
  flex: 1;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tab-panel[hidden] {
  display: none !important;
}

.rounding-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding-left: 6px;
  border-left: 2px solid var(--border-color);
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.sidebar-footer-copy {
  text-align: center;
  font-size: 11px;
  color: var(--text-dimmed);
}

.sidebar-footer-copy a,
.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.sidebar-footer-copy a:hover,
.footer-link:hover {
  color: var(--accent-emerald);
  text-decoration: underline;
}

/* App Footer at bottom of Main Pane */
.app-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 11.5px;
  color: var(--text-dimmed);
  flex-shrink: 0;
}

.footer-copy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.format-radio-group {
  display: flex;
  gap: 16px;
}

.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   6. Main Content Area & Toolbar
   -------------------------------------------------------------------------- */
.main-content-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  gap: 10px;
}

.main-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  flex-shrink: 0;
}

/* View Switcher Tabs (Timesheet vs Usage) */
.view-tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 2px;
}

.view-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 4px 8px 4px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-tab-btn:hover {
  color: var(--text-primary);
}

.view-tab-btn.active {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--accent-emerald);
}

/* Toolbar Actions */
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-right: 4px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--status-live);
  flex-shrink: 0;
}

.status-dot.error {
  background-color: var(--status-error);
}

.status-dot.warn {
  background-color: var(--status-warn);
}

.export-btn-group {
  display: flex;
  gap: 4px;
}

/* Reload Icon Animation */
.spin-icon.spinning,
.spin-icon.spin,
.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Theme Toggle Icons */
.theme-toggle .icon-sun {
  display: none;
}
.theme-toggle .icon-moon {
  display: block;
}

:root[data-theme="light"] .theme-toggle .icon-sun,
[data-theme="light"] .theme-toggle .icon-sun {
  display: block;
}
:root[data-theme="light"] .theme-toggle .icon-moon,
[data-theme="light"] .theme-toggle .icon-moon {
  display: none;
}

/* --------------------------------------------------------------------------
   7. View Container & Panels
   -------------------------------------------------------------------------- */
.view-content-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.view-panel {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.view-panel[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   8. Data Table Architecture & Sticky Layout (Feature 31)
   -------------------------------------------------------------------------- */
.table-scroll-container {
  flex: 1;
  overflow: auto;
  position: relative;
  background-color: var(--bg-card);
}

.timesheet-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  -webkit-font-feature-settings: "tnum" 1;
  font-feature-settings: "tnum" 1;
}

/* Headers & Sticky Positioning */
.timesheet-table thead th {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky-th);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 10px;
  font-weight: 500;
  text-align: right;
  user-select: none;
  white-space: nowrap;
}

/* Sticky Left Column: Tag */
.timesheet-table .col-sticky-left {
  position: sticky;
  left: 0;
  z-index: var(--z-sticky-col);
  background-color: var(--bg-card);
  text-align: left;
  min-width: 180px;
  max-width: 260px;
  border-right: 1px solid var(--border-color);
}

/* Top-Left Corner Header Cell Intersection */
.timesheet-table thead th.col-sticky-left {
  z-index: var(--z-sticky-corner);
}

/* Rate Column (Header & Cells) */
.timesheet-table .col-rate,
.timesheet-table .th-rate,
.timesheet-table .cell-rate {
  text-align: right;
  min-width: 70px;
  white-space: nowrap;
}

.timesheet-table thead th.col-rate,
.timesheet-table thead th.th-rate {
  text-align: right;
  font-weight: 500;
  user-select: none;
}

.timesheet-table tbody td.cell-rate,
.timesheet-table tbody td.col-rate {
  text-align: right;
  color: var(--text-secondary);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  -webkit-font-feature-settings: "tnum" 1;
  font-feature-settings: "tnum" 1;
}

.cell-multi-rate {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--accent-emerald);
  font-weight: 500;
  font-size: 11.5px;
  cursor: help;
  transition: all 0.15s ease;
}

.cell-multi-rate:hover {
  border-color: var(--accent-emerald);
  background-color: var(--accent-emerald-bg);
}

.timesheet-table tbody tr:hover td.cell-rate,
.timesheet-table tbody tr:hover td.col-rate {
  color: var(--text-primary);
}

.timesheet-table tfoot td.cell-rate,
.timesheet-table tfoot td.col-rate {
  text-align: right;
  color: var(--text-dimmed);
  font-weight: 500;
}

/* Table Cells */
.timesheet-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-color);
  text-align: right;
  white-space: nowrap;
  color: var(--text-primary);
}

.timesheet-table tbody tr:hover td {
  background-color: var(--bg-surface-hover);
}

.timesheet-table tbody tr:hover .col-sticky-left {
  background-color: var(--bg-surface-hover);
}

/* --------------------------------------------------------------------------
   9. Stacked Column Headers (Feature 32)
   -------------------------------------------------------------------------- */
.th-content {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  width: 100%;
}

.timesheet-table .col-sticky-left .th-content {
  justify-content: space-between;
  display: flex;
}

.th-stacked,
.header-stacked {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}

.th-day-num,
.header-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.th-day-name,
.header-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
}

.sortable {
  cursor: pointer;
}

.sortable:hover .th-title,
.sortable:hover .th-day-num,
.sortable:hover .header-label {
  color: var(--accent-emerald);
}

.sort-icon {
  font-size: 11px;
  opacity: 0.35;
  transition: opacity 0.15s ease;
  margin-left: 2px;
}

.sortable:hover .sort-icon {
  opacity: 0.8;
}

th[data-sorted="asc"] .sort-icon,
.sort-icon.active {
  opacity: 1;
  color: var(--accent-emerald);
}

th[data-sorted="desc"] .sort-icon {
  opacity: 1;
  color: var(--accent-emerald);
}

/* --------------------------------------------------------------------------
   10. Dimmed Zero Cells (Feature 33)
   -------------------------------------------------------------------------- */
.timesheet-table td.is-zero,
.timesheet-table td.zero-cell,
.timesheet-table td.cell-zero,
.cell-zero {
  color: var(--text-dimmed) !important;
  opacity: 0.38 !important;
}

/* --------------------------------------------------------------------------
   11. Bold Totals Row & Separator (Feature 34)
   -------------------------------------------------------------------------- */
/* Vertical divider before Total Column */
.timesheet-table .col-total {
  border-left: 2px solid var(--border-prominent);
  font-weight: 600;
}

.timesheet-table thead th.col-total {
  border-left: 2px solid var(--border-prominent);
}

/* Optional Earnings Column */
.timesheet-table .col-earned {
  font-weight: 600;
  min-width: 75px;
}

/* Sticky Totals Footer */
.timesheet-table tfoot {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky-th);
  background-color: var(--bg-surface-elevated);
}

.timesheet-table tfoot td,
.row-totals td,
.totals-row td {
  padding: 8px 10px;
  font-weight: 700;
  text-align: right;
  border-top: 2px solid var(--border-prominent);
  border-bottom: none;
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.timesheet-table tfoot td.col-sticky-left {
  z-index: var(--z-sticky-corner);
}

.timesheet-table tfoot td.col-grand-total,
.timesheet-table tfoot td.col-total {
  color: var(--accent-emerald);
}

/* --------------------------------------------------------------------------
   12. Category Color Indicators (Feature 36)
   -------------------------------------------------------------------------- */
.tag-cell-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  background-color: var(--dot-color, #71717A);
  margin-right: 6px;
  vertical-align: middle;
}

.hide-dots .cat-dot {
  display: none !important;
}

.tag-name,
.tag-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* --------------------------------------------------------------------------
   13. Usage Details Panel (Feature 38)
   -------------------------------------------------------------------------- */
.usage-container {
  padding: 20px;
  height: 100%;
  overflow-y: auto;
}

.usage-heading {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
}

.usage-table th,
.usage-table td {
  padding: 9px 12px;
}

.usage-table .num-cell,
.usage-table .text-right {
  text-align: right;
}

/* --------------------------------------------------------------------------
   14. Loading, Empty, and Error States
   -------------------------------------------------------------------------- */
.loading-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(24, 24, 27, 0.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 50;
  backdrop-filter: blur(2px);
}

:root[data-theme="light"] .loading-overlay {
  background-color: rgba(255, 255, 255, 0.7);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-emerald);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-text {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  color: var(--text-secondary);
}

.error-banner {
  margin: 10px;
  padding: 10px 14px;
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--status-error);
  border-radius: var(--radius-card);
  color: #F87171;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-inline-retry {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   14b. Usage Details & Pie Chart Visualization
   -------------------------------------------------------------------------- */
.usage-container {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  overflow-y: auto;
}

.usage-heading {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.usage-visual-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 32px;
  padding: 14px 20px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  flex-wrap: wrap;
}

.usage-chart-col {
  display: flex;
  align-items: center;
  justify-content: center;
}

.pie-chart-container {
  position: relative;
  width: 170px;
  height: 170px;
}

.usage-pie-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}

.pie-slice {
  transition: transform 0.18s ease, opacity 0.15s ease, stroke-width 0.18s ease;
  cursor: pointer;
  transform-origin: 100px 100px;
}

.pie-slice:hover {
  opacity: 0.9;
  filter: brightness(1.15);
}

.pie-slice.highlighted {
  transform: scale(1.04);
  filter: brightness(1.2);
}

.pie-chart-center-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}

.pie-center-time {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.pie-center-sub {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.usage-legend-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 200px;
  max-width: 480px;
}

.usage-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.usage-legend-item:hover,
.usage-legend-item.highlighted {
  background-color: var(--bg-surface-hover);
}

.usage-legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.usage-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.usage-legend-name {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.usage-legend-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.usage-legend-time {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.usage-legend-pct {
  font-weight: 600;
  color: var(--text-primary);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Hidden Utility */
[hidden] {
  display: none !important;
}

.print-header {
  display: none;
}

/* --------------------------------------------------------------------------
   15. Responsive Breakpoint (< 840px)
   -------------------------------------------------------------------------- */
@media (max-width: 840px) {
  .app-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }

  .sidebar-pane {
    height: auto;
  }

  .table-scroll-container {
    max-height: 550px;
  }
}

@media (max-width: 640px) {
  .timesheet-table .col-rate,
  .timesheet-table .th-rate,
  .timesheet-table .cell-rate {
    min-width: 60px;
    padding-left: 6px;
    padding-right: 6px;
    font-size: 11.5px;
  }
}

/* --------------------------------------------------------------------------
   16. Print Stylesheet (Feature 41)
   -------------------------------------------------------------------------- */
@media print {
  @page {
    size: auto;
    margin: 12mm 14mm;
  }

  /* Reset layout for paper printing */
  html, body {
    background: #FFFFFF !important;
    color: #111827 !important;
    height: auto !important;
    font-size: 11pt !important;
  }

  .app-layout {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
  }

  /* Hide navigation, sidebar, toolbars, and buttons */
  .sidebar-pane,
  .main-toolbar,
  .loading-overlay,
  .empty-state,
  .error-banner,
  .theme-toggle,
  .sort-icon {
    display: none !important;
  }

  .main-content-pane {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  .view-content-wrapper {
    overflow: visible !important;
    height: auto !important;
  }

  /* Show Print Header */
  .print-header {
    display: block !important;
    margin-bottom: 15px;
    border-bottom: 2px solid #111827;
    padding-bottom: 8px;
  }

  .print-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }

  .print-title {
    font-size: 18pt;
    font-weight: 700;
    color: #111827;
  }

  .print-meta,
  .print-subtitle {
    font-size: 9pt;
    color: #4B5563;
  }

  /* Full Width Printable Table */
  .table-scroll-container {
    border: none !important;
    box-shadow: none !important;
    max-height: none !important;
    overflow: visible !important;
    background: #FFFFFF !important;
  }

  .timesheet-table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 10pt !important;
  }

  /* Disable sticky headers in print mode */
  .timesheet-table thead th,
  .timesheet-table .col-sticky-left,
  .timesheet-table tfoot {
    position: static !important;
    background: #FFFFFF !important;
    color: #111827 !important;
    box-shadow: none !important;
  }

  .timesheet-table thead th {
    border-top: 1px solid #111827 !important;
    border-bottom: 2px solid #111827 !important;
    border-left: 1px solid #D1D5DB !important;
    border-right: 1px solid #D1D5DB !important;
    background-color: #F9FAFB !important;
  }

  .timesheet-table tbody td {
    border: 1px solid #E5E7EB !important;
    color: #111827 !important;
    background: transparent !important;
  }

  /* Rate column high contrast in print mode */
  .timesheet-table th.th-rate,
  .timesheet-table th.col-rate,
  .timesheet-table td.cell-rate,
  .timesheet-table td.col-rate {
    color: #111827 !important;
    font-size: 9.5pt !important;
  }

  /* High contrast dividers */
  .timesheet-table .col-total {
    border-left: 2px solid #111827 !important;
  }

  .timesheet-table tfoot td {
    border-top: 2px solid #111827 !important;
    border-bottom: 2px solid #111827 !important;
    background-color: #F9FAFB !important;
    color: #111827 !important;
  }

  /* Toner saving: print zeroes as lighter text but legible */
  .timesheet-table td.is-zero,
  .timesheet-table td.cell-zero {
    color: #9CA3AF !important;
    opacity: 1 !important;
  }

  /* Repeat table headers across pages */
  thead {
    display: table-header-group;
  }

  tfoot {
    display: table-footer-group;
  }

  tr {
    page-break-inside: avoid;
  }

  /* Hide thumbnail shelf during print */
  .shelf-resizer,
  .work-preview-shelf,
  .preview-lightbox-modal {
    display: none !important;
  }
}

/* ==========================================================================
   16. Work Preview Thumbnail Shelf & Draggable Resizer
   ========================================================================== */

/* Draggable Splitter / Resizer */
.shelf-resizer {
  height: 9px;
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  cursor: row-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
  transition: background-color 0.15s ease;
  position: relative;
  z-index: 20;
}

.shelf-resizer:hover,
.shelf-resizer.is-dragging {
  background-color: var(--accent-emerald-bg);
  border-color: var(--accent-emerald);
}

.shelf-resizer-handle {
  width: 36px;
  height: 3px;
  border-radius: 2px;
  background-color: var(--text-dimmed);
  transition: background-color 0.15s ease, width 0.15s ease;
}

.shelf-resizer:hover .shelf-resizer-handle,
.shelf-resizer.is-dragging .shelf-resizer-handle {
  background-color: var(--accent-emerald);
  width: 48px;
}

/* Work Preview Shelf Container */
.work-preview-shelf {
  height: 220px;
  min-height: 120px;
  max-height: 500px;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.08);
  position: relative;
}

.shelf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface-elevated);
}

.shelf-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shelf-icon {
  color: var(--accent-emerald);
}

.shelf-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.shelf-subtitle {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-left: 4px;
}

.shelf-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Shelf Thumbnails Row */
.shelf-thumbnails {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 14px;
  padding: 12px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  background-color: var(--bg-card);
}

.shelf-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-style: italic;
}

/* Shelf Loading Overlay */
.shelf-loading-overlay {
  position: absolute;
  inset: 38px 0 0 0;
  background-color: rgba(24, 24, 27, 0.7);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 15;
}

:root[data-theme="light"] .shelf-loading-overlay,
[data-theme="light"] .shelf-loading-overlay {
  background-color: rgba(255, 255, 255, 0.75);
}

.shelf-loading-overlay[hidden] {
  display: none !important;
}

.shelf-spinner {
  width: 22px;
  height: 22px;
  border-width: 2.5px;
}

.shelf-loading-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Preview Card */
.preview-card {
  flex: 0 0 280px;
  max-width: 320px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.preview-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  border-color: var(--accent-emerald);
}

.preview-card:focus-visible {
  outline: 2px solid var(--accent-emerald);
  outline-offset: 2px;
}

/* Thumbnail Image Container */
.preview-img-container {
  width: 100%;
  height: 110px;
  background-color: #000;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.preview-card:hover .preview-thumbnail {
  transform: scale(1.04);
}

/* App Badge Overlay */
.preview-app-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  text-transform: capitalize;
  display: flex;
  align-items: center;
  gap: 4px;
}

.preview-app-badge.app-aseprite {
  border-left: 3px solid #ff77a8;
}

.preview-app-badge.app-blender {
  border-left: 3px solid #ea7600;
}

.preview-time-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: #E4E4E7;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Card Details */
.preview-details {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.preview-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.preview-window-title {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.preview-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
}

.preview-tags-group {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}

.preview-tag-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  background-color: var(--accent-emerald-bg);
  color: var(--accent-emerald);
  white-space: nowrap;
}

.preview-category-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  color: var(--text-secondary);
  background-color: var(--bg-surface-hover);
  white-space: nowrap;
}

.preview-rate-pill {
  font-weight: 600;
  color: var(--accent-emerald);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ==========================================================================
   17. Preview Lightbox Modal
   ========================================================================== */
.preview-lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease-out;
}

.preview-lightbox-modal[hidden] {
  display: none !important;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
}

.lightbox-dialog {
  position: relative;
  z-index: 1001;
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-card);
  border: 1px solid var(--border-prominent);
  border-radius: var(--radius-card);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface-elevated);
}

.lightbox-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.lightbox-app-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background-color: var(--text-primary);
  color: var(--bg-primary);
  text-transform: capitalize;
}

.lightbox-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 450px;
}

.lightbox-tag-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 3px;
  background-color: var(--accent-emerald-bg);
  color: var(--accent-emerald);
  font-weight: 500;
}

.lightbox-rate-badge {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.lightbox-time {
  font-size: 11px;
  color: var(--text-dimmed);
}

.lightbox-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.lightbox-close:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-hover);
}

.lightbox-body {
  padding: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #0b0b0c;
  max-height: calc(90vh - 50px);
}

.lightbox-img {
  max-width: 100%;
  max-height: calc(90vh - 60px);
  object-fit: contain;
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
