/* ===== Reset & base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #12100a;
  --color-surface: #1e1a12;
  --color-surface-hover: #2a2418;
  --color-border: #3d3520;
  --color-text: #f5f0e6;
  --color-text-muted: #a89a7a;
  --color-primary: #f59e0b;
  --color-primary-hover: #d97706;
  --color-primary-text: #1a1200;
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.12);
  --color-success: #22c55e;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== Layout ===== */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page--centered {
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(245, 158, 11, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(234, 179, 8, 0.07) 0%, transparent 50%),
    var(--color-bg);
}

.container {
  width: 100%;
  max-width: 420px;
}

.container--wide {
  max-width: 1280px;
  padding: 1.5rem 2rem 3rem;
  margin: 0 auto;
}

/* ===== Card ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.card__header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.card__title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card__subtitle {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-top: 0.375rem;
}

/* ===== Form ===== */
.form-group {
  margin-bottom: 1.125rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 0.375rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 0.875rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  font-size: 0.9375rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

.form-input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.6;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn--primary {
  width: 100%;
  background: var(--color-primary);
  color: var(--color-primary-text);
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

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

.btn--ghost:hover:not(:disabled) {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.btn--danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn--danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
}

/* ===== Alert ===== */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: none;
}

.alert--visible {
  display: block;
}

.alert--error {
  background: var(--color-danger-bg);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.alert--info {
  background: rgba(245, 158, 11, 0.12);
  color: #fde68a;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ===== Dashboard header ===== */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.dashboard-header__info h1 {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dashboard-header__info p {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.dashboard-header__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-badge {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-box__input {
  width: 100%;
  padding: 0.625rem 0.875rem 0.625rem 2.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  font-size: 0.875rem;
  font-family: inherit;
}

.search-box__input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.search-box__icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
  font-size: 0.875rem;
}

.record-count {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ===== Table ===== */
.table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

thead {
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
}

th:hover {
  color: var(--color-text);
}

th .sort-indicator {
  margin-left: 0.25rem;
  opacity: 0.4;
}

th.sorted .sort-indicator {
  opacity: 1;
  color: var(--color-primary);
}

td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

tbody tr:last-child td {
  border-bottom: none;
}

/* ===== States ===== */
.loading-overlay {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.loading-overlay--visible {
  display: flex;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.empty-state {
  display: none;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-text-muted);
}

.empty-state--visible {
  display: block;
}

.empty-state__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.375rem;
}

/* ===== Footer ===== */
.page-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .card {
    padding: 1.5rem;
  }

  .container--wide {
    padding: 1rem;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-header__actions {
    width: 100%;
    justify-content: space-between;
  }
}
