:root {
  --color-background: #f5f7fb;
  --color-surface: #ffffff;
  --color-primary: #1f6feb;
  --color-primary-dark: #1550b9;
  --color-accent: #0d2854;
  --color-text: #1a2333;
  --color-muted: #6b7280;
  --border-radius: 12px;
  --shadow-soft: 0 12px 24px rgba(16, 37, 66, 0.12);
  --shadow-flat: 0 1px 3px rgba(16, 37, 66, 0.08);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--color-text);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-background);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font: inherit;
}

/* --- Login Page --- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0a2051, #224c9f);
  padding: 20px;
}

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

.login-card {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  padding: 40px 36px;
  box-shadow: var(--shadow-soft);
}

.login-card h1 {
  margin: 0 0 32px;
  font-size: 28px;
  text-align: center;
  color: var(--color-primary);
  letter-spacing: 0.5px;
}

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
}

.form-group label {
  font-weight: 600;
  margin-bottom: 8px;
}

.form-group input {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.15);
}

.form-error {
  min-height: 22px;
  color: #d14343;
  font-size: 14px;
  margin-bottom: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.form-error.visible {
  opacity: 1;
}

.primary-button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.4px;
  transition: background 0.2s ease, transform 0.1s ease;
}

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

.primary-button:active:not(:disabled) {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: progress;
  background: rgba(31, 111, 235, 0.65);
}

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

.top-bar {
  background: linear-gradient(120deg, #0a2051, #214ba2);
  color: #fff;
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-flat);
}

.top-bar h1 {
  margin: 0;
  font-size: 24px;
}

.user-tools {
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 500;
}

.secondary-button {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: transparent;
  color: inherit;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.secondary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.content {
  flex: 1;
  padding: 24px 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-label {
  color: var(--color-muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-primary);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
}

.control-left,
.control-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-left input {
  min-width: 260px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

.control-left input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.control-right select {
  padding: 10px 32px 10px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3e%3cpath fill='%231f6feb' d='M6 7 0 0h12z'/%3e%3c/svg%3e")
    no-repeat right 12px center;
  appearance: none;
  cursor: pointer;
}

.status-banner {
  background: #e8f1ff;
  border-left: 4px solid var(--color-primary);
  padding: 14px 18px;
  border-radius: 10px;
  display: none;
  color: var(--color-accent);
  font-weight: 500;
}

.status-banner.visible {
  display: block;
}

.table-container {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-soft);
  overflow: auto;
  max-height: 60vh;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1200px;
}

thead {
  background: #0a2051;
  color: #fff;
}

thead th {
  padding: 14px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.4px;
  position: sticky;
  top: 0;
  z-index: 3;
  background: #0a2051;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
}

thead th.sortable:focus {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

thead th .sort-indicator {
  font-size: 12px;
  font-weight: 500;
  margin-left: 4px;
  opacity: 0.85;
}

thead th .sort-indicator[data-active='false'] {
  opacity: 0.5;
}

thead th .sort-indicator::selection {
  background: transparent;
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

tbody tr:nth-child(odd) {
  background: #f9fbff;
}

tbody tr:hover {
  background: rgba(31, 111, 235, 0.08);
}

tbody select,
tbody input,
tbody textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
  resize: vertical;
}

tbody textarea {
  min-height: 52px;
}

.field-readonly {
  color: #0f172a;
  font-size: 14px;
  line-height: 1.3;
}

.field-comment {
  min-width: 220px;
}

.empty-state {
  padding: 32px;
  text-align: center;
  color: var(--color-muted);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

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

.pagination-meta {
  color: var(--color-muted);
  font-size: 14px;
}

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f3460;
  color: #fff;
  padding: 14px 18px;
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  max-width: 320px;
  line-height: 1.4;
  font-size: 14px;
}

#toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 768px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

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

  .control-left input {
    width: 100%;
  }

  .table-container {
    border-radius: 18px;
  }
}
