:root {
  --brand: #1a3c6e;
  --bg: #f5f5f5;
  --text: #222;
  --line: #e5e5e5;
  --ok: #1a7a3c;
  --warn: #c0392b;
  --muted: #777;
}

/* Base */
body {
  font-family: 'Noto Sans Thai', 'Sarabun', -apple-system, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

/* Header + Nav */
header {
  background: var(--brand);
  color: #fff;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
header a { color: #fff; text-decoration: none; }
header a:hover { text-decoration: underline; }

nav.main {
  display: flex;
  gap: 1rem;
  align-items: center;
}
nav.main a {
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  transition: background 0.2s;
}
nav.main a:hover { background: rgba(255,255,255,0.15); }
nav.main a.active { background: rgba(255,255,255,0.25); font-weight: 600; }

/* Hamburger toggle */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}
.hamburger span {
  width: 22px;
  height: 2px;
  background: #fff;
}

/* Language selector */
.lang-form select {
  min-width: 7rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #fff;
  color: var(--text);
  font-size: 0.95rem;
}

/* Layout */
main { max-width: 100%; margin: 1.5rem auto; padding: 0 1rem; }

/* Cards */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.card h2, .card h3 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.25rem;
}

.card form {
  padding-top: 0.5rem;
  padding-bottom: 1rem;    /* vertical breathing room inside cards */
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.75rem 1rem; /* consistent horizontal gap */
  border-bottom: 1px solid var(--line);
  text-align: left;
}



th { border-bottom: 2px solid #ddd; }

/* Responsive tables → cards */
@media (max-width: 768px) {
  table.data.responsive {
    display: block;
  }
  table.data.responsive thead {
    display: none; /* hide table headers on mobile */
  }
  table.data.responsive tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.75rem;
    background: #fff;
  }
  table.data.responsive td {
    display: block;              /* stack label + value */
    border: none;
    padding: 0.5rem 0;
  }
  table.data.responsive td::before {
    content: attr(data-label);   /* show the label */
    display: block;              /* put label on its own line */
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.25rem;      /* gap between label and value */
  }
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.form-section {
  margin-bottom: 1rem;
}
.form-section fieldset {
  border: 1px solid var(--line);
  padding: 0.8rem;
  border-radius: 4px;
}
.form-section legend {
  font-weight: bold;
}
.form-section label {
  display: block;
  margin: 0.3rem 0;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0;
}
.summary div {
  flex: 1 1 120px;
}
.alert.warn {
  border: 2px solid var(--warn);
  padding: 1rem;
  border-radius: 6px;
  margin: 1rem 0;
}


/* Buttons */
.btn {
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  text-decoration: none;
  transition: background 0.2s;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: #0f274a; }
.btn.outline {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn.outline:hover { background: var(--brand); color: #fff; }
.btn.danger { background: var(--warn); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.success { background: var(--ok); color: #fff; }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; line-height: 1.2; }
.btn.outline.small {
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 700;
}
.empty { padding: 1.5rem 0; text-align: center; color: var(--muted); }

@media (max-width: 768px) {
  .transaction-group {
    flex-direction: column;
    align-items: flex-start;
  }
  .transaction-group > div {
    width: 100%;
    text-align: left;
  }
}

/* Action buttons */
.actions .action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
@media (max-width: 768px) {
  .actions .action-buttons {
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.75rem;
  }
  .actions .action-buttons .btn {
    width: 100%;
    font-size: 1rem;
    padding: 0.7rem;
  }
}

/* Filters */
.filters {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;   /* add gap above */
  margin-bottom: 1rem;
}
.filters a {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--text);
  background: #fff;
}
.filters a.active {
  background: var(--brand);
  color: #fff;
  font-weight: bold;
}
.filters-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin-bottom: 1.5rem;
}

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}
@media (max-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* Status cells */
.cell-ok { color: var(--ok); font-weight: bold; text-align: center; }
.cell-missing { color: #d35400; font-weight: bold; text-align: center; }

.section {
  border-top: 1px solid var(--line);
  padding: 1rem 0;
}

.file-list {
  margin: 0.5rem 0;
  padding-left: 1.2rem;
}

.form-group { margin-bottom: 1.2rem; }

.form-inline {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.btn-block {
  display: block;
  width: 100%;
}

.file-list {
  margin: 0.5rem 0;
  padding-left: 1.2rem;
}
.file-list li {
  margin-bottom: 0.5rem;
}
.btn-block {
  display: block;
  width: 100%;
}
.section-strong {
  border-top: 2px solid var(--line);
  padding-top: 1rem;
  margin-top: 1rem;
}

.question-block {
  border: 2px solid var(--warn);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

/* Form inputs */
.divider {
  margin: 1.5rem 0;
  border: none;
  border-top: 1px solid var(--line);
}
input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  padding: 0.6rem;
  margin-top: 0.25rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  box-sizing: border-box;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 2px rgba(26, 60, 110, 0.2);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}
.badge.ok     { background: var(--ok); color: #fff; }
.badge.error  { background: var(--danger); color: #fff; }
.badge.warn   { background: var(--warn); color: #000; }
.badge.neutral{ background: var(--line); color: #333; }

/* Utilities */
.text-right { text-align: right; }
.muted { color: var(--muted); }

/* Card link block */
.card-link-block {
  margin-top: 1rem;
  text-align: center;
}


.msg-error {
  color: #c0392b;       /* red tone */
  background: rgba(239,68,68,.14); /* optional subtle background */
  border: 1px solid rgba(239,68,68,.3); /* optional border */
  padding: 0.3rem 0.5rem;
  margin: 0 0 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
}



/* Responsive header/nav fallback + animation */
@media (max-width: 600px) {
  header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 768px) {
  nav.main {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    margin-top: 0.75rem;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
  }
  nav.main.active {
    display: flex;
    max-height: 500px; /* enough to show all links */
    opacity: 1;
  }
  .hamburger { display: flex; }
}

@media (max-width: 768px) {
  .data.responsive td,
  .data.responsive th {
    text-align: left;   /* force all fields left-aligned */
  }

  .badge {
    display: inline-block;
    text-align: center; /* keep badges centered inside their pill */
  }

  .num {
    text-align: right;  /* numeric values stay right-aligned */
  }
}



/* ---- Form fields: one consistent look for every portal form (BaseForm adds .form-control) ---- */
.form-group > label { display: block; font-weight: 500; margin-bottom: 0.25rem; }

textarea.form-control,
select.form-control,
input.form-control[type="number"],
input.form-control[type="url"],
input.form-control[type="tel"],
input.form-control[type="date"] {
  display: block;
  width: 100%;
  padding: 0.6rem;
  margin-top: 0.25rem;
  margin-bottom: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
  background: #fff;
  color: var(--text);
  box-sizing: border-box;
}
textarea.form-control { resize: vertical; min-height: 4.5rem; }

textarea.form-control:focus,
select.form-control:focus,
input.form-control[type="number"]:focus,
input.form-control[type="url"]:focus,
input.form-control[type="tel"]:focus,
input.form-control[type="date"]:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 2px rgba(26, 60, 110, 0.2);
}

/* help text always on its own line, under the field */
.form-group .help { display: block; color: var(--muted, #666); font-size: 0.9rem; margin-top: 0.15rem; }
.form-group input.form-control[type="text"],
.form-group input.form-control[type="email"],
.form-group input.form-control[type="password"] { margin-bottom: 0.4rem; }

/* file picker */
input.form-control[type="file"] { display: block; margin-top: 0.35rem; font-family: inherit; font-size: 0.95rem; }
