:root {
  --bg: #0b0f14;
  --text: #f3f5f7;
  --hint: rgba(243, 245, 247, 0.72);
  --btn: var(--tg-theme-button-color, #2f7fc1);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --sec: rgba(12, 16, 22, 0.72);
  --bad: #ff6b6b;
  --line: rgba(255, 255, 255, 0.14);
}

* { box-sizing: border-box; }

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Noto Sans SC", sans-serif;
  font-size: 16px;
  color: var(--text);
  background-color: #0b0f14;
  position: relative;
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px 48px;
  min-height: calc(100vh - 24px);
  min-height: calc(var(--app-h, 100vh) - 24px);
}

#view-home {
  position: relative;
  min-height: calc(100vh - 80px);
  min-height: calc(var(--app-h, 100vh) - 80px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

#view-home .home-nav {
  margin-top: 24px;
}

.home-top {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
}

.clear-all-btn {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid rgba(255, 107, 107, 0.55);
  border-radius: 10px;
  background: rgba(255, 107, 107, 0.18);
  color: #ffb4b4;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

html.is-mobile,
html.is-mobile body {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  width: 100%;
  height: var(--app-h, 100vh);
  max-height: var(--app-h, 100vh);
  overflow: hidden;
}

html.is-mobile #app {
  height: 100%;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.muted {
  color: var(--hint);
  font-size: 0.9rem;
  margin: 8px 0;
}

.hidden { display: none !important; }

.error {
  background: rgba(255, 107, 107, 0.18);
  color: #ffb4b4;
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.heading {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 12px;
}

#home-role {
  text-align: center;
}

#home-hint {
  text-align: center;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.toolbar input {
  flex: 1;
}

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.seg-btn {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.seg-btn.active {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow: none;
  font-weight: 700;
}

label, .field {
  display: block;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.label {
  display: block;
  margin-bottom: 6px;
  color: var(--hint);
}

input, select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--sec);
  color: var(--text);
  font-size: 1rem;
}

textarea { resize: vertical; }

button.primary,
button.secondary,
button.secondary-block,
button.danger {
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
  margin-top: 8px;
  background: transparent;
  box-shadow: none;
}

button.primary {
  width: 100%;
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  color: #fff;
  font-weight: 700;
}

button.secondary {
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.4);
  margin-top: 0;
  padding: 10px 14px;
  font-weight: 500;
}

button.secondary-block {
  width: 100%;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-weight: 500;
}

button.danger {
  width: 100%;
  border: 1px solid rgba(255, 107, 107, 0.7);
  color: #ffb4b4;
  font-weight: 600;
}

.list { margin-top: 8px; }

.card {
  background: var(--sec);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
}

.card .title {
  font-weight: 600;
  margin-bottom: 4px;
}

.card .meta {
  color: var(--hint);
  font-size: 0.85rem;
  line-height: 1.45;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}

.badge.on {
  background: rgba(76, 175, 80, 0.25);
  color: #a5d6a7;
}

.badge.off {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(243, 245, 247, 0.75);
}

.job-change, .history {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.empty {
  color: var(--hint);
  text-align: center;
  padding: 24px 8px;
}

.home-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

.home-nav button {
  width: 140px;
  height: 40px;
  box-sizing: border-box;
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 0;
  font-size: 0.9em;
  font-weight: 700;
  background: transparent;
  color: #fff;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#view-org > .secondary-block {
  margin-top: 8px;
}

#view-org > .secondary-block:first-of-type {
  margin-top: 0;
}

#view-org #org-title {
  text-align: center;
  margin: 20px 0 14px;
}

#view-org #org-status {
  text-align: center;
  margin: 14px 0 0;
}

.org-stats {
  margin: 0 0 10px;
  line-height: 1.55;
  text-align: center;
}

.org-stat-red {
  color: #ff6b6b;
  font-weight: 600;
  margin: 0 0 8px;
  text-align: center;
}

.org-stat-pos {
  margin: 0 0 6px;
  color: var(--text);
  text-align: center;
}

.org-divider {
  margin: 14px 0 10px;
  color: var(--hint);
  letter-spacing: 1px;
  text-align: center;
}

.org-hint {
  text-align: center;
  color: var(--hint);
  margin: 0 0 14px;
  line-height: 1.6;
}

.org-supervisor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.org-supervisor-grid button {
  width: 100%;
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 14px 8px;
  font-size: 0.95rem;
  font-weight: 700;
  background: transparent;
  color: #fff;
  text-align: center;
  box-shadow: none;
}


.select-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.select-row select {
  flex: 1;
  margin-top: 0;
}

#user-list .select-row button {
  flex: 1;
  width: auto;
  margin-top: 0;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  box-sizing: border-box;
}

.select-row input {
  flex: 1;
  margin-top: 0;
}

.opt-add,
.opt-del {
  flex: 0 0 44px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0;
}

.name-random {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 0 12px;
  font-size: 0.9rem;
}

.opt-del {
  color: #ffb4b4;
  border-color: rgba(255, 107, 107, 0.7);
}

.name-hint {
  margin: 4px 0 0;
  min-height: 1.2em;
}

.name-hint.dup {
  color: #ff6b6b;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--sec);
  border-radius: 14px;
  padding: 16px;
}

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

.report-summary {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 8px 0;
  color: var(--text);
}

.report-table-wrap {
  overflow: auto;
  max-height: min(50vh, 420px);
  margin: 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.report-table {
  border-collapse: collapse;
  font-size: 0.75rem;
  white-space: nowrap;
  min-width: 100%;
}

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

.report-table th {
  position: sticky;
  top: 0;
  background: rgba(30, 30, 40, 0.95);
  font-weight: 600;
  z-index: 1;
}

.report-table tr.row-left td {
  color: #ff6b6b;
}

