:root {
  --bg-color: var(--tg-theme-bg-color, #f4f4f5);
  --text-color: var(--tg-theme-text-color, #000000);
  --btn-color: var(--tg-theme-button-color, #3390ec);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --card-bg: #ffffff;
  --card-bg-rgb: 255, 255, 255;
  --border-color: #eee;
  --inner-bg: rgba(100, 100, 100, 0.05);
  --form-title-color: #000000;
  --form-input-color: #4d4d4d;
  --banner-bg: rgba(0, 0, 0, 0.03);
  --desc-color: #555;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: var(--tg-theme-bg-color, #121212);
    --text-color: var(--tg-theme-text-color, #e0e0e0);
    --card-bg: #1e1e1e;
    --card-bg-rgb: 30, 30, 30;
    --border-color: #333;
    --inner-bg: rgba(255, 255, 255, 0.06);
    --form-title-color: #ffffff;
    --form-input-color: #e0e0e0;
    --banner-bg: rgba(255, 255, 255, 0.04);
    --desc-color: #ccc;
  }
  .glass {
    background: rgba(35, 35, 35, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5) !important;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  margin: 0;
  padding: 0;
  overscroll-behavior-y: none;
  -webkit-overflow-scrolling: touch;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.4s ease, color 0.4s ease;
  display: flex;
  flex-direction: column;
}

.glass {
  background: rgba(var(--card-bg-rgb), 0.82) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(150, 150, 150, 0.15);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
  border-radius: 20px;
}

/* Animations */
.fade-in { animation: fadeIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.slide-up-fade { animation: slideUpFade 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.slide-in-right { animation: slideInRight 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.slide-in-left { animation: slideInLeft 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.slide-down-fade { animation: slideDownFade 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes fadeIn { 
  0% { opacity: 0; transform: scale(0.985); } 
  100% { opacity: 1; transform: scale(1); } 
}
@keyframes slideUpFade { 
  0% { opacity: 0; transform: translateY(14px); } 
  100% { opacity: 1; transform: translateY(0); } 
}
@keyframes slideInRight { 
  0% { opacity: 0; transform: translateX(20px); } 
  100% { opacity: 1; transform: translateX(0); } 
}
@keyframes slideInLeft { 
  0% { opacity: 0; transform: translateX(-20px); } 
  100% { opacity: 1; transform: translateX(0); } 
}
@keyframes slideDownFade { 
  0% { opacity: 0; transform: translateY(-14px); } 
  100% { opacity: 1; transform: translateY(0); } 
}
@keyframes modalScaleIn {
  0% { opacity: 0; transform: scale(0.92) translateY(12px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Modal Overlay & Centered Dialogs */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  animation: fadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-content {
  animation: modalScaleIn 0.26s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#loader-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-color);
  z-index: 1000;
  transition: opacity 0.4s ease, visibility 0.4s;
}

/* Headers */
.fixed-header {
  padding: calc(env(safe-area-inset-top, 12px) + 8px) 14px 10px 14px;
  flex-shrink: 0;
  z-index: 100;
  border-radius: 0 0 20px 20px;
  border-top: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  width: 100%;
  max-width: 540px;
  margin-bottom: 6px;
}

.top-icons {
  display: flex;
  gap: 6px;
  align-items: center;
  background: rgba(150, 150, 150, 0.1);
  padding: 4px;
  border-radius: 16px;
}

.icon-btn {
  font-size: 20px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.3s;
  padding: 6px 10px;
  border-radius: 12px;
  opacity: 0.5;
}

.icon-btn:active { transform: scale(0.88); }
.icon-btn.active-tab {
  opacity: 1;
  background: var(--card-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
@media (prefers-color-scheme: dark) {
  .icon-btn.active-tab { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }
}

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 25;
  padding: 10px 12px;
  margin: 0 0 10px 0;
  border-radius: 16px;
  transition: 0.3s;
}

/* Scroll Container */
.hidden { display: none !important; }

.scrollable-content {
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 14px calc(35px + env(safe-area-inset-bottom)) 14px;
  -webkit-overflow-scrolling: touch;
}

/* Responsive wrappers */
.responsive-pane {
  width: 100%;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.scrollable-content > div:not(.hidden) {
  width: 100%;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

/* Inputs & Form controls */
input, select, textarea {
  user-select: text;
  -webkit-user-select: text;
  transition: 0.3s;
  font-family: inherit;
}

input[type="text"], input[type="number"], input[type="date"], select, textarea {
  display: block;
  width: 100%;
  height: 46px;
  padding: 0 14px;
  margin: 8px 0;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 14px;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  background-color: var(--card-bg);
  color: var(--text-color);
}

textarea {
  height: auto;
  padding: 10px 14px;
  resize: vertical;
}

input[type="text"]:not(.smart-date), input[type="number"], select {
  text-align: left;
}

@media (prefers-color-scheme: dark) {
  input, select, textarea {
    border: 1px solid #444;
  }
}

.smart-date {
  color: var(--btn-color);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: normal;
}

/* Buttons */
button {
  width: 100%;
  padding: 12px 14px;
  margin: 5px 0;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  color: var(--btn-text);
  background: var(--btn-color);
  transition: transform 0.1s, background-color 0.3s, opacity 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  filter: grayscale(100%);
}

button:active:not(:disabled) {
  transform: scale(0.97);
  opacity: 0.9;
}

.btn-unavailable {
  opacity: 0.55 !important;
  filter: grayscale(35%) !important;
  cursor: pointer !important;
}

.btn-break { background-color: #f39c12; color: #fff; }
.btn-lunch { background-color: #27ae60; color: #fff; }
.btn-snack { background-color: #8e44ad; color: #fff; }
.btn-return { background-color: #e74c3c; color: #fff; }
.btn-green { background-color: #27ae60; color: white; }
.btn-orange { background-color: #f39c12; color: white; }
.btn-gray { background-color: #95a5a6; color: white; }
.btn-red { background-color: #e74c3c; color: white; }

.desc {
  font-size: 11px;
  opacity: 0.9;
  font-weight: normal;
  margin-top: 2px;
}

/* Cards */
.card {
  background: var(--card-bg);
  padding: 14px;
  border-radius: 16px;
  margin-bottom: 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
  transition: 0.4s;
  border: 1px solid var(--border-color);
}

.card h3 {
  margin: 0 0 10px 0;
  font-size: 15px;
  color: var(--btn-color);
}

@media (prefers-color-scheme: dark) {
  .card { box-shadow: none; }
  .req-item { background: var(--card-bg); border: 1px solid var(--border-color); }
}

.form-dark h3 { color: var(--form-title-color) !important; }
.form-dark input, .form-dark select { color: var(--form-input-color) !important; }

/* Badges & Navigation */
.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #e74c3c;
  color: white;
  border-radius: 50%;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: bold;
  border: 2px solid var(--bg-color);
  transition: 0.3s;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

/* Info Dashboard Banner */
.banner-wrapper {
  background: var(--banner-bg);
  border-radius: 16px;
  padding: 8px;
  margin-bottom: 4px;
  border: 1px solid rgba(150, 150, 150, 0.05);
  transition: 0.4s;
  width: 100%;
  max-width: 540px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  box-sizing: border-box !important;
}

.info-wrapper {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.scrollable-blocks {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding-bottom: 2px;
  flex: 1;
  scroll-snap-type: x mandatory;
}
.scrollable-blocks::-webkit-scrollbar { display: none; }

.info-box {
  background: var(--card-bg);
  padding: 8px 6px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  transition: 0.3s;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-shrink: 0;
  min-width: 65px;
  scroll-snap-align: start;
  border: 1px solid rgba(150, 150, 150, 0.05);
}

.info-box.pts-box { width: 100%; max-width: 150px; padding-left: 6px; padding-right: 6px; }
.info-box:active { transform: scale(0.96); }
.info-box.tabel-box { min-width: 120px; }

.circle-box {
  width: 62px;
  min-width: 62px;
  height: 62px;
  border-radius: 50%;
  padding: 0;
  align-items: center;
  justify-content: center;
  margin: auto 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  background: none;
  border: none;
}

.kpi-container {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.4s ease;
}

.kpi-inner {
  width: 84%;
  height: 84%;
  background: var(--card-bg);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.info-box-title {
  font-size: 9px;
  color: gray;
  text-transform: uppercase;
  font-weight: bold;
  white-space: nowrap;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}

.info-box-value {
  font-size: 15px;
  font-weight: bold;
  color: var(--btn-color);
  transition: 0.3s;
}

.tabel-grid {
  display: flex;
  gap: 6px;
  font-size: 10px;
  font-weight: bold;
  color: var(--text-color);
  justify-content: center;
}

.tabel-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tabel-lbl {
  color: gray;
  font-size: 8px;
  margin-bottom: 2px;
}

.inner-block {
  background: var(--inner-bg);
  border-radius: 12px;
  padding: 10px;
  transition: 0.3s;
  margin-bottom: 10px;
}

/* Requests */
.req-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.req-item {
  padding: 10px;
  border-radius: 12px;
  background: var(--card-bg);
  border-left: 4px solid var(--btn-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  transition: 0.3s;
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.req-item.admin { border-left-color: #3498db; }
.req-title { font-weight: bold; margin-bottom: 4px; font-size: 13px; }
.req-desc { font-size: 12px; color: gray; margin-bottom: 8px; line-height: 1.3; }

.grid-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.grid-btns button {
  padding: 10px;
  margin: 0;
  font-size: 12px;
  display: block;
}

/* Detail & List items */
.detail-item {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  transition: 0.3s;
}
.detail-item:last-child { border-bottom: none; }
.detail-plus { color: #27ae60; font-weight: bold; font-size: 13px; }
.detail-minus { color: #e74c3c; font-weight: bold; font-size: 13px; }
.detail-fine { color: #c0392b; font-weight: bold; font-size: 13px; }
.detail-val { font-weight: bold; font-size: 13px; color: var(--btn-color); }

.sc-item {
  padding: 10px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  cursor: pointer;
  transition: 0.3s;
  border-radius: 10px;
}
.sc-item:active { background: var(--inner-bg); }
.sc-item.selected {
  border-color: var(--btn-color) !important;
  background: rgba(52, 152, 219, 0.12) !important;
  box-shadow: 0 0 0 1.5px var(--btn-color) !important;
}

.sc-list-container {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  margin-bottom: 10px;
  background: var(--card-bg);
  transition: 0.3s;
}

.grid-details-container {
  padding: 8px;
  background: var(--card-bg);
  border-radius: 12px;
  transition: 0.3s;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border-color);
}
.grid-details-title {
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 6px;
  color: var(--text-color);
}
.grid-details-box {
  display: grid;
  gap: 2px;
  text-align: center;
  align-items: center;
  justify-content: center;
}
.grid-details-header {
  font-size: 9px;
  color: gray;
  font-weight: bold;
  margin-bottom: 2px;
  text-transform: uppercase;
}
.grid-details-value { font-size: 12px; margin-top: 0; }

.active-outs-box {
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  text-align: left;
  margin-top: 15px;
  transition: 0.3s;
}
.active-outs-title {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text-color);
}
.active-out-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}
.active-out-item:last-child { border-bottom: none; }
.active-out-name { font-weight: bold; color: var(--text-color); }
.active-out-time { color: var(--btn-color); font-weight: bold; }
.active-out-time.late { color: #e74c3c; }

.admin-flt {
  padding: 8px 4px;
  font-size: 11px;
  margin: 0;
  flex: 1;
  background: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: 0.3s;
  text-align: center;
}
.admin-flt.active-flt {
  background: var(--btn-color);
  color: #fff;
  border-color: var(--btn-color);
  font-weight: bold;
}
.admin-flt.focus-flt.active-flt {
  background: #e74c3c;
  border-color: #e74c3c;
}

#toast {
  position: fixed;
  bottom: env(safe-area-inset-bottom, 25px);
  left: 50%;
  transform: translateX(-50%);
  background: #34495e;
  color: white;
  padding: 12px 24px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
  z-index: 2000;
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
  opacity: 0;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-12px);
}

/* DESKTOP & WIDE SCREEN ADAPTATION */
@media (min-width: 641px) {
  body {
    background-color: var(--bg-color);
  }
  .scrollable-content {
    padding-left: 20px;
    padding-right: 20px;
  }
  #standard-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 10px;
  }
  #standard-buttons button {
    margin: 0;
    min-height: 75px;
  }
  .card {
    padding: 18px;
    border-radius: 18px;
  }
  #auth-screen {
    max-width: 440px !important;
    margin: 60px auto 0 auto !important;
    padding: 28px !important;
    background: var(--card-bg) !important;
    border-radius: 24px !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06) !important;
  }
}

/* MOBILE SCREEN ADAPTATION */
@media (max-width: 640px) {
  .scrollable-content {
    padding-left: 10px;
    padding-right: 10px;
  }
  #standard-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  #standard-buttons button {
    margin: 0;
    min-height: 56px;
  }
}


/* --- LAPTOP & DESKTOP TABEL & CALENDAR PROPORTIONS --- */
#user-personal-calendar-box,
.tabel-calendar-box,
.cal-grid-container {
  max-width: 440px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.cal-day-cell {
  max-width: 46px !important;
  max-height: 46px !important;
  margin: 0 auto !important;
  font-size: 11px !important;
}

#content-create,
#menu-list,
#content-details,
#content-time,
.banner-wrapper,
#form-sc,
#form-tradein,
#form-points,
#form-swap {
  max-width: 540px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

#admin-plus-dropdown-menu {
  z-index: 10001 !important;
  background: var(--card-bg) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 14px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
}

@media (min-width: 641px) {
  #admin-tabel-summary-modal-overlay > .card,
  #admin-fines-summary-modal-overlay > .card,
  #admin-points-summary-modal-overlay > .card {
    max-width: 680px !important;
    width: 90% !important;
  }
}

/* Hot Checks & Admin Parameters styling */
.hc-dept-tab {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-color);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.hc-dept-tab.active {
  background: #3498db !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(52, 152, 219, 0.35);
}
.hc-row-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 8px;
  border-radius: 10px;
  margin-bottom: 6px;
  transition: border-color 0.2s;
}
.hc-row-item:hover {
  border-color: rgba(52, 152, 219, 0.5);
}

