:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --muted: #5b6676;
  --text: #0f172a;
  --line: #d6deea;
  --accent: #2563eb;
  --accent-dark: #0b1b4d;
  --accent-dark-hover: #102867;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.page-content {
  padding-bottom: 32px;
}

.page-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* =========================
   HEADER / NAV
========================= */

.site-header {
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  padding: 14px 0;
  margin-bottom: 28px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  color: #ffffff;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.4px;
  text-decoration: none;
}

.main-nav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.main-nav a {
  color: #e2e8f0;
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.main-nav a:hover {
  background: #1e293b;
  border-color: #334155;
}

/* =========================
   COMMON BLOCKS
========================= */

.card {
  margin-top: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
}

.h1 {
  font-size: 20px;
  margin: 0 0 10px 0;
}

.sub,
.subtext,
.small {
  color: var(--muted);
}

.sub {
  margin: 0 0 14px 0;
}

.subtext {
  margin-top: -4px;
  margin-bottom: 16px;
}

.small {
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #eef2ff;
  color: #1e3a8a;
}

.link,
.breadcrumb a,
.btn-link {
  color: var(--accent);
  text-decoration: none;
}

.link:hover,
.breadcrumb a:hover,
.btn-link:hover {
  text-decoration: underline;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.breadcrumb {
  margin-bottom: 16px;
  font-size: 14px;
  color: #64748b;
}

/* =========================
   BUTTONS
========================= */

.btn {
  height: 46px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: rgba(79, 140, 255, 0.2);
  border-color: rgba(79, 140, 255, 0.6);
  color: var(--text);
  box-shadow: 0 6px 16px rgba(11, 27, 77, 0.08);
}

.btn-primary:hover {
  background: rgba(79, 140, 255, 0.28);
}

.btn-secondary {
  background: #eef2f8;
  color: #1d2f57;
  border-color: #cfd8e6;
}

.btn-secondary:hover {
  background: #e4ebf5;
}

.btn-success {
  background: rgba(22, 163, 74, 0.14);
  border-color: rgba(22, 163, 74, 0.35);
  color: #166534;
}

.btn-success:hover {
  background: rgba(22, 163, 74, 0.22);
}

.btn-block {
  width: 100%;
}

.btn.is-loading,
.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}

/* =========================
   INPUTS / FORMS
========================= */

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.form-group,
.filter-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label,
.filter-block label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a2746;
}

.input,
.form-input,
.filter-block .input,
.textarea {
  width: 100%;
  min-width: 0;
  background: #ffffff;
  color: #13213a;
  font-size: 0.96rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  border: 1px solid #bcc6d8;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input,
.form-input,
.filter-block .input {
  height: 46px;
  padding: 0 14px;
}

.input::placeholder,
.form-input::placeholder,
.filter-block .input::placeholder {
  color: #7a859a;
}

.input:focus,
.form-input:focus,
.filter-block .input:focus,
.textarea:focus {
  border-color: #163b8c;
  box-shadow: 0 0 0 3px rgba(22, 59, 140, 0.12);
}

.input {
  width: 320px;
  max-width: 100%;
}

.form-input {
  flex: 1;
}

.textarea {
  min-height: 140px;
  resize: vertical;
  padding: 12px 14px;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* =========================
   TABLES / RESULTS
========================= */

.table-wrap {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: auto;
  max-height: 560px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 8px 10px;
  font-size: 13px;
  border-bottom: 1px solid rgba(34, 49, 77, 0.65);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #ffffff;
  text-align: left;
  color: #001e55;
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

tr:hover td {
  background: rgba(79, 140, 255, 0.06);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* =========================
   FLASH MESSAGES
========================= */

.flash-container {
  max-width: 1100px;
  margin: 24px auto 0;
  padding: 0 24px;
}

.flash {
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  font-size: 0.95rem;
  border: 1px solid transparent;
}

.flash-success {
  background: #edf8f0;
  color: #1f6b38;
  border-color: #b9e0c5;
}

.flash-danger {
  background: #fff3f2;
  color: #b42318;
  border-color: #f2b8b5;
}

.flash-warning {
  background: #fff8eb;
  color: #9a6700;
  border-color: #f3d38a;
}

.flash-info {
  background: #eef4ff;
  color: #1d4ed8;
  border-color: #c7d7fe;
}

/* =========================
   HOME
========================= */

.home-page {
  padding: 32px 0;
}

.hero {
  margin-bottom: 32px;
}

.hero h1 {
  margin: 0 0 8px 0;
  font-size: 32px;
}

.hero p {
  margin: 0;
  color: #555;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.module-card {
  display: block;
  padding: 24px;
  border: 1px solid #d9dee8;
  border-radius: 14px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.module-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.module-card h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 18px;
}

.module-card p {
  margin: 0;
  color: #666;
  line-height: 1.5;
}

/* =========================
   AUTH
========================= */

.auth-section {
  width: 100%;
  padding: 48px 24px 32px;
}

.auth-wrapper {
  max-width: 1100px;
  margin: 0 auto;
}

.auth-wrapper-sm {
  max-width: 620px;
}

.auth-header {
  margin-bottom: 24px;
}

.auth-header h1 {
  margin: 0 0 10px;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent-dark);
  line-height: 1.2;
}

.auth-header p {
  margin: 0;
  font-size: 1rem;
  color: #24324a;
}

.auth-card {
  background: #ffffff;
  border: 1px solid #d9dfeb;
  border-radius: 18px;
  padding: 20px 18px;
  box-shadow: 0 8px 22px rgba(15, 32, 68, 0.06);
}

.auth-form {
  width: 100%;
}

.auth-form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-secondary-form {
  margin-top: 12px;
}

/* =========================
   FILTERS / TABS
========================= */

.tabs {
  display: flex;
  gap: 10px;
  margin: 14px 0 16px;
  flex-wrap: wrap;
}

.tab-link {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #93c5fd;
  background: #dbeafe;
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 600;
}

.tab-link.active {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.filter-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.filter-grid-ruc {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
}

.filter-block-lg {
  grid-column: span 1;
}

/* =========================
   LOADING / SUBMIT LOCK
========================= */

.loading-box {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 12px;
  font-size: 13px;
}

.loading-box.show {
  display: inline-flex;
}

.loading-box-inline {
  margin-top: 10px;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #bfdbfe;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.loading-text {
  line-height: 1.4;
}

.js-loading-form.is-submitting {
  pointer-events: none;
}

.js-loading-form.is-submitting .js-loading-box {
  pointer-events: none;
}

.page-busy {
  cursor: progress;
}

.page-busy .js-loading-form.is-submitting .btn,
.page-busy .js-loading-form.is-submitting button,
.page-busy .js-loading-form.is-submitting input,
.page-busy .js-loading-form.is-submitting select,
.page-busy .js-loading-form.is-submitting textarea {
  pointer-events: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 900px) {
  .filter-grid,
  .filter-grid-ruc {
    grid-template-columns: 1fr;
  }

  .result-header {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 768px) {
  .auth-section {
    padding: 32px 16px 24px;
  }

  .auth-header h1 {
    font-size: 1.8rem;
  }

  .auth-card {
    padding: 16px;
  }

  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .form-row .btn {
    width: 100%;
  }
}