* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--tg-bg, #ffffff);
  color: var(--tg-text, #111111);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#header {
  padding: 12px 16px 6px;
  flex-shrink: 0;
}
#header h1 {
  font-size: 18px;
  margin: 0;
}

#content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 90px;
}

#nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--tg-secondary-bg, #f4f4f5);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 8px 2px;
  font-size: 12px;
  color: var(--tg-hint, #8a96a3);
  border-radius: 10px;
}
.nav-btn.active {
  color: var(--tg-button, #f2660b);
  font-weight: 600;
  background: rgba(242, 102, 11, 0.1);
}

.loading, .empty {
  color: var(--tg-hint, #8a96a3);
  padding: 24px 0;
  text-align: center;
  font-size: 14px;
}

.error-box {
  background: #fbe6e6;
  color: #b33;
  padding: 10px 12px;
  border-radius: 10px;
  margin: 10px 0;
  font-size: 13px;
}

.access-denied {
  padding: 40px 16px;
  text-align: center;
}

.back-btn {
  background: none;
  border: none;
  color: var(--tg-link, #2aabee);
  font-size: 14px;
  padding: 6px 0 12px;
}

.section-title {
  font-size: 15px;
  margin: 18px 0 8px;
  color: var(--tg-hint, #8a96a3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.menu-item {
  text-align: left;
  padding: 16px;
  border-radius: 12px;
  background: var(--tg-secondary-bg, #f4f4f5);
  border: none;
  font-size: 15px;
  color: var(--tg-text, #111);
}

.filter-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.chip-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}
.chip {
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: transparent;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  white-space: nowrap;
  color: var(--tg-text, #111);
}
.chip-active {
  background: var(--tg-button, #f2660b);
  border-color: var(--tg-button, #f2660b);
  color: var(--tg-button-text, #fff);
}

.select, .input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: var(--tg-secondary-bg, #f4f4f5);
  color: var(--tg-text, #111);
  font-size: 14px;
  margin-bottom: 8px;
}
.select-inline { margin-bottom: 0; }

textarea.input { resize: vertical; }

.field-label {
  display: block;
  font-size: 12.5px;
  color: var(--tg-hint, #8a96a3);
  margin: 10px 0 4px;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  background: var(--tg-secondary-bg, #f4f4f5);
  border-radius: 12px;
  padding: 12px 14px;
}
.card-row-only {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-title {
  font-size: 14.5px;
  font-weight: 600;
}
.card-sub {
  font-size: 12.5px;
  color: var(--tg-hint, #8a96a3);
  margin-top: 2px;
}
.card-meta {
  font-size: 12.5px;
  margin-top: 4px;
}
.card-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-free { background: #e3f3e9; color: #2e9e5b; }
.badge-busy { background: #fbe6e6; color: #d64545; }
.badge-maintenance { background: #fcf1dd; color: #c6820a; }
.badge-inactive { background: #e7e7ea; color: #6b7480; }
.badge-info { background: #ddf0fc; color: #1a7bab; }

.btn {
  display: block;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 14.5px;
  font-weight: 600;
  margin: 6px 0;
}
.btn-primary { background: var(--tg-button, #f2660b); color: var(--tg-button-text, #fff); }
.btn-secondary { background: var(--tg-secondary-bg, #ebebee); color: var(--tg-text, #111); border: 1px solid rgba(0,0,0,0.1); }

.btn-link {
  background: none;
  border: none;
  color: var(--tg-link, #2aabee);
  font-size: 13px;
  padding: 4px 0;
}
.btn-link-danger { color: #d64545; }

.btn-icon {
  background: var(--tg-secondary-bg, #ebebee);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 32px;
  font-size: 15px;
}

.inline-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--tg-secondary-bg, #f4f4f5);
  padding: 10px;
  border-radius: 12px;
  margin-bottom: 10px;
}
.inline-form.hidden { display: none; }

.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  font-size: 14px;
}
.radio-row-group {
  display: flex;
  flex-direction: column;
}

.date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.date-label {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  text-transform: capitalize;
}

.hour-grid {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
}
.hour-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 13px;
}
.hour-label {
  width: 46px;
  color: var(--tg-hint, #8a96a3);
  flex-shrink: 0;
}
.hour-content {
  flex: 1;
}
.hour-busy {
  background: rgba(214, 69, 69, 0.1);
  color: #b33;
  font-weight: 500;
}

.hint-text {
  font-size: 12.5px;
  color: var(--tg-hint, #8a96a3);
  margin: 4px 0 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%) translateY(20px);
  background: #1b2027;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  max-width: 85%;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error {
  background: #d64545;
}
