:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-soft: #faf9f6;
  --border: #e5e1d8;
  --border-strong: #d3cec2;
  --ink: #192230;
  --ink-muted: #5f6876;
  --ink-faint: #8a929e;
  --primary: #1d3557;
  --primary-hover: #142742;
  --primary-soft: #e8eef6;
  --accent: #c9562e;
  --accent-soft: #fbece6;
  --success: #1b7a58;
  --success-soft: #e6f5ef;
  --warning: #b87312;
  --warning-soft: #fdf3e1;
  --danger: #b83333;
  --danger-soft: #fdeaea;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(25, 34, 48, 0.05);
  --shadow-md: 0 10px 30px rgba(25, 34, 48, 0.08);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, #2d5385 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.5px;
  box-shadow: 0 4px 12px rgba(29, 53, 87, 0.25);
}

.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13.5px;
  transition: all 0.16s ease;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(29, 53, 87, 0.2);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(201, 86, 46, 0.25);
}
.btn-accent:hover:not(:disabled) {
  background: #b14824;
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) {
  background: #146346;
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f5c7c7;
}
.btn-danger:hover:not(:disabled) {
  background: #fbdada;
}

.btn-outline {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
}
.btn-outline:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  color: var(--ink-muted);
  padding: 7px 11px;
}
.btn-ghost:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn-lg {
  padding: 13px 22px;
  font-size: 15px;
  border-radius: 12px;
}

.btn-full {
  width: 100%;
}

/* Badges / Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #eceae4; color: var(--ink-muted); }

/* Layout Containers */
.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.mobile-container {
  max-width: 520px;
  margin: 0 auto;
  padding: 18px 16px 56px;
}

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

.card-soft {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

/* Landing Hero */
.hero-card {
  background: linear-gradient(135deg, #1d3557 0%, #274772 58%, #2e537d 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 38px 34px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  margin-bottom: 26px;
}

.hero-card::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 86, 46, 0.35), transparent 70%);
  pointer-events: none;
}

.hero-pill {
  display: inline-block;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #f4f7fb;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 14px;
}

.hero-title {
  margin: 0 0 10px;
  font-size: clamp(24px, 3.2vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.hero-desc {
  margin: 0 0 22px;
  max-width: 720px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 15px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

/* Admin Workspace Split */
.admin-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.course-item {
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 10px;
}

.course-item:hover {
  border-color: var(--primary);
}

.course-item.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.course-code {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.4px;
}

.course-name {
  font-weight: 700;
  font-size: 14.5px;
  margin: 2px 0 6px;
}

.course-meta {
  font-size: 12px;
  color: var(--ink-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-muted);
  border-bottom: 2.5px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Assignment cards */
.assignment-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  background: var(--surface);
  margin-bottom: 14px;
  transition: box-shadow 0.15s ease;
}

.assignment-card:hover {
  box-shadow: var(--shadow-sm);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.row-gap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 53, 87, 0.12);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 640px) {
  .form-row-2, .form-row-3 {
    grid-template-columns: 1fr;
  }
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th, td {
  padding: 11px 13px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

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

/* Calling / Queue Desk */
.calling-banner {
  background: linear-gradient(135deg, #fffaf6 0%, #fef1ea 100%);
  border: 1.5px solid #f0c2ae;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 18px;
}

.ticket-big-no {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.queue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.ticket-pill {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 16px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  min-width: 78px;
  text-align: center;
}

/* Stats strip */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.stat-val {
  font-size: 24px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--primary);
}

.stat-label {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* Time Slots Grid */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.slot-card {
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  transition: all 0.15s ease;
  text-align: left;
}

.slot-card.selectable:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.slot-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px rgba(201, 86, 46, 0.22);
}

.slot-card.booked {
  background: #f2f1ed;
  border-color: var(--border);
  opacity: 0.72;
  cursor: not-allowed;
}

/* Student Mobile Ticket */
.student-header {
  background: linear-gradient(135deg, var(--primary) 0%, #2b4c79 100%);
  color: #fff;
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}

.ticket-card-active {
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: 18px;
  padding: 22px 20px;
  text-align: center;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
}

.ticket-card-calling {
  background: linear-gradient(180deg, #fff5ef 0%, #ffffff 100%);
  border: 2.5px solid var(--accent);
  animation: pulseRing 1.8s infinite;
}

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(201, 86, 46, 0.35); }
  70% { box-shadow: 0 0 0 14px rgba(201, 86, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 86, 46, 0); }
}

.student-ticket-no {
  font-family: var(--font-mono);
  font-size: 46px;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -1px;
  margin: 8px 0;
}

.ticket-card-calling .student-ticket-no {
  color: var(--accent);
}

/* Projector Display Mode */
.display-shell {
  min-height: 100vh;
  background: #0e1624;
  color: #f4f6fa;
  display: flex;
  flex-direction: column;
  padding: 24px 32px;
}

.display-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 28px;
  margin-top: 20px;
  align-items: stretch;
}

@media (max-width: 960px) {
  .display-grid {
    grid-template-columns: 1fr;
  }
}

.display-panel {
  background: #172338;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  padding: 26px;
}

.display-qr-wrap {
  background: #fff;
  padding: 16px;
  border-radius: 18px;
  display: inline-flex;
  margin: 16px 0;
}

.display-serving-box {
  background: linear-gradient(135deg, #c9562e 0%, #df6c43 100%);
  border-radius: 20px;
  padding: 28px 32px;
  margin-bottom: 22px;
  box-shadow: 0 16px 40px rgba(201, 86, 46, 0.35);
}

.display-serving-no {
  font-family: var(--font-mono);
  font-size: clamp(48px, 6vw, 76px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -1px;
}

.display-queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  margin-bottom: 12px;
  font-size: 20px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(4px);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #192230;
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  max-width: 90vw;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

.muted { color: var(--ink-muted); }
.small { font-size: 12.5px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
