:root {
  --bg-top: #f4e9d8;
  --bg-bottom: #fffaf1;
  --card: #fffdf8;
  --card-soft: #fff8ec;
  --line: #e4d8c4;
  --line-strong: #b4c7de;
  --text: #2f2416;
  --muted: #7b6851;
  --primary: #2f6fbe;
  --primary-strong: #24599a;
  --primary-soft: #f3eadc;
  --warn: #ffefcc;
  --danger: #9f1239;
  --row-alt: #f7efe3;
  --radius: 14px;
  --shadow: 0 10px 26px rgba(87, 63, 27, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom) 44%);
  color: var(--text);
}

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px 36px;
}

body.view-desktop #app {
  min-width: 1200px;
}

.card {
  max-width: 430px;
  margin: 64px auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

h1, h2, h3, h4 {
  margin: 0 0 8px;
}

label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
}

input,
select,
button {
  width: 100%;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid #c3d3e6;
  font: inherit;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid #9ec4f8;
  border-color: #78abef;
}

button {
  background: linear-gradient(180deg, #1c6fdd, var(--primary));
  border: none;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(15, 98, 201, 0.25);
  min-height: 38px;
}

button:hover {
  background: linear-gradient(180deg, #1263ca, var(--primary-strong));
}

button.secondary {
  background: #e7effb;
  color: #174173;
  box-shadow: none;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.brand p {
  margin: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

body.view-mobile #app {
  max-width: 100%;
  padding: 16px 12px 28px;
}

body.view-mobile .topbar {
  flex-direction: column;
  align-items: stretch;
}

body.view-mobile .top-actions {
  width: 100%;
  justify-content: flex-start;
}

body.view-mobile .tabs,
body.view-mobile .subtabs {
  gap: 6px;
  flex-wrap: wrap;
}

body.view-mobile .tabs {
  gap: 10px;
  justify-content: space-between;
  border-bottom: 0;
  padding-bottom: 0;
  margin: 8px 0 4px;
}

body.view-mobile .tabs .tab {
  flex: 1 1 30%;
  text-align: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--card-soft);
  color: var(--muted);
}

body.view-mobile .tabs .tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 6px 14px rgba(87, 63, 27, 0.12);
}

body.view-mobile .tabs .tab.active::after {
  display: none;
}

body.view-mobile .tabs .tab-indicator,
body.view-mobile .subtabs .tab-indicator,
body.view-mobile .leaves-subtabs .tab-indicator,
body.view-mobile .token-subtabs .tab-indicator {
  display: none;
}

body.view-mobile .subtabs {
  width: 100%;
  justify-content: space-between;
  border-radius: 18px;
  padding: 6px;
}

body.view-mobile .subtabs .tab {
  flex: 1 1 auto;
  text-align: center;
  padding: 8px 10px;
}

body.view-mobile .subtabs .tab.active {
  background: var(--card);
  color: var(--text);
  border-color: var(--line);
  box-shadow: 0 6px 14px rgba(87, 63, 27, 0.12);
}

body.view-mobile .leaves-subtabs {
  width: 100%;
  justify-content: space-between;
  border-radius: 18px;
}

body.view-mobile .leaves-subtabs .tab {
  flex: 1 1 auto;
  text-align: center;
  padding: 8px 10px;
}

body.view-mobile .token-subtabs {
  width: 100%;
  justify-content: space-between;
  border-radius: 18px;
}

body.view-mobile .token-subtabs .tab {
  flex: 1 1 auto;
  text-align: center;
  padding: 8px 10px;
}

body.view-mobile.dark .leaves-subtabs .tab.active {
  background: #1f2f47;
  color: #ffffff;
  border-color: #35527a;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

body.view-mobile.dark .subtabs .tab.active {
  background: #1f2f47;
  color: #ffffff;
  border-color: #35527a;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

body.view-mobile.dark .token-subtabs .tab.active {
  background: #1f2f47;
  color: #ffffff;
  border-color: #35527a;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

body.view-mobile .toolbar {
  grid-template-columns: 1fr;
}

body.view-mobile .manager-track-bar {
  flex-direction: column;
  align-items: stretch;
}

body.view-mobile .manager-track-bar label,
body.view-mobile .manager-track-bar button {
  width: 100%;
  min-width: 0;
}

body.view-mobile .split {
  grid-template-columns: 1fr;
}

body.view-mobile .calendar {
  gap: 4px;
}

body.view-mobile .day {
  min-height: 70px;
}

body.view-mobile .day-number {
  font-size: 12px;
}

body.view-mobile .leave-bar {
  font-size: 10px;
}

body.view-mobile table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

body.view-mobile th,
body.view-mobile td {
  padding: 7px 8px;
}

.top-actions #logoutBtn {
  width: auto;
  padding: 9px 14px;
}

.top-actions button {
  width: auto;
  min-height: 34px;
}

#catBtn {
  font-size: 16px;
  line-height: 1;
  padding: 8px 10px;
}

#catVanity {
  position: fixed;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) scale(0.85);
  font-size: 96px;
  opacity: 0;
  pointer-events: none;
  z-index: 60;
}

#catVanity.play {
  animation: cat-pop 1400ms ease-in-out forwards;
}

#catBubble {
  position: fixed;
  left: 50%;
  top: 54%;
  transform: translate(-50%, -50%);
  padding: 14px 22px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  z-index: 60;
}

#catBubble.show {
  animation: cat-bubble 1400ms ease-in-out forwards;
}

@keyframes cat-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.85) rotate(0deg); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.2) rotate(-10deg); }
  45% { opacity: 1; transform: translate(-50%, -50%) scale(1.28) rotate(8deg); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(-4deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9) rotate(0deg); }
}

@keyframes cat-bubble {
  0% { opacity: 0; transform: translate(-50%, -50%) translateY(10px); }
  15% { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
  70% { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) translateY(8px); }
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f6ebda;
  color: #5f4a2f;
  border: 1px solid #e4d4bb;
  font-size: 12px;
  font-weight: 600;
}

.pill.subtle {
  background: #f8f1e6;
  color: #7b6851;
  border-color: #e8dbc7;
}

.tabs {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: 10px 0 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  position: relative;
}

.subtabs {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0 12px;
  padding: 6px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  position: relative;
}

.tabs .tab {
  width: auto;
  padding: 6px 4px 10px;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  position: relative;
}

.tabs .tab.active {
  color: var(--text);
  font-weight: 700;
}

.subtabs .tab {
  width: auto;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  position: relative;
  z-index: 1;
  transition: color 180ms ease;
}

.subtabs .tab.active {
  background: transparent;
  color: var(--text);
  border-color: transparent;
  box-shadow: none;
}

.leaves-subtabs {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0 12px;
  padding: 6px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  position: relative;
}

.leaves-subtabs .tab {
  width: auto;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--card);
  color: var(--muted);
  box-shadow: none;
  position: relative;
  z-index: 1;
}

.leaves-subtabs .tab.active {
  color: var(--text);
  font-weight: 700;
  border-color: var(--line);
  box-shadow: 0 6px 14px rgba(87, 63, 27, 0.12);
}

.leaves-subtabs .tab-indicator {
  height: calc(100% - 10px);
  top: 5px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 6px 14px rgba(87, 63, 27, 0.12);
  border-radius: 999px;
  z-index: 0;
}

.token-subtabs {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0 12px;
  padding: 6px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  position: relative;
}

.token-subtabs .tab {
  width: auto;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--card);
  color: var(--muted);
  box-shadow: none;
  position: relative;
  z-index: 1;
  transition: color 180ms ease;
}

.token-subtabs .tab.active {
  color: var(--text);
  font-weight: 700;
  border-color: var(--line);
  box-shadow: 0 6px 14px rgba(87, 63, 27, 0.12);
}

.token-subtabs .tab-indicator {
  height: calc(100% - 10px);
  top: 5px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 6px 14px rgba(87, 63, 27, 0.12);
  border-radius: 999px;
  z-index: 0;
}

.tab-indicator {
  position: absolute;
  left: 0;
  top: 0;
  height: 4px;
  border-radius: 999px;
  background: var(--primary);
  transform: translateX(var(--tab-left, 0)) scaleX(0);
  transform-origin: left center;
  width: var(--tab-width, 0);
  transition: transform 220ms ease, width 220ms ease, opacity 200ms ease;
  opacity: 0;
  pointer-events: none;
}

.tabs .tab-indicator {
  bottom: -9px;
  top: auto;
}

.subtabs .tab-indicator {
  height: calc(100% - 10px);
  top: 5px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 6px 14px rgba(87, 63, 27, 0.12);
  border-radius: 999px;
  z-index: 0;
}

.tab-indicator[data-ready="1"] {
  opacity: 1;
  transform: translateX(var(--tab-left, 0)) scaleX(1);
}

.content {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  align-items: end;
}

.toolbar > * {
  margin-bottom: 0;
}

.toolbar > button {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 10px 16px;
  justify-self: stretch;
  align-self: end;
}

.manager-track-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -2px 0 12px;
  align-items: end;
}

.manager-track-bar label {
  margin: 0;
  flex: 1 1 240px;
  min-width: 220px;
}

.manager-track-bar button {
  width: auto;
  min-width: 240px;
  max-width: 100%;
  min-height: 40px;
}

#saveBranding,
#yearEndPreview,
#applyYearEnd {
  width: auto;
  min-width: 190px;
  min-height: 40px;
  padding: 10px 16px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

th,
td {
  padding: 8px 9px;
  vertical-align: top;
  border-bottom: 1px solid #e4ecf7;
}

.staff-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  margin: 2px 4px 2px 0;
  white-space: nowrap;
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.85),
    0 0 2px rgba(0, 0, 0, 0.65);
}

.col-helpdesk {
  background: #efe3cf;
}

.col-cover {
  background: #f4e6d2;
}

td button {
  width: auto;
  min-height: 30px;
  padding: 6px 10px;
  font-size: 12px;
  margin: 2px 6px 2px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

li button {
  width: auto;
  min-height: 30px;
  padding: 6px 10px;
  font-size: 12px;
  margin: 4px 6px 0 0;
  display: inline-flex;
  align-items: center;
}

.manager-access-panel {
  margin-bottom: 12px;
}

.manager-access-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  align-items: end;
}

.manager-access-form label {
  margin-bottom: 0;
}

.manager-access-perms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 12px;
  margin: 10px 0;
}

.manager-access-perms label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 600;
}

.manager-access-perms input[type="checkbox"],
.manager-access-table input[type="checkbox"] {
  width: auto;
}

.manager-access-actions {
  display: flex;
  justify-content: flex-start;
}

.manager-access-actions button {
  width: auto;
  min-width: 180px;
}

.manager-access-table td:last-child {
  white-space: nowrap;
}

.token-queue ul {
  list-style: none;
  padding-left: 0;
  margin: 8px 0 0;
}

.token-queue li {
  padding: 6px 0;
  border-bottom: 1px dashed rgba(120, 140, 170, 0.35);
}

.token-queue li:last-child {
  border-bottom: none;
}

.token-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f0e1c9;
  color: #4c3a24;
  font-weight: 700;
  margin-right: 6px;
}

.token-badge-waiting {
  background: rgba(170, 36, 41, 0.16);
  color: #8f1d22;
}

.token-badge-service {
  background: rgba(239, 192, 86, 0.28);
  color: #6f4c00;
}

.token-badge-recent {
  background: rgba(16, 123, 98, 0.16);
  color: #145a47;
}

.token-meta {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(47, 111, 190, 0.12);
  color: #203a63;
  font-size: 11px;
  font-weight: 600;
}

.token-wait {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(16, 123, 98, 0.22);
  color: #0f3f33;
  font-size: 11px;
  font-weight: 700;
}

.token-service {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(239, 192, 86, 0.35);
  color: #4a2f00;
  font-size: 11px;
  font-weight: 700;
}

.token-recent-item {
  padding: 6px 0;
}

.token-recent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.token-recent-details {
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
}

.token-active {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  text-align: center;
}

.token-active-number {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
}

.token-active-title {
  font-weight: 700;
}

.token-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.token-actions button {
  width: auto;
  min-width: 120px;
}

.token-staff {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.token-staff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.staff-bubble {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 70px;
}

.staff-bubble.busy {
  border-color: rgba(20, 90, 71, 0.45);
  background: linear-gradient(180deg, rgba(16, 123, 98, 0.12), rgba(16, 123, 98, 0.04));
}

.staff-bubble.leave {
  border-color: rgba(170, 36, 41, 0.55);
  background: linear-gradient(180deg, rgba(170, 36, 41, 0.16), rgba(170, 36, 41, 0.05));
}

.staff-bubble.pending {
  border-color: rgba(194, 140, 0, 0.55);
  background: linear-gradient(180deg, rgba(239, 192, 86, 0.22), rgba(239, 192, 86, 0.08));
}

.staff-name {
  font-weight: 700;
  color: var(--text);
}

.staff-status {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.token-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin: 8px 0 6px;
}

.appointments-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}

.appointments-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1200px;
}

.appointments-table th,
.appointments-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: left;
  vertical-align: middle;
}

.appointments-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.appointments-table td input,
.appointments-table td select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
}

.appointments-table td.appt-confirmed input[type="checkbox"] {
  width: auto;
  transform: scale(1.05);
}

.appointments-table td.appt-time {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.sales-schedule,
.sales-events {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.sales-schedule th,
.sales-schedule td,
.sales-events th,
.sales-events td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
}

.sales-schedule th,
.sales-events th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.sales-schedule tbody tr.sales-day-even td {
  background: var(--row-alt);
}

.sales-promoter-panel {
  margin-bottom: 12px;
}

.sales-promoter-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.promoter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: grab;
  user-select: none;
}

.promoter-name[contenteditable="true"] {
  cursor: text;
  user-select: text;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.6);
}

.promoter-chip.readonly {
  opacity: 0.7;
  cursor: default;
}

.promoter-chip .promoter-name {
  outline: none;
}

.sales-promoter-drop {
  min-height: 34px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 34, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-card {
  width: min(520px, 92vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.modal-card h3 {
  margin: 0 0 6px;
}

.modal-card p {
  margin: 0 0 8px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.insights-suggestions {
  display: grid;
  gap: 10px;
}

.insight-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--card);
}

.insight-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.insight-meta {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0;
}

.insight-action {
  font-weight: 600;
}

.insight-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

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

.insights-account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.insights-account-card {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 4px;
}

.insights-account-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 147, 255, 0.2);
}

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

.insights-list li {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  background: var(--card);
}

.insights-list li.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 147, 255, 0.2);
}

.insights-profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.insights-cases tr.active {
  background: var(--row-alt);
}

.case-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.case-tabs .tab {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
}

.case-tabs .tab.active {
  border-color: var(--primary);
}

.case-timeline {
  display: grid;
  gap: 8px;
}

.case-message {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
}

.case-message.from-customer {
  border-left: 4px solid #2f6fbe;
}

.case-message.from-dept {
  border-left: 4px solid #2f9e44;
}

.case-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.token-section {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.token-block ul {
  padding-left: 16px;
}

.insights-chat-log {
  margin-top: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 10px;
  max-height: 360px;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.insights-chat-msg {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.insights-chat-msg.from-user {
  border-left: 4px solid #2f6fbe;
}

.insights-chat-msg.from-ai {
  border-left: 4px solid #2f9e44;
}

.insights-chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.insights-chat-form input {
  flex: 1 1 auto;
  width: auto;
  min-width: 240px;
  min-height: 44px;
  padding: 10px 12px;
}

.insights-chat-form button {
  flex: 0 0 auto;
  width: auto;
  min-width: 100px;
  min-height: 44px;
  padding: 0 16px;
}

.ramadan-header td {
  background: #8b1e24;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.leave-bar.offday {
  background: rgba(88, 108, 136, 0.35);
  color: var(--text);
  border: 1px dashed rgba(88, 108, 136, 0.6);
}

body.dark .leave-bar.offday {
  background: rgba(86, 118, 168, 0.35);
  border-color: rgba(86, 118, 168, 0.7);
  color: #e8effa;
}

.appointments-table .appt-token {
  margin-left: 6px;
}

.appointment-link {
  margin: 12px 0 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.appointment-links {
  margin: 12px 0 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.appointment-links-search {
  margin: 8px 0 10px;
}

.appointment-links-search input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}

.appt-link-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appt-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.appointment-link-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.appointment-link-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 6px;
}

.appointment-link-form input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}

.appointment-link-form button {
  width: auto;
}

.appt-status-note {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 30, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-card {
  width: min(520px, 92vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.modal-title {
  font-weight: 800;
  margin-bottom: 10px;
}

.modal-body {
  display: grid;
  gap: 10px;
}

.modal-body label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.modal-body input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}

.modal-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.token-stats > div,
.token-stats-grid > div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.token-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.token-team-stats {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.team-stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 110px;
}

.team-stat-card.is-top {
  border-color: #e1b85b;
  box-shadow: 0 0 0 1px rgba(225, 184, 91, 0.45), 0 8px 20px rgba(225, 184, 91, 0.35);
  background: linear-gradient(180deg, #fff2c9, #fff8e3);
}

.team-stat-name {
  font-weight: 700;
  color: var(--text);
}

.team-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.team-stat-row strong {
  color: var(--text);
  font-size: 13px;
}

th {
  text-align: left;
  background: var(--primary-soft);
  color: #0f3f78;
  font-weight: 700;
}

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

tr:nth-child(even) td {
  background: #fff9ef;
}

.focus-row td {
  background: #e8f4ff !important;
  box-shadow: inset 0 0 0 1px #8dc0f8;
}

.warn td {
  background: var(--warn) !important;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.split {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 10px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  user-select: none;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 6px;
}

.weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 0;
}

.day {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 100px;
  padding: 4px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease;
  user-select: none;
}

.day.empty {
  background: transparent;
  border-style: dashed;
  border-color: rgba(128, 144, 168, 0.35);
  cursor: default;
}

.day:hover {
  border-color: #8bb4ea;
}

.day.sel {
  outline: 2px solid #5b8ed9;
}

.day.range {
  border-color: #5294e7;
  box-shadow: 0 0 0 2px rgba(82, 148, 231, 0.18), inset 0 0 0 1px rgba(82, 148, 231, 0.2);
  background: linear-gradient(180deg, #ffffff, #f2f8ff);
}

.day.inspect {
  border-color: #1668c7;
  box-shadow: 0 0 0 2px rgba(22, 104, 199, 0.28), inset 0 0 0 1px rgba(22, 104, 199, 0.25);
}

.day-number {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.leave-bar {
  margin-top: 4px;
  border-radius: 5px;
  font-size: 11px;
  padding: 2px 4px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leave-bar.pending {
  opacity: 0.45;
}

.leave-bar.manager-leave {
  border: 1px dashed rgba(255, 255, 255, 0.85);
  font-weight: 700;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--card-soft);
}

.row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.row > * {
  margin: 0;
}

ul {
  margin: 8px 0;
  padding-left: 18px;
}

li {
  margin-bottom: 4px;
}

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

  .topbar {
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .toolbar > button,
  #saveBranding,
  #yearEndPreview,
  #applyYearEnd {
    width: 100%;
    min-width: 0;
  }

  .manager-track-bar button,
  .manager-access-actions button {
    width: 100%;
    min-width: 0;
  }
}

body.dark {
  --bg-top: #0f1b2d;
  --bg-bottom: #0b1422;
  --card: #172338;
  --card-soft: #1a2940;
  --line: #2d3f5d;
  --line-strong: #3b5173;
  --text: #e8effa;
  --muted: #a7bbd9;
  --primary: #4f93ff;
  --primary-strong: #2f79ea;
  --primary-soft: #223653;
  --warn: #4e3e1f;
  --danger: #ff8aa5;
  --row-alt: #22385a;
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

body.dark input,
body.dark select {
  background: #0f1e33;
  color: #e8effa;
  border-color: #35527a;
}

body.dark input::placeholder {
  color: #9fb5d5;
}

body.dark .tabs {
  border-bottom-color: #2b3f5c;
}

body.dark .tabs .tab {
  color: #a7bbd9;
}

body.dark .tabs .tab.active {
  color: #ffffff;
}

body.dark .subtabs {
  background: #1b2a40;
  border-color: #2d3f5d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.dark .subtabs .tab {
  color: #b4c9e6;
}

body.dark .subtabs .tab.active {
  color: #ffffff;
  border-color: transparent;
  box-shadow: none;
}

body.dark .leaves-subtabs {
  background: #1b2a40;
  border-color: #2d3f5d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.dark .leaves-subtabs .tab {
  background: #1f2f47;
  color: #b4c9e6;
  border-color: #2d3f5d;
}

body.dark .leaves-subtabs .tab.active {
  color: #ffffff;
  border-color: #35527a;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

body.dark .leaves-subtabs .tab-indicator {
  background: #1f2f47;
  border-color: #35527a;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

body.dark .token-subtabs {
  background: #1b2a40;
  border-color: #2d3f5d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.dark .token-subtabs .tab {
  background: #1f2f47;
  color: #b4c9e6;
  border-color: #2d3f5d;
}

body.dark .token-subtabs .tab.active {
  color: #ffffff;
  border-color: #35527a;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

body.dark .token-subtabs .tab-indicator {
  background: #1f2f47;
  border-color: #35527a;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

body.dark .subtabs .tab-indicator {
  background: #1f2f47;
  border-color: #35527a;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

body.dark .pill {
  background: #1d3150;
  color: #d7e8ff;
  border-color: #38557f;
}

body.dark .pill.subtle {
  background: #1a2a41;
  color: #b9cbe6;
  border-color: #314a6c;
}

body.dark button.secondary {
  background: #273b58;
  color: #d8e8ff;
}

body.dark th {
  color: #d7e8ff;
}

body.dark .col-helpdesk {
  background: #213756;
}

body.dark .col-cover {
  background: #263f62;
}

body.dark .token-badge {
  background: #2b3e57;
  color: #dbe8ff;
}

body.dark .token-badge-waiting {
  background: rgba(170, 36, 41, 0.3);
  color: #ffd6d7;
}

body.dark .token-badge-service {
  background: rgba(239, 192, 86, 0.35);
  color: #ffe6a8;
}

body.dark .token-badge-recent {
  background: rgba(16, 123, 98, 0.28);
  color: #c9f4e0;
}

body.dark .token-meta {
  background: rgba(120, 168, 255, 0.28);
  color: #e6f0ff;
}

body.dark .token-wait {
  background: rgba(70, 190, 140, 0.32);
  color: #e3fff3;
}

body.dark .token-service {
  background: rgba(239, 192, 86, 0.38);
  color: #fff0c2;
}

body.dark .team-stat-card {
  background: #1f2f47;
  border-color: #2d3f5d;
}

body.dark .team-stat-card.is-top {
  background: linear-gradient(180deg, #3b2f15, #2b2313);
  border-color: #d4a64b;
  box-shadow: 0 0 0 1px rgba(212, 166, 75, 0.45), 0 10px 24px rgba(212, 166, 75, 0.28);
}

body.dark .team-stat-name {
  color: #f7f0dd;
}

body.dark .team-stat-row {
  color: #c3d5f0;
}

body.dark .team-stat-row strong {
  color: #f3f7ff;
}

body.dark tr:nth-child(even) td {
  background: #1a2941;
}

body.dark .focus-row td {
  background: #203b59 !important;
}

body.dark .day.range {
  background: linear-gradient(180deg, #1b2c45, #1f3656);
}

body.dark .day {
  background: #18283f;
}

body.dark .day.inspect {
  border-color: #67a7ff;
}
