:root {
  --brand-blue: #0b5cad;
  --brand-blue-dark: #084482;
  --brand-red: #e51b24;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #cbd5e1;
  --border-light: #e2e8f0;
  --warn-bg: #fffbeb;
  --warn-border: #f59e0b;
  --warn-text: #78350f;
  --danger-bg: #fef2f2;
  --danger-border: #fca5a5;
  --danger-text: #991b1b;
  --info-bg: #eff6ff;
  --info-border: #93c5fd;
  --info-text: #1e40af;
  --success-bg: #ecfdf5;
  --success-border: #6ee7b7;
  --success-text: #065f46;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Sarabun", "Noto Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
}

.topbar-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand img {
  height: 36px;
  width: auto;
  display: block;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-tab {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-tab:hover {
  background: #f8fafc;
}

.nav-tab.active {
  background: var(--brand-blue);
  color: #fff;
  border-color: var(--brand-blue);
}

.container {
  max-width: 920px;
  margin: 24px auto 48px;
  padding: 0 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.hero-header {
  border-top: 4px solid var(--brand-blue);
}

.hero-tag {
  display: inline-block;
  background: #eff6ff;
  color: var(--brand-blue);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

h1 {
  margin: 0 0 6px;
  font-size: 1.55rem;
  color: var(--brand-blue-dark);
  line-height: 1.3;
}

h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
  color: var(--brand-blue);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-light);
}

.subtitle {
  color: var(--muted);
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.deadline-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 5px 12px;
  border-radius: 6px;
}

.alert {
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 0.92rem;
  border: 1px solid;
}

.alert-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

.alert-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}

.alert-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

.alert-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.alert h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.alert ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.alert li {
  margin: 4px 0;
}

.tenant-box {
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
  border: 2px solid #bfdbfe;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 18px;
}

.tenant-box-title {
  font-weight: 700;
  color: var(--brand-blue-dark);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.sso-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: #1d2733;
  border: 1px solid #8c8c8c;
  border-radius: 6px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  cursor: pointer;
}

.sso-btn:hover {
  background: #f3f4f6;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group.full {
  grid-column: 1 / -1;
}

label.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  color: #0f172a;
}

label.field-label .req {
  color: var(--brand-red);
  margin-left: 2px;
}

.field-hint {
  font-size: 0.83rem;
  color: var(--muted);
  margin: -2px 0 6px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="datetime-local"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(11, 92, 173, 0.15);
}

input.verified {
  border-color: #10b981;
  background: #f0fdf4;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-row input {
  flex: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand-blue);
  color: #fff;
}

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

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

.btn-secondary {
  background: #fff;
  color: var(--brand-blue);
  border-color: var(--brand-blue);
}

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

.btn-submit {
  background: var(--brand-red);
  color: #fff;
  padding: 13px 28px;
  font-size: 1.05rem;
  width: 100%;
}

.btn-submit:hover {
  background: #c8141c;
}

.radio-list,
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.12s;
}

.check-item:hover {
  background: #f8fafc;
}

.check-item input {
  margin-top: 4px;
  width: 16px;
  height: 16px;
  accent-color: var(--brand-blue);
  flex-shrink: 0;
}

.consent-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.sla-calc-box {
  background: #f8fafc;
  border: 1px dashed var(--brand-blue);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 8px 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
}

.sla-stat {
  display: flex;
  flex-direction: column;
}

.sla-stat strong {
  font-size: 1.05rem;
  color: var(--brand-blue-dark);
}

.thai-warning {
  color: #b45309;
  font-size: 0.82rem;
  margin-top: 4px;
  display: none;
}

.thai-warning.show {
  display: block;
}

.file-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.86rem;
}

.file-chip button {
  background: none;
  border: none;
  color: var(--brand-red);
  cursor: pointer;
  font-weight: 700;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.badge-submitted { background: #dbeafe; color: #1e40af; }
.badge-reviewing { background: #fef3c7; color: #92400e; }
.badge-submitted-ms { background: #e0e7ff; color: #3730a3; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

.hidden {
  display: none !important;
}

.admin-table-wrap {
  overflow-x: auto;
}

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

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--muted);
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 20px 16px;
}

@media (max-width: 680px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .card {
    padding: 18px 14px;
  }
  .input-row {
    flex-direction: column;
  }
}
