* {
  box-sizing: border-box;
}

body {
  --theme-main: #005baa;
  --theme-dark: #003f7f;
  --theme-soft: #dbeafe;
  --theme-card-border: #bfdbfe;
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f3f4f6;
  color: #111827;
}

.auth-page,
.app-page {
  min-height: 100vh;
}

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card,
.welcome-card,
.white-card,
.module-card,
.card {
  background: #ffffff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.brand-block {
  margin-bottom: 24px;
  text-align: center;
}

.brand-block h1 {
  margin: 0 0 8px;
  font-size: 28px;
  color: var(--theme-main);
}

.brand-block p,
.welcome-card p,
.module-card p {
  margin: 0;
  color: #6b7280;
}

.form-card,
.form-group {
  display: flex;
  flex-direction: column;
}

.form-card {
  gap: 16px;
}

.form-group {
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  color: #374151;
}

.form-group input,
.form-group select,
.form-group textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  outline: none;
  font: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
select:focus {
  border-color: var(--theme-main);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.2s ease;
}

.btn:hover {
  opacity: 0.95;
}

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

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--theme-main);
  color: #ffffff;
}

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

.btn-secondary {
  background: #e5e7eb;
  color: #111827;
}

.btn-secondary:hover {
  background: #d1d5db;
}

.btn-success {
  background: #16a34a;
  color: #ffffff;
}

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

.error-text {
  min-height: 18px;
  color: #dc2626;
  font-size: 14px;
  margin: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  background: var(--theme-main);
  flex-wrap: wrap;
}

.topbar-left {
  min-width: 220px;
}

.app-title {
  margin: 0;
  font-size: 22px;
  color: #ffffff;
}

.app-subtitle {
  margin: 4px 0 0;
  color: var(--theme-soft);
}

.topbar-right {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-department-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}

.topbar-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--theme-soft);
}

.topbar-select {
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: #ffffff;
  color: #111827;
  font-weight: 600;
}

.user-box {
  background: rgba(255, 255, 255, 0.18);
  padding: 10px 14px;
  border-radius: 10px;
  color: #ffffff;
  min-height: 42px;
  display: flex;
  align-items: center;
}

.main-content {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.home-content {
  max-width: 1280px;
}

.welcome-card {
  margin-bottom: 24px;
  border-top: 4px solid var(--theme-main);
}

.welcome-card h2,
.module-card h3 {
  margin-top: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.home-module-grid {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  align-items: stretch;
}

.module-card {
  display: flex;
  min-height: 142px;
  flex-direction: column;
  justify-content: flex-start;
  border-top: 4px solid var(--theme-main);
  color: inherit;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.module-card:hover {
  transform: translateY(-2px);
  border-top-color: var(--theme-dark);
  box-shadow: 0 8px 18px rgba(0, 91, 170, 0.12);
}

.module-card h3 {
  min-height: 48px;
  margin-bottom: 10px;
  color: var(--theme-main);
  line-height: 1.2;
}

.module-subtitle {
  min-height: 0 !important;
  margin: -4px 0 10px !important;
  color: #111827 !important;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.module-card p {
  min-height: 0;
  margin-bottom: 0;
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.page-actions-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.page-actions {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.card {
  margin-bottom: 18px;
}

.filters-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  align-items: end;
}

.filter-actions {
  justify-content: end;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: #f8fafc;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.data-table tbody tr:nth-child(even) td {
  background: #fbfdff;
}

.data-table tbody tr:hover td,
.selectable-table tbody tr.is-selected td {
  background: #eef6ff;
}

.btn-sm {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.page-feedback {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
}

.page-feedback.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.page-feedback.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(17, 24, 39, 0.45);
}

.modal-card {
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #ffffff;
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.modal-large {
  width: min(980px, 100%);
}

.modal-xl {
  width: min(1180px, 100%);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0 0 4px;
}

.modal-header p {
  margin: 0;
  color: #6b7280;
}

.quick-f9-input {
  width: 230px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font: inherit;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
  }

  .topbar-right {
    width: 100%;
    align-items: stretch;
  }

  .topbar-department-box {
    width: 100%;
  }

  .topbar-select {
    width: 100%;
    min-width: 0;
  }

  .page-actions,
  .page-actions-right {
    width: 100%;
    align-items: stretch;
  }

  .quick-f9-input {
    width: 100%;
  }
}
