:root {
  /* Refined Color Palette - Modern & Clean */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --border-light: #e2e8f0;
  --border-focus: #3b82f6;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;

  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  margin: 0;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-hover);
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.hidden {
  display: none !important;
}

/* Typography */
h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  color: var(--text-main);
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; margin-bottom: 0.75rem; }
.muted { color: var(--text-muted); font-size: 0.875rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

/* Layout Helpers */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 640px) {
  .grid.two {
    grid-template-columns: 1fr;
  }
}

.divider {
  height: 1px;
  background-color: var(--border-light);
  margin: 16px 0;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card.soft {
  background: #f1f5f9;
  border: none;
  box-shadow: none;
}

/* Topbar */
.topbar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  margin-bottom: 24px;
  position: sticky;
  top: 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 { 
  font-size: 1.125rem; 
  font-weight: 700;
  letter-spacing: -0.01em;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  border: 1px solid rgba(37, 99, 235, 0.2);
  overflow: hidden;
  cursor: pointer;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar.large {
  width: 80px;
  height: 80px;
  font-size: 2rem;
}

.avatar:hover .overlay {
  opacity: 1 !important;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  background-color: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.btn:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(1px);
}

.btn.secondary {
  background-color: white;
  color: var(--text-main);
  border-color: var(--border-light);
}

.btn.secondary:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

.btn.danger {
  background-color: var(--danger);
  color: white;
}

.btn.danger:hover {
  background-color: #dc2626;
}

.btn.small {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  box-shadow: none;
}

.btn.ghost:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text-main);
}

/* Forms */
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background-color: var(--bg-input);
  font-size: 0.875rem;
  transition: all 0.2s;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}

input:hover, select:hover, textarea:hover {
  border-color: #cbd5e1;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background-color: white;
}

/* Lists & Items */
.list {
  display: grid;
  gap: 12px;
}

.item {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.item:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.item-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-main);
  display: block;
  margin-bottom: 8px;
  text-decoration: none;
}

.item-title:hover {
  color: var(--primary);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.meta .kv {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

/* Detail Styles */
.detail-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
  line-height: 1.4;
}

.detail-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.prewrap {
  white-space: pre-wrap;
  color: var(--text-main);
  line-height: 1.6;
  font-size: 0.95rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

/* Status Badges */
.badge.status-open { background: #eff6ff; color: #1d4ed8; }
.badge.status-in_progress { background: #f0fdf4; color: #15803d; }
.badge.status-blocked { background: #fff7ed; color: #c2410c; }
.badge.status-awaiting_acceptance { background: #faf5ff; color: #7e22ce; }
.badge.status-done { background: #f0fdf4; color: #15803d; }
.badge.status-closed { background: #f1f5f9; color: #475569; }

/* Priority Badges */
.badge.pri-P0 { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.badge.pri-P1 { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge.pri-P2 { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 8px;
  font-size: 0.875rem;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.5);
}

.tab.active {
  background: white;
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Controls (Filters) */
.controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .controls {
    flex-direction: column;
  }
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 24px;
  margin-top: 16px;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 0;
  left: 7px;
  width: 2px;
  background: var(--border-light);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--border-focus);
  z-index: 1;
}

.timeline-content {
  /* No extra styling needed for now, just container */
}

/* Comments */
.comment-item {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.comment-body {
  white-space: pre-wrap;
  font-size: 0.875rem;
  color: var(--text-main);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  background: var(--bg-card);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-lg);
}

.customer-admin {
  display: grid;
  gap: 16px;
}

.customer-admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.customer-admin-title h2 {
  margin-bottom: 4px;
}

.customer-admin-header-actions {
  display: flex;
  gap: 8px;
}

.customer-admin-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.customer-admin-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}

.customer-admin-form input[type="file"] {
  padding: 6px 8px;
}

.customer-admin-list {
  display: grid;
  gap: 12px;
}

.customer-admin-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}

.customer-admin-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.customer-admin-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 720px) {
  .customer-admin-forms {
    grid-template-columns: 1fr;
  }

  .customer-admin-form {
    grid-template-columns: 1fr;
  }

  .customer-admin-item {
    grid-template-columns: 1fr;
  }

  .customer-admin-fields {
    grid-template-columns: 1fr;
  }

  .customer-admin-actions {
    justify-content: flex-start;
  }
}

.list-header {
  padding: 8px 0;
  font-weight: 600;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
  margin-top: 16px;
  margin-bottom: 8px;
}
.list-header:first-child {
  margin-top: 0;
}
.owner-select {
  width: 100%;
}
.owner-select.hidden {
  display: none;
}
