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

:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --border: #e5e7eb;
  --header-bg: #1e293b;
  --header-text: #f8fafc;
  --row-alt: #f8fafc;
  --row-hover: #eff6ff;
  --success: #10b981;
  --danger: #ef4444;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 24px 16px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 24px;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.add-package {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 280px;
}

.add-package input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.add-package input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.add-package button {
  padding: 8px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.add-package button:hover {
  background: var(--primary-dark);
}

.actions {
  display: flex;
  gap: 8px;
}

.actions button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.actions button:hover {
  background: var(--row-alt);
  border-color: var(--primary);
}

/* Package Tags */
.package-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.package-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
}

.package-tag .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.package-tag .delete-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 2px;
  line-height: 1;
}

.package-tag .delete-btn:hover {
  color: var(--danger);
}

/* Table */
.table-wrapper {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
  max-height: 70vh;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 12px 16px;
  text-align: right;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

thead th:first-child,
thead th:nth-child(2) {
  text-align: center;
}

tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

tbody td:first-child,
tbody td:nth-child(2) {
  text-align: center;
  color: var(--text-light);
}

tbody tr:nth-child(even) {
  background: var(--row-alt);
}

tbody tr:hover {
  background: var(--row-hover);
}

tbody tr.current-week {
  background: #fefce8;
}

tbody tr.current-week:hover {
  background: #fef9c3;
}

tfoot td {
  padding: 12px 16px;
  font-weight: 700;
  text-align: right;
  border-top: 2px solid var(--header-bg);
  background: var(--row-alt);
  white-space: nowrap;
  position: sticky;
  bottom: 0;
  z-index: 1;
}

tfoot td:first-child {
  text-align: center;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text-light);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
  color: white;
  margin-top: 12px;
  font-size: 0.9rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--header-bg);
  color: white;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: transform 0.3s ease;
  z-index: 1001;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

/* Responsive */
@media (max-width: 640px) {
  header h1 {
    font-size: 1.4rem;
  }

  .toolbar {
    flex-direction: column;
  }

  .add-package {
    width: 100%;
    min-width: 0;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }
}
