* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', Tahoma, 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  padding: 16px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
  padding: 32px;
  width: 100%;
  max-width: 400px;
}
.login-title { font-size: 24px; text-align: center; color: var(--primary); margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; font-family: inherit; background: #f8fafc;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--primary); border-color: transparent;
}
.field textarea { min-height: 70px; resize: vertical; }
.error-msg { color: var(--danger); margin-top: 10px; font-size: 14px; text-align: center; min-height: 20px; }
.req { color: var(--danger); }

/* ===== BUTTONS ===== */
.btn {
  padding: 10px 16px; border: none; border-radius: 8px; font-size: 14px;
  cursor: pointer; font-family: inherit; transition: all .15s; font-weight: 600;
}
.btn:active { transform: scale(.98); }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f1f5f9; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ===== TOP BAR ===== */
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; position: sticky; top: 0; z-index: 30;
  box-shadow: var(--shadow);
}
.hamburger { background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px 8px; }
.app-title { font-weight: 700; font-size: 15px; line-height: 1.25; margin-left: 8px; }
.app-company { display: block; font-weight: 400; font-size: 11px; color: var(--muted); letter-spacing: .2px; }
.topbar .app-title { color: var(--primary); }
.topbar .app-company { color: var(--muted); }
.login-title .app-company { font-size: 13px; margin-top: 2px; }
.login-sub .app-company { font-size: 12px; margin-top: 2px; color: var(--muted); }
.topbar-left { display: flex; align-items: center; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-badge { font-weight: 600; font-size: 14px; color: var(--muted); }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 250px; background: #0f172a;
  color: #94a3b8; overflow-y: auto; z-index: 50; transform: translateX(-100%);
  transition: transform .25s ease; padding-top: 20px;
}
.sidebar.open { transform: translateX(0); }
.sidebar-brand { padding: 0 20px 16px; font-weight: 700; font-size: 17px; line-height: 1.3; color: #fff; border-bottom: 1px solid #1e293b; margin-bottom: 10px; }
.sidebar-brand .app-company { font-weight: 400; font-size: 12px; color: #94a3b8; margin-top: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 12px 20px; color: #94a3b8; text-decoration: none; font-size: 14px; }
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-role { display: none; }
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 45; display: none;
}

/* ===== CONTENT ===== */
.content {
  padding: 16px; max-width: 1200px; margin: 0 auto;
}
.page { display: none; }
.page.active { display: block; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; } }

.page-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 16px; font-size: 14px; }

/* ===== CARDS ===== */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 16px;
}
.card-title { font-weight: 700; font-size: 16px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #f8fafc; font-weight: 700; color: var(--muted); }
tr:hover { background: #f8fafc; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-orange { background: #fed7aa; color: #c2410c; }
.badge-purple { background: #e9d5ff; color: #7e22ce; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #e2e8f0; color: #475569; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: #fff; border-radius: 14px; max-width: 640px; width: 100%;
  max-height: 90vh; overflow-y: auto; padding: 24px; position: relative;
  box-shadow: 0 20px 40px rgba(0,0,0,.3); animation: fadeIn .2s;
}
.modal-close {
  position: absolute; top: 12px; right: 12px; background: none; border: none;
  font-size: 20px; cursor: pointer; color: var(--muted);
}
.modal h3 { margin-bottom: 16px; }

/* ===== TOAST ===== */
#toastContainer { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: 90%; max-width: 400px; }
.toast { padding: 12px 16px; border-radius: 8px; color: #fff; font-weight: 600; box-shadow: var(--shadow); animation: slideUp .3s; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--primary); }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; } }

/* ===== CALENDAR ===== */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.cal-toolbar select, .cal-toolbar input, .cal-toolbar button { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; }
.cal-toolbar .btn { border: none; }
.cal-type-btn { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }
.cal-type-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.calendar-view { display: grid; grid-template-columns: 60px 1fr; gap: 4px; }
.calendar-day-header { display: grid; grid-column: 2; }
.calendar-grid { display: grid; grid-template-columns: 60px 1fr; gap: 4px; }
.time-col { display: grid; }
.time-slot { border-top: 1px solid var(--border); height: 60px; font-size: 11px; color: var(--muted); }
.cal-cell { position: relative; height: 60px; border: 1px solid var(--border); border-radius: 4px; background: #fff; overflow: hidden; }
.cal-event { position: absolute; left: 2px; right: 2px; border-radius: 4px; padding: 2px 6px; font-size: 11px; overflow: hidden; cursor: pointer; z-index: 2; }
.cal-event.approved { background: #dbeafe; border-left: 3px solid var(--primary); }
.cal-event.cancelling { background: #fed7aa; border-left: 3px solid var(--warning); }

/* Month view */
.cal-monthend { margin-top: 12px; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month-day { border: 1px solid var(--border); border-radius: 6px; min-height: 80px; padding: 4px; background: #fff; cursor: pointer; }
.month-day .day-num { font-weight: 700; font-size: 12px; color: var(--muted); }
.month-day:hover { border-color: var(--primary); }
.month-day.weekend { background: #f8fafc; }
.month-ev { font-size: 10px; background: var(--primary); color: #fff; border-radius: 3px; padding: 1px 4px; margin-top: 2px; overflow: hidden; white-space: nowrap; }
.month-ev.cancelling { background: var(--warning); }
.day-names { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; margin-bottom: 4px; }
.day-names div { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }

/* ===== FILTER ROOM AVAILABILITY ===== */
.free-badge { display: inline-block; padding: 8px 14px; border-radius: 8px; font-weight: 700; margin: 4px; }
.free-badge.available { background: #dcfce7; color: #166534; }
.free-badge.booked { background: #fee2e2; color: #b91c1c; }

/* ===== STAT CARDS ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: #fff; border-radius: 10px; box-shadow: var(--shadow); padding: 16px; text-align: center; }
.stat-card .num { font-size: 28px; font-weight: 800; }
.stat-card .label { color: var(--muted); font-size: 13px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; background: #f1f5f9; padding: 6px 12px; border-radius: 20px; margin: 3px; }

@media (min-width: 769px) {
  .sidebar { transform: translateX(0); }
  .content { margin-left: 250px; }
  .hamburger { display: none; }
}
