/* Панель исполнителя. Минималистичное оформление: только типографика, тонкие
   разделители и акценты цветом. Цвета берутся из темы Telegram (тёмная или
   светлая выбирается клиентом), поэтому интерфейс всегда выглядит «своим». */

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-soft: var(--tg-theme-secondary-bg-color, #f4f4f6);
  --text: var(--tg-theme-text-color, #0b0b0c);
  --hint: var(--tg-theme-hint-color, #8a8a8f);
  --link: var(--tg-theme-link-color, #2f7ce0);
  --button: var(--tg-theme-button-color, #2f7ce0);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --sep: rgba(128, 128, 128, 0.22);
  --new: #3b82f6;
  --work: #f59e0b;
  --done: #22c55e;
  --cancel: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }
a { color: var(--link); text-decoration: none; }

/* ------------------------------------------------------------- шапка ---- */

.topbar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 16px 10px;
}
.topbar__text { flex: 1; min-width: 0; }
.topbar__title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.topbar__user {
  margin-top: 2px;
  font-size: 13px;
  color: var(--hint);
}
.icon-btn {
  border: none;
  background: transparent;
  color: var(--hint);
  font-size: 19px;
  line-height: 1;
  padding: 6px;
  cursor: pointer;
}
.icon-btn:active { opacity: 0.55; }

/* -------------------------------------------------------------- табы ---- */

.tabs {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding: 0 16px;
  border-bottom: 1px solid var(--sep);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  flex: 0 0 auto;
  border: none;
  background: none;
  color: var(--hint);
  font-size: 14px;
  font-family: inherit;
  padding: 10px 0 9px;
  cursor: pointer;
  transition: color 0.15s ease;
}
.tab--active { color: var(--text); font-weight: 600; }
.tab--active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--button);
}
.tab__count { margin-left: 5px; font-size: 12px; color: var(--hint); }

/* ----------------------------------------------------------- список ---- */

.list { padding: 0 16px 96px; }

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--sep);
  cursor: pointer;
}
.row:last-child { border-bottom: none; }
.row:active { opacity: 0.55; }
.row__main { min-width: 0; }
.row__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}
.row__sub {
  margin-top: 3px;
  font-size: 13px;
  color: var(--hint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row__side { text-align: right; }
.row__date { font-size: 12px; color: var(--hint); white-space: nowrap; }
.row__status { margin-top: 5px; font-size: 12px; color: var(--hint); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--hint);
}
.dot--new { background: var(--new); }
.dot--in_progress { background: var(--work); }
.dot--done { background: var(--done); }
.dot--canceled { background: var(--cancel); }
.dot--draft { background: var(--hint); }

/* скелетон загрузки */
.skeleton { padding: 18px 0; }
.skeleton__row {
  height: 42px;
  border-radius: 10px;
  background: var(--bg-soft);
  margin-bottom: 14px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--hint);
  font-size: 14px;
}

/* --------------------------------------------------------- карточка ---- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background: var(--bg);
  animation: slide 0.18s ease-out;
}
@keyframes slide { from { transform: translateX(14px); opacity: 0.5; } to { transform: none; opacity: 1; } }

.sheet__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--sep);
}
.sheet__title { font-size: 17px; font-weight: 600; }
.sheet__status { margin-left: auto; font-size: 13px; color: var(--hint); white-space: nowrap; }

.sheet__body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 16px 28px; }

.sheet__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--sep);
  background: var(--bg);
}

.section { margin-top: 24px; }
.section__title {
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hint);
}

.kv {
  display: flex;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--sep);
  font-size: 15px;
}
.kv:last-child { border-bottom: none; }
.kv__key { flex: 0 1 auto; min-width: 0; color: var(--hint); }
.kv__value { flex: 1 1 auto; min-width: 0; text-align: right; word-break: break-word; }
.kv--stack { display: block; }
.kv--stack .kv__key { margin-bottom: 3px; }
.kv--stack .kv__value { text-align: left; }

.item { padding: 14px 0; border-bottom: 1px solid var(--sep); }
.item:last-child { border-bottom: none; }
.item__head { display: flex; align-items: baseline; gap: 10px; }
.item__name { flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 600; }
.item__qty { flex: 0 0 auto; font-size: 14px; color: var(--hint); white-space: nowrap; }
.item__meta { margin-top: 2px; font-size: 13px; color: var(--hint); word-break: break-word; }
.item .kv { font-size: 14px; padding: 8px 0; }
.item__comment { margin-top: 8px; font-size: 13px; color: var(--hint); word-break: break-word; }

.timeline { font-size: 13px; color: var(--hint); }
.timeline__row { padding: 8px 0; border-bottom: 1px solid var(--sep); }
.timeline__row:last-child { border-bottom: none; }

/* ----------------------------------------------------------- кнопки ---- */

.btn {
  width: 100%;
  border: none;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  background: var(--button);
  color: var(--button-text);
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.btn:active { opacity: 0.8; }
.btn[disabled] { opacity: 0.4; }
.btn--ghost { background: transparent; color: var(--text); font-weight: 500; }
.btn--danger { background: transparent; color: var(--cancel); font-weight: 500; }
.btn--soft {
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  padding: 12px 10px;
}
.btn-row { display: flex; gap: 8px; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ------------------------------------------------------------ тосты ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  max-width: 88vw;
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(24, 24, 26, 0.94);
  color: #fff;
  font-size: 14px;
  text-align: center;
  backdrop-filter: blur(8px);
}
