:root {
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-300: #93c5fd;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;
  --blue-950: #172554;

  --bg: #f0f5ff;
  --surface: #ffffff;
  --surface-muted: #f8fbff;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: var(--blue-600);
  --primary-dark: var(--blue-700);
  --primary-light: var(--blue-100);
  --border: #dbeafe;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #059669;
  --page-gutter: 16px;
  --success-bg: #ecfdf5;
  --shadow-sm: 0 4px 16px rgba(37, 99, 235, 0.08);
  --shadow-md: 0 12px 32px rgba(37, 99, 235, 0.12);
  --shadow-lg: 0 24px 48px rgba(30, 64, 175, 0.16);
  --radius: 16px;
  --radius-sm: 12px;
  --font-family-base: 'Kanit', sans-serif;
  --font-size-base: 14px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  width: 100%;
  max-width: 100%;
  scroll-behavior: smooth;
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  font-family: inherit;
  font-size: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  height: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
  max-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

.app-shell > .site-header {
  flex-shrink: 0;
}

.app-shell > .page-shell {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 0;
}

.app-shell > .site-footer {
  flex-shrink: 0;
}

.login-body {
  height: 100vh;
  min-height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-dark);
}

.container {
  width: 100%;
  max-width: 100vw;
  margin: 0;
  padding-inline: var(--page-gutter);
  box-sizing: border-box;
}

.site-header {
  background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-700) 100%);
  color: white;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  gap: 16px;
}

.site-header a {
  color: rgba(255, 255, 255, 0.92);
}

.site-header a:hover {
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 600;
  color: white;
}

.brand-title {
  font-size: 16px;
  line-height: 1.2;
}

.brand-subtitle {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.72);
}

.brand-badge {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: white;
  font-size: 16px;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.nav-links {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-link {
  padding: 8px 12px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  font-weight: 400;
  transition: background 0.2s ease, color 0.2s ease;
}

.header-link:hover {
  color: white;
  background: rgba(255, 255, 255, 0.12);
  text-decoration: none;
}

.header-divider {
  width: 1px;
  height: 42px;
  background: rgba(255, 255, 255, 0.18);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.profile-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.profile-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}

.profile-avatar-fallback {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.12));
  color: white;
  font-size: 13px;
  font-weight: 600;
}

.profile-status {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid var(--blue-800);
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.18);
}

.profile-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 180px;
}

.profile-name {
  color: white;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-email {
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  font-weight: 300;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-role {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.92);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.btn-header-logout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 13px;
  box-shadow: none;
}

.btn-header-logout:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: white;
  font-size: 13px;
}

.user-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
}

.page-shell {
  padding: 32px 0 56px;
}

.page-hero {
  margin-bottom: 24px;
  padding: 28px 32px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--blue-700) 0%, var(--blue-500) 100%);
  color: white;
  box-shadow: var(--shadow-md);
}

.page-hero h1 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 600;
}

.page-hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-weight: 300;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 22px 28px 0;
}

.card-body {
  padding: 28px;
}

.card-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
  color: var(--blue-900);
}

.card-subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-weight: 300;
  line-height: 1.6;
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--blue-800);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  gap: 18px;
}

.form-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--blue-900);
}

input,
select,
textarea {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input::placeholder {
  color: #94a3b8;
  font-weight: 300;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue-400);
  background: white;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  color: white;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.28);
}

.btn-primary:hover {
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.34);
}

.btn-secondary {
  background: white;
  color: var(--blue-800);
  border: 1px solid var(--border);
}

.site-header .btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.site-header .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 8px 14px;
  font-size: 13px;
}

.btn-link {
  background: var(--primary-light);
  color: var(--blue-800);
  border: 1px solid var(--blue-200);
  padding: 8px 14px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 400;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #a7f3d0;
}

.auth-layout {
  height: 100%;
  min-height: 100vh;
  max-height: 100vh;
  width: 100%;
  max-width: 100vw;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  overflow: hidden;
  box-sizing: border-box;
}

.auth-visual {
  position: relative;
  padding: 48px;
  background: linear-gradient(160deg, var(--blue-950) 0%, var(--blue-700) 55%, var(--blue-500) 100%);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.auth-visual::before,
.auth-visual::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.auth-visual::before {
  width: 280px;
  height: 280px;
  top: -80px;
  right: -60px;
}

.auth-visual::after {
  width: 360px;
  height: 360px;
  bottom: -120px;
  left: -100px;
}

.auth-visual-content {
  position: relative;
  z-index: 1;
  max-width: 460px;
}

.auth-visual h1 {
  margin: 0 0 16px;
  font-size: 34px;
  font-weight: 600;
  line-height: 1.2;
}

.auth-visual p {
  margin: 0 0 28px;
  font-size: 15px;
  font-weight: 300;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.86);
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 14px;
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 400;
}

.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.14);
  font-size: 14px;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 32px 24px;
  overflow-y: auto;
  background:
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.08), transparent 30%),
    var(--bg);
}

.auth-card {
  width: min(440px, 100%);
}

.auth-card .card {
  border: 1px solid rgba(219, 234, 254, 0.9);
  box-shadow: var(--shadow-lg);
}

.auth-note {
  margin-top: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  font-weight: 300;
}

.btn-google {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-height: 52px;
}

.btn-google:hover {
  background: var(--surface-muted);
  text-decoration: none;
}

.google-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.google-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.auth-footer {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 300;
}

.section-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--blue-900);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th,
td {
  padding: 16px 14px;
  text-align: left;
  font-size: 13px;
}

th {
  background: var(--blue-50);
  color: var(--blue-900);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

td {
  border-bottom: 1px solid #eef4ff;
  color: var(--text);
}

tbody tr:hover {
  background: #fafcff;
}

tbody tr:last-child td {
  border-bottom: none;
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 1px dashed var(--blue-200);
  border-radius: var(--radius-sm);
  font-weight: 300;
}

.empty-state-icon {
  font-size: 28px;
  margin-bottom: 10px;
}

.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--blue-800);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legal-content h2 {
  margin-top: 28px;
  margin-bottom: 10px;
  color: var(--blue-900);
  font-weight: 600;
}

.legal-content p,
.legal-content li {
  line-height: 1.8;
  color: var(--text-muted);
  font-weight: 300;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.site-footer {
  padding: 24px 0 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 300;
}

.hidden {
  display: none !important;
}

.dashboard-body {
  background:
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.08), transparent 28%),
    var(--bg);
  width: 100%;
  max-width: 100vw;
}

.dashboard-header-inner {
  width: 100%;
  max-width: 100vw;
  margin: 0;
  box-sizing: border-box;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  width: 100%;
  max-width: 100vw;
  margin: 0;
  box-sizing: border-box;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.dashboard-sidebar {
  position: sticky;
  top: 92px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.dashboard-nav {
  display: grid;
  gap: 8px;
}

.dashboard-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.dashboard-nav-item:hover {
  background: var(--surface-muted);
  border-color: var(--border);
}

.dashboard-nav-item.active {
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  color: white;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.24);
}

.nav-icon {
  width: 28px;
  text-align: center;
}

.dashboard-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dashboard-section {
  display: none;
}

.dashboard-section.active {
  display: block;
}

.dashboard-body .dashboard-section.active {
  flex: 1;
  min-height: 0;
}

.dashboard-body .dashboard-section-overview.active,
.dashboard-body .dashboard-section-fill.active {
  display: flex;
  flex-direction: column;
}

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

.section-desc {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-weight: 300;
  line-height: 1.6;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.stat-card-accent {
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
  color: white;
  border-color: transparent;
}

.stat-card-accent .stat-label,
.stat-card-accent .stat-hint {
  color: rgba(255, 255, 255, 0.82);
}

.stat-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  display: block;
  font-size: 28px;
  line-height: 1.1;
  margin-bottom: 8px;
}

.stat-value-sm {
  font-size: 16px;
  line-height: 1.4;
}

.stat-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 300;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  font: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.quick-action-btn:hover {
  transform: translateY(-1px);
  background: white;
  box-shadow: var(--shadow-sm);
}

.quick-action-btn span:first-child {
  font-size: 20px;
}

.badge-muted {
  background: #f1f5f9;
  color: #64748b;
}

.badge-info {
  background: #e0f2fe;
  color: #0369a1;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  font-weight: 400;
}

.checkbox-label input {
  width: auto;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  z-index: 1001;
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  height: fit-content;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-footer {
  border-bottom: none;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.modal-body {
  padding: 24px;
  flex: 0 1 auto;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}

.modal-header,
.modal-footer {
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  color: var(--blue-900);
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: var(--surface-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-actions-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .dashboard-body .dashboard-layout {
    overflow-y: auto;
    align-items: start;
  }

  .dashboard-body .dashboard-sidebar {
    height: auto;
    max-height: none;
  }

  .dashboard-body .dashboard-main {
    height: auto;
    overflow: visible;
  }

  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar {
    position: static;
  }

  .dashboard-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-layout {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .auth-visual {
    min-height: 240px;
    max-height: 42vh;
    padding: 32px 24px;
  }

  .auth-visual h1 {
    font-size: 26px;
  }
}

@media (max-width: 768px) {
  .form-grid.two-col {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .nav-links,
  .header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .header-divider {
    display: none;
  }

  .header-links {
    justify-content: center;
  }

  .profile-card {
    width: 100%;
    border-radius: var(--radius-sm);
  }

  .profile-meta {
    max-width: none;
    flex: 1;
  }

  .btn-header-logout {
    width: 100%;
    justify-content: center;
  }

  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-hero {
    padding: 24px;
  }
}
