:root {
  --bg: var(--tg-theme-bg-color, #f4f4f5);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #888);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #fff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #fff);
  --card: #ffffff;
  --border: rgba(0,0,0,0.08);
  --green: #22a559;
  --red: #e5484d;
  --orange: #f0a02c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 12px;
  padding-bottom: 32px;
}

.card {
  background: var(--secondary-bg);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.greeting { font-size: 20px; font-weight: 700; margin: 4px 0 2px; }
.subtext { color: var(--hint); font-size: 14px; margin-bottom: 8px; }

.status-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 15px; }
.status-row .label { color: var(--hint); }
.status-row .value { font-weight: 600; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.green { background: rgba(34,165,89,0.15); color: var(--green); }
.badge.red { background: rgba(229,72,77,0.15); color: var(--red); }
.badge.orange { background: rgba(240,160,44,0.15); color: var(--orange); }

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 10px;
  background: var(--button);
  color: var(--button-text);
}
.btn:disabled { opacity: 0.5; }
.btn.secondary { background: rgba(36,129,204,0.12); color: var(--link); }
.btn.danger { background: rgba(229,72,77,0.12); color: var(--red); }

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

.stat-box { text-align: center; padding: 10px 4px; }
.stat-box .num { font-size: 20px; font-weight: 800; }
.stat-box .label { font-size: 12px; color: var(--hint); margin-top: 2px; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); margin: 18px 4px 8px; }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar .day { aspect-ratio: 1; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 12px; background: rgba(0,0,0,0.04); }
.calendar .day.present { background: rgba(34,165,89,0.18); color: var(--green); font-weight: 700; }
.calendar .day.late { background: rgba(240,160,44,0.2); color: var(--orange); font-weight: 700; }

.toast {
  position: fixed; left: 12px; right: 12px; bottom: 16px;
  background: #222; color: #fff; padding: 12px 16px; border-radius: 10px;
  font-size: 14px; text-align: center; z-index: 999; opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }

.loader { text-align: center; color: var(--hint); padding: 30px 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--hint); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.pill-list { display: flex; flex-direction: column; gap: 8px; }
.pill { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 10px; background: rgba(0,0,0,0.03); }
.pill .name { font-weight: 600; }
.pill .meta { font-size: 12px; color: var(--hint); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none; align-items: flex-end; z-index: 100; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--secondary-bg); width: 100%; border-radius: 16px 16px 0 0; padding: 18px; }
.modal input, .modal textarea {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 15px; margin-bottom: 10px;
}

.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab { flex: 1; text-align: center; padding: 8px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--hint); background: rgba(0,0,0,0.04); cursor: pointer; }
.tab.active { background: var(--button); color: var(--button-text); }
