
/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--outline);
}
.btn-secondary:hover { background: var(--surface-variant); }

.btn-text {
  background: none;
  color: var(--primary);
  padding: 8px 12px;
}
.btn-text:hover { background: var(--primary-container); }

.btn-danger { background: var(--error); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon {
  padding: 8px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--secondary);
}
.btn-icon:hover { background: var(--surface-variant); }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--outline);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 500;
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--outline);
  box-shadow: var(--shadow-sm);
}

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-container);
  color: var(--primary);
}

.kpi-label {
  font-size: 13px;
  color: var(--secondary);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 500;
  line-height: 1.2;
}

.kpi-trend {
  font-size: 12px;
  margin-top: 4px;
}
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--error); }

/* Grid layouts */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success { background: #E6F4EA; color: var(--success); }
.badge-warning { background: #FEF7E0; color: #E37400; }
.badge-error { background: #FCE8E6; color: var(--error); }
.badge-info { background: var(--primary-container); color: var(--primary); }
.badge-neutral { background: #F1F3F4; color: var(--secondary); }

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--surface-variant);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--secondary);
  border-bottom: 1px solid var(--outline);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--outline);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #F8F9FA; }

/* Forms */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #3C4043;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-container);
}

.form-textarea { min-height: 100px; resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 500;
}

.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--secondary);
}

.empty-state .material-symbols-outlined {
  font-size: 48px;
  opacity: 0.4;
  margin-bottom: 12px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}

.modal-title { font-size: 18px; font-weight: 500; }

.modal-body { padding: 20px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 20px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #323232;
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  animation: slideIn 0.3s ease;
  min-width: 280px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.warning { background: #E37400; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--outline);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  color: var(--secondary);
  margin-bottom: -1px;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}

/* Coming soon placeholder */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
  color: var(--secondary);
}

.coming-soon .material-symbols-outlined {
  font-size: 64px;
  opacity: 0.3;
  margin-bottom: 16px;
}

.coming-soon h3 {
  font-size: 18px;
  font-weight: 500;
  color: #3C4043;
  margin-bottom: 8px;
}

@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-actions { width: 100%; }
  .page-actions .form-input,
  .page-actions .btn { flex: 1; min-width: 0; }
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .tab { white-space: nowrap; flex-shrink: 0; padding: 10px 12px; font-size: 13px; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-bottom: env(safe-area-inset-bottom, 0px);
  }
  .data-table { min-width: 560px; }
  .btn, .nav-item, .bottom-nav-item { min-height: 44px; }
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
  .toast { min-width: 0; width: 100%; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-header h2 { font-size: 18px; }
  .kpi-value { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--background, #f0f4f8);
}
.auth-screen.hidden { display: none; }
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 28px 24px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 20px;
}
.auth-logo .material-symbols-outlined {
  font-size: 48px;
  color: var(--primary);
}
.auth-logo h1 { margin: 8px 0 4px; font-size: 22px; }
.auth-logo p { margin: 0; font-size: 13px; color: var(--secondary); }
.auth-tabs { margin-bottom: 16px; }
.auth-form { display: flex; flex-direction: column; gap: 4px; }
.auth-hint {
  margin-top: 16px;
  font-size: 11px;
  color: var(--secondary);
  text-align: center;
  line-height: 1.5;
}

