.titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 32px;
    padding: 0 12px;
    border-bottom: 1px solid;
    user-select: none;
    -webkit-user-select: none;
    -webkit-app-region: drag;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Dark theme */
.titlebar-dark {
    background-color: #1e1e1e;
    color: #e0e0e0;
    border-bottom-color: #2d2d2d;
}

/* Light theme */
.titlebar-light {
    background-color: #ffffff;
    color: #1a1a1a;
    border-bottom-color: #e0e0e0;
}

.titlebar-content {
    flex: 1;
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 500;
    gap: 1rem;
}

.menu-button-wrapper {
    position: relative;
}

.menu-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.2s;
    -webkit-app-region: no-drag;
}

.menu-button svg {
    width: 18px;
    height: 18px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.titlebar-dark .menu-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.titlebar-light .menu-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.dropdown-menu {
    position: absolute;
    top: 32px;
    left: 0;
    min-width: 180px;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    -webkit-app-region: no-drag;
}

.dropdown-menu-dark {
    background-color: #242a33;
    border: 1px solid #2d3540;
}

.dropdown-menu-light {
    background-color: #ffffff;
    border: 1px solid #e0e4e9;
}

.menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    color: inherit;
    text-align: left;
    font-family: inherit;
}

.menu-item:first-child {
    border-radius: 6px 6px 0 0;
}

.menu-item:last-child {
    border-radius: 0 0 6px 6px;
}

.dropdown-menu-dark .menu-item:hover {
    background-color: #2d3540;
}

.dropdown-menu-light .menu-item:hover {
    background-color: #f5f7fa;
}

.menu-item svg {
    width: 16px;
    height: 16px;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.titlebar-title {
    font-weight: 500;
    white-space: nowrap;
}

.titlebar-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    -webkit-app-region: no-drag;
}

.titlebar-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.2s;
}

.titlebar-button svg {
    width: 16px;
    height: 16px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Dark theme button hover */
.titlebar-dark .titlebar-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.titlebar-dark .titlebar-button.close:hover {
    background-color: #e81828;
    color: #ffffff;
}

/* Light theme button hover */
.titlebar-light .titlebar-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.titlebar-light .titlebar-button.close:hover {
    background-color: #e81828;
    color: #ffffff;
}

.titlebar-button.close:hover {
    background-color: #e81828;
    color: #ffffff;
}

/* macOS-specific styles */
@supports (-webkit-app-region: drag) {
    .titlebar-controls {
        margin-left: 8px;
    }
}/* CSS Variables for Theming */
:root[data-theme='light'] {
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f8f9fb;
  --bg-hover: #e8eaed;

  --text-primary: #1a1d21;
  --text-secondary: #525866;
  --text-tertiary: #6e7582;

  --accent-primary: #4b6bfb;
  --accent-hover: #3d5ce0;
  --accent-subtle: #e8ecff;

  --border-color: #e0e4e9;
  --border-hover: #c4cbd4;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #ea580c;
  --warning-bg: #ffedd5;
  --info: #0284c7;
  --info-bg: #e0f2fe;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.08);
}

:root[data-theme='dark'] {
  --bg-primary: #0f1419;
  --bg-secondary: #1a1f26;
  --bg-tertiary: #242a33;
  --bg-hover: #2d3540;

  --text-primary: #e8eaed;
  --text-secondary: #b8bdc6;
  --text-tertiary: #8b919d;

  --accent-primary: #5b7ef7;
  --accent-hover: #4a6de6;
  --accent-subtle: #1e2940;

  --border-color: #2d3540;
  --border-hover: #3d4554;

  --success: #22c55e;
  --success-bg: #1a3a29;
  --warning: #f97316;
  --warning-bg: #3a2817;
  --info: #38bdf8;
  --info-bg: #1a2d3d;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--bg-secondary);
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-header-content h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
  font-weight: 600;
}

.app-header-content p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.theme-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.app-main {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.section {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.section h2 {
  margin-bottom: 1rem;
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
}

/* Repository Selector */
.repository-selector {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.selector-header {
  display: flex;
  gap: 0.75rem;
}

.manual-repo-input {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.manual-repo-input input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.875rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.manual-repo-input input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.manual-repo-input input::placeholder {
  color: var(--text-tertiary);
}

.btn-add-repo {
  padding: 0.5rem 1rem;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 500;
}

.btn-add-repo:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-add-repo:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.repo-select {
  flex: 1;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.repo-select:hover,
.repo-select:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.btn-refresh {
  padding: 0.65rem 1.25rem;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-refresh:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-refresh:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.selected-repos-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.repo-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--accent-subtle);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.repo-tag button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  font-size: 1rem;
  transition: color 0.2s;
}

.repo-tag button:hover {
  color: var(--warning);
}

.selected-repo-info {
  padding: 0.75rem;
  background: var(--accent-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
}

/* Filter Panel */
.filter-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.filter-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.date-range-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-filter {
  padding: 0.5rem 0.875rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
}

.btn-filter:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn-filter.active {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.custom-date-range {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
  background: var(--bg-tertiary);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.custom-date-range input {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.85rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.custom-date-range input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.date-preview {
  padding: 0.65rem;
  background: var(--info-bg);
  border-left: 3px solid var(--info);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.user-select {
  padding: 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.2s;
}

.user-select:hover,
.user-select:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.filter-info {
  padding: 0.65rem;
  background: var(--warning-bg);
  border-left: 3px solid var(--warning);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.export-types {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
  color: var(--text-primary);
}

.checkbox-label:hover {
  background: var(--bg-hover);
}

.checkbox-label input[type='checkbox'] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent-primary);
}

.full-backup-option {
  background: var(--accent-subtle);
  border: 1px solid var(--border-color);
  padding: 0.65rem;
  border-radius: 6px;
  font-weight: 500;
}

.full-backup-option:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

/* Export Panel */
.export-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.export-settings {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.setting-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.format-options {
  display: flex;
  gap: 0.75rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem 0.875rem;
  border-radius: 6px;
  transition: background 0.2s;
  color: var(--text-primary);
}

.radio-label:hover {
  background: var(--bg-hover);
}

.radio-label input[type='radio'] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent-primary);
}

.output-path-group {
  display: flex;
  gap: 0.5rem;
}

.output-path-input {
  flex: 1;
  padding: 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.output-path-input:hover,
.output-path-input:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.btn-browse {
  padding: 0.65rem 1.25rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-primary);
  font-weight: 500;
}

.btn-browse:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.export-summary {
  padding: 1.25rem;
  background: var(--bg-tertiary);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.export-summary h3 {
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
}

.export-summary ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.export-summary li {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.export-summary strong {
  color: var(--text-primary);
}

.btn-export {
  padding: 0.875rem 1.5rem;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-md);
}

.btn-export:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-export:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Progress Display */
.progress-display {
  padding: 1.5rem;
  background: var(--bg-tertiary);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.progress-display h3 {
  margin-bottom: 1rem;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
}

.progress-info {
  margin-bottom: 1.25rem;
}

.progress-info p {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.progress-info strong {
  color: var(--text-primary);
}

.progress-bar {
  height: 24px;
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-primary);
  transition: width 0.3s ease;
  border-radius: 12px;
}

.progress-percentage {
  text-align: center;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text-primary);
}

/* Footer */
.app-footer {
  background: var(--bg-secondary);
  padding: 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
}

/* Success/Error Messages */
.success-message {
  background: var(--success-bg);
  border: 2px solid var(--success);
  animation: slideIn 0.3s ease-out;
  text-align: center;
}

.success-message h3 {
  color: var(--success);
  margin-bottom: 0.5rem;
}

.success-message p {
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.btn-open-folder {
  background: var(--accent-primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 5px;
}

.btn-open-folder:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(91, 126, 247, 0.3);
}

.btn-open-folder:active {
  transform: translateY(0);
}

.error-message {
  background: var(--warning-bg);
  border: 2px solid var(--warning);
  animation: slideIn 0.3s ease-out;
}

.error-message h3 {
  color: var(--warning);
  margin-bottom: 0.5rem;
}

.error-message p {
  color: var(--text-primary);
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Custom Scrollbar */
/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 5px;
  transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

::-webkit-scrollbar-corner {
  background: var(--bg-primary);
}

/* Firefox */
* {
  scrollbar-color: var(--border-color) var(--bg-primary);
  scrollbar-width: thin;
}