:root {
  /* Colors */
  --bg-primary: #F5F6F6;
  --bg-secondary: #EBECED;
  --bg-hover: #f0f0f0;
  --text-primary: #1a1a1a;
  --text-secondary: #888888;
  --text-muted: #aaaaaa;
  --border-color: #e5e5e5;

  /* Stage colors */
  --stage-open: #e74c3c;
  --stage-progress: #3498db;
  --stage-waiting: #f39c12;
  --stage-closed: #27ae60;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 13px;
  --font-size-lg: 14px;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;

  /* Borders */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 100px;
}

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

html, body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.4;
  box-shadow: inset 2px 0 4px -2px rgba(0, 0, 0, 0.1);
  min-height: 100vh;
}

.sidebar {
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* User Bar */
.user-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin: var(--spacing-sm) auto;
  background: #e4e6e9;
  border-radius: 12px;
}

.sidebar > .user-bar {
  display: flex;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.user-bar-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: #8b939e;
  transition: all 0.15s ease;
}

.user-bar-tab.selected {
  background: white;
  color: #34363a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.user-bar-tab:not(.selected):hover {
  color: #34363a;
}

.user-bar-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
}

.user-bar-name {
  font-size: 14px;
  font-weight: 400;
}

.user-bar-tab [data-lucide] {
  width: 18px;
  height: 18px;
}

/* Settings Panel */
.settings-content {
  padding: 0 var(--spacing-md) var(--spacing-md);
}

.settings-label {
  font-size: 11px;
  color: #888;
  display: block;
  margin-bottom: 4px;
}

.settings-input {
  width: 100%;
  padding: 8px;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  font-size: 12px;
  box-sizing: border-box;
}

.settings-button {
  margin-top: 8px;
  padding: 8px 16px;
  background: #34363a;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  width: 100%;
}

.settings-button:hover {
  background: #4a4c50;
}

.settings-hint {
  font-size: 10px;
  color: #888;
  margin-top: 8px;
}

/* Footer */
.sidebar-footer {
  margin-top: auto;
  padding: var(--spacing-sm) 0 var(--spacing-xl);
  text-align: center;
}

.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 600;
  color: #aaa;
  margin-bottom: 2px;
}

.footer-brand [data-lucide] {
  width: 18px;
  height: 18px;
}

.footer-version {
  font-size: 16px;
  color: #aaa;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Lucide Icons */
[data-lucide] {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
}

.section-title [data-lucide],
.btn-pill [data-lucide] {
  width: 14px;
  height: 14px;
  margin-right: 4px;
}

.list-item-icon [data-lucide] {
  width: 18px;
  height: 18px;
}

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 400;
  color: #646c76;
  padding: var(--spacing-sm) var(--spacing-md);
  margin-top: var(--spacing-sm);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
}

/* List Items (like sidebar rows) */
.list-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  cursor: pointer;
  border-radius: var(--radius-md);
  margin: 0 var(--spacing-xs);
  transition: background 0.1s ease;
}

.list-item:hover {
  background: var(--bg-hover);
}

.list-item-icon {
  width: 20px;
  height: 20px;
  margin-right: var(--spacing-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.list-item-label {
  flex: 1;
  font-size: var(--font-size-base);
}

.list-item-count {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  min-width: 24px;
  text-align: center;
}

/* Pill Buttons (like Reply, Forward) */
.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s ease;
  font-family: var(--font-family);
}

.btn-pill:hover {
  background: var(--bg-secondary);
}

.btn-pill:active {
  background: var(--bg-hover);
}

/* Button Groups */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
}

/* Stage Badges */
.stage-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: white;
}

.stage-badge.open { background: var(--stage-open); }
.stage-badge.in-progress { background: var(--stage-progress); }
.stage-badge.waiting { background: var(--stage-waiting); }
.stage-badge.closed { background: var(--stage-closed); }

/* User Card */
.user-card {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-secondary);
}

.user-name {
  font-size: var(--font-size-base);
  font-weight: 500;
}

/* Ticket Info Card */
.ticket-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  margin: var(--spacing-sm) var(--spacing-md);
}

.ticket-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) 0;
}

.ticket-label {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.ticket-value {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--spacing-md) var(--spacing-md);
}

/* Link button (like settings) */
.btn-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  padding: var(--spacing-sm);
}

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

/* Ticket List */
.ticket-list {
  padding: 0 var(--spacing-md);
}

.ticket-list-item {
  display: flex;
  flex-direction: column;
  padding: var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
  background: transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background 0.1s ease;
}

.ticket-list-item:hover,
.ticket-list-item.selected {
  background: #e4e6e9;
  border-radius: 12px;
}

.ticket-list-item.selected {
  position: relative;
  padding-bottom: 20px;
  margin-bottom: 16px;
}

.ticket-list-item-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  width: 100%;
}

.ticket-list-item-subtitle {
  font-size: 11px;
  font-weight: 400;
  color: #8b939e;
  padding-left: 22px;
  margin-top: 2px;
  margin-bottom: 8px;
}

.ticket-list-item-actions {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.btn-small {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 400;
  color: #34363a;
  font-family: var(--font-family);
  background: white;
  border: none;
  border-right: 1px solid #e5e5e5;
  cursor: pointer;
  transition: background 0.1s ease;
}

.btn-small:last-child {
  border-right: none;
}

.btn-small:hover {
  background: #f5f5f5;
}

.btn-small [data-lucide] {
  width: 14px;
  height: 14px;
}

.ticket-list-item-icon {
  flex-shrink: 0;
  color: var(--text-secondary);
}

.ticket-list-item-icon [data-lucide] {
  width: 14px;
  height: 14px;
}

.ticket-list-item-subject {
  flex: 1;
  font-size: 14px;
  font-weight: 400;
  color: #34363a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticket-list-item-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  color: white;
  background: #ec4899;
  border-radius: 10px;
  margin-left: 8px;
}

.ticket-list-item-action {
  opacity: 0;
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 14px;
  font-weight: 400;
  color: #34363a;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.1s ease;
}

.ticket-list-item:hover .ticket-list-item-action {
  opacity: 1;
}

.ticket-list-item-action:hover {
  background: var(--text-primary);
  color: var(--bg-primary);
}

.ticket-list-empty {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  padding: var(--spacing-sm);
  text-align: center;
}

/* Loading state */
.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* Error state */
.error {
  color: var(--stage-open);
  font-size: var(--font-size-sm);
  padding: var(--spacing-sm) var(--spacing-md);
}
