.card {
  background: linear-gradient(180deg, #1c2a38, #182533);
  border: 1px solid var(--tg-border-color);
  border-radius: 22px;
  box-shadow: var(--tg-shadow);
}

.card-soft {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--tg-border-color);
  border-radius: 16px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-card {
  width: min(400px, 100%);
  padding: 20px;
  border-radius: 22px;
  border: 1px solid var(--tg-border-color);
  background: linear-gradient(180deg, #1f2d3a, #192733);
  box-shadow: var(--tg-shadow);
}

.login-card h1 {
  margin: 0;
  font-size: 18px;
}

.login-card p {
  margin: 4px 0 14px;
  color: var(--tg-hint-color);
}

.login-card form {
  display: grid;
  gap: 8px;
}

.app-shell {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 12px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.app-shell.route-loading {
  visibility: hidden;
}

.app-shell > main {
  min-height: 0;
}

.topbar {
  min-height: 58px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, #253546, #213140);
}

.topbar-copy {
  min-width: 0;
}

.topbar h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--tg-hint-color);
  font-size: 12px;
}

.topbar-refresh-btn {
  justify-self: end;
}

.topbar-refresh-btn.is-loading {
  animation: refresh-spin 0.8s linear infinite;
}

@keyframes refresh-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  line-height: 1;
  font-size: 20px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--tg-border-color);
  color: var(--tg-text-color);
  touch-action: manipulation;
}

.stats {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pill {
  min-width: 88px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--tg-border-color);
}

.pill span {
  display: block;
  color: var(--tg-hint-color);
  font-size: 11px;
}

.pill b {
  font-size: 15px;
  font-weight: 700;
}

.workspace-view {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
  overflow: hidden;
}

.workspace-view > * {
  min-height: 0;
  height: 100%;
}

#board-view,
.board-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

#board-view .lane.card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#board-view .conversation-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.lane {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  padding: 10px;
  background: linear-gradient(180deg, #14202c, #13202b);
  align-content: start;
}

.lane h3 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}

.lane.drag-over {
  border-color: rgba(100, 168, 232, 0.35);
}

.folders-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--tg-border-color);
}

.folder-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 10px;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--tg-hint-color);
  font-size: 15px;
  font-weight: 700;
}

.folder-tab span {
  min-width: 28px;
  height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(100, 168, 232, 0.9);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.folder-tab.active {
  color: var(--tg-text-color);
  border-bottom-color: var(--tg-link-color);
}

.folder-tab.active span {
  background: var(--tg-link-color);
}

.folder-tab:hover {
  filter: none;
  color: var(--tg-text-color);
}

.conversation-list {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  display: grid;
  gap: 2px;
  align-content: start;
  grid-auto-rows: max-content;
  overscroll-behavior: contain;
}

.conversation-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  width: 100%;
  padding: 10px 10px;
  border-radius: 16px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.conversation-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.conversation-item.active {
  background: rgba(100, 168, 232, 0.14);
  border-color: rgba(100, 168, 232, 0.12);
}

.conversation-item.new {
  background: rgba(47, 79, 110, 0.28);
}

.conv-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  background: #35506c;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.conv-avatar img {
  object-fit: cover;
  display: block;
  width: 100%;
  height: 100%;
}

.conv-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.conv-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.conv-name {
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-assignee {
  min-width: 0;
  color: var(--tg-hint-color);
  font-size: 12px;
  line-height: 1.35;
}

.conv-preview {
  min-width: 0;
  color: var(--tg-hint-color);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-preview.new-text {
  color: #7fc3ff;
  font-weight: 600;
}

.conv-rating {
  min-width: 0;
  font-size: 12px;
  line-height: 1.35;
  color: #f3d27c;
}

.conv-tag {
  align-self: start;
  min-width: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #4b84b8;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.history-page {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: 100%;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, #14202c, #13202b);
  border: 1px solid var(--tg-border-color);
  border-radius: 22px;
  box-shadow: var(--tg-shadow);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.chat-empty-state {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 18px;
  text-align: center;
  border: 1px solid var(--tg-border-color);
  border-radius: 22px;
  background: linear-gradient(180deg, #14202c, #13202b);
  box-shadow: var(--tg-shadow);
}

.chat-empty-state strong {
  font-size: 16px;
}

.chat-empty-state span {
  max-width: 420px;
  color: var(--tg-hint-color);
  line-height: 1.45;
}

#users-view.history-page {
  align-items: stretch;
}

#broadcast-view.history-page {
  align-items: stretch;
}

#quick-replies-view.history-page {
  align-items: stretch;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.dashboard-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
  padding: 4px 2px 0;
}

.history-head strong {
  font-size: 16px;
  font-weight: 700;
}

.history-results {
  overflow: visible;
  min-height: auto;
  display: grid;
  gap: 6px;
  align-content: start;
}

.history-search {
  margin-bottom: 4px;
}

.board-empty {
  padding: 18px 10px;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.44);
  z-index: 60;
}

.drawer {
  position: fixed;
  left: 12px;
  top: 12px;
  bottom: 12px;
  width: min(360px, calc(100vw - 24px));
  z-index: 70;
  padding: 0;
  overflow: auto;
  background: linear-gradient(180deg, #1f2d3a, #182633);
  transform: translateX(-110%);
  transition: transform 220ms ease;
  overscroll-behavior: contain;
}

.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.drawer-title {
  font-size: 16px;
  font-weight: 700;
}

.profile {
  padding: 16px;
  margin: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.drawer-profile {
  border-radius: 0;
}

.notify-box {
  margin-top: 12px;
  padding: 12px;
  display: grid;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.notify-btn {
  min-height: 38px;
}

.notify-help {
  line-height: 1.35;
}

.profile-top {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #60a9ef, #3d8dd8);
}

.name {
  font-size: 14px;
  font-weight: 700;
}

.hint {
  font-size: 12px;
  color: var(--tg-hint-color);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0 8px;
}

.drawer-menu {
  display: grid;
  padding: 10px 8px;
  gap: 2px;
}

.drawer-item {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--tg-text-color);
  text-align: left;
  box-shadow: none;
}

.drawer-item:hover {
  filter: none;
  background: rgba(255,255,255,0.04);
}

.drawer-item-icon {
  font-size: 18px;
  line-height: 1;
  opacity: 0.9;
}

.drawer-item-danger {
  color: #f0b7bf;
}

.drawer-item-danger .drawer-item-icon {
  color: #f0b7bf;
}

.ios-switch {
  position: relative;
  width: 48px;
  height: 28px;
  display: inline-block;
}

.ios-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  transition: background 180ms ease;
}

.ios-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #fff;
  transition: transform 180ms ease;
}

.ios-switch input:checked + .ios-slider {
  background: #34c759;
}

.ios-switch input:checked + .ios-slider::before {
  transform: translateX(20px);
}

.ghost-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--tg-border-color);
  color: var(--tg-text-color);
}

.danger-btn {
  background: rgba(217, 108, 123, 0.12);
  border-color: rgba(217, 108, 123, 0.32);
  color: #f6c2cb;
}

.success-btn {
  background: rgba(46, 160, 103, 0.16);
  border-color: rgba(77, 201, 128, 0.34);
  color: #8df0ad;
}

.waiting-btn {
  background: rgba(227, 176, 70, 0.16);
  border-color: rgba(227, 176, 70, 0.38);
  color: #ffd78a;
}

#admin-section h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

#metrics,
#staff-list {
  display: grid;
  gap: 6px;
}

#staff-list {
  min-height: 0;
  overflow: visible;
}

#admin-section {
  margin: 8px 12px 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.04);
}

.admin-create-form {
  padding: 8px;
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: center;
}

.users-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 2px;
}

.broadcast-card {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 4px 0 0;
  display: grid;
  gap: 16px;
  align-content: start;
}

.quick-replies-card {
  gap: 14px;
}

.quick-reply-form {
  display: grid;
  gap: 12px;
}

.quick-reply-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quick-reply-fields {
  display: grid;
  gap: 10px;
}

.quick-reply-fields input,
.quick-reply-fields textarea {
  background: #223247;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 14px 16px;
}

.quick-reply-fields textarea {
  min-height: 132px;
  resize: vertical;
}

.quick-replies-list {
  display: grid;
  gap: 8px;
}

.quick-reply-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.03);
}

.quick-reply-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.quick-reply-key {
  font-size: 14px;
  font-weight: 700;
  color: #8cc9ff;
}

.quick-reply-preview {
  color: var(--tg-text-color);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.quick-reply-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-reply-action-btn {
  width: auto;
  min-width: 112px;
  min-height: 38px;
  padding-inline: 14px;
}

.broadcast-copy {
  display: grid;
  gap: 6px;
}

.broadcast-copy strong {
  font-size: 16px;
}

#notice-current {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  line-height: 1.4;
}

.broadcast-form {
  display: grid;
  gap: 12px;
  padding: 16px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.notice-actions {
  justify-content: space-between;
}

.notice-delete-btn {
  width: auto;
  min-width: 120px;
}

.broadcast-form textarea {
  min-height: 180px;
  background: #223247;
  border: 1px solid rgba(255, 255, 255, 0.06);
  resize: vertical;
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.45;
}

.broadcast-actions {
  display: flex;
  justify-content: flex-end;
}

.broadcast-submit-btn {
  width: auto;
  min-width: 160px;
  min-height: 44px;
  padding-inline: 22px;
  background: linear-gradient(180deg, #5ca9f3, #4792df);
}

#broadcast-result {
  margin-top: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.users-create-btn {
  width: auto;
  min-height: 38px;
  padding-inline: 18px;
  background: linear-gradient(180deg, #29425a, #22384c);
  border-color: rgba(115, 167, 216, 0.18);
}

.staff-editor {
  padding: 12px;
  display: grid;
  gap: 10px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(39, 58, 78, 0.82), rgba(24, 37, 51, 0.92));
  border-color: rgba(113, 150, 187, 0.14);
}

.staff-editor-head,
.staff-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.staff-summary-btn {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  color: inherit;
  text-align: left;
}

.staff-summary-btn:hover {
  filter: none;
}

.staff-summary-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.staff-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #5fa9ef, #3c88cf);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.staff-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.staff-copy-top {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.staff-copy-top strong {
  min-width: 0;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.staff-copy-sub,
.staff-copy-meta {
  min-width: 0;
  color: var(--tg-hint-color);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.staff-copy-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.staff-expand-icon {
  flex: 0 0 auto;
  color: var(--tg-hint-color);
  font-size: 14px;
}

.staff-editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.staff-settings-btn {
  width: 34px;
  height: 34px;
}

.admin-create-form input,
.admin-create-form select,
.staff-editor input,
.staff-editor select {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 12px;
}

.admin-create-form button,
.staff-editor button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
}

.staff-card,
.metric-card,
.profile-stat,
.profile-line {
  border-radius: 14px;
  border: 1px solid var(--tg-border-color);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px;
}

.admin-stat-card {
  min-height: 88px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(35, 53, 72, 0.94), rgba(27, 42, 56, 0.94));
  border-color: rgba(113, 150, 187, 0.14);
}

.admin-stat-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.05;
  color: #f4f8fc;
}

.admin-stat-label {
  margin-top: 6px;
  color: var(--tg-hint-color);
  font-size: 12px;
  line-height: 1.25;
}

.presence-badge {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  color: #dfefff;
  background: rgba(100, 168, 232, 0.18);
  border: 1px solid rgba(100, 168, 232, 0.14);
}

.presence-badge.online {
  color: #c7ffd8;
  background: rgba(52, 199, 89, 0.14);
  border-color: rgba(52, 199, 89, 0.2);
}

.presence-badge.offline {
  color: #dce7f3;
  background: rgba(128, 145, 164, 0.16);
  border-color: rgba(128, 145, 164, 0.16);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
}

.modal-card {
  position: relative;
  width: min(560px, 100%);
  padding: 14px;
  z-index: 1;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-form {
  grid-template-columns: 1fr;
  margin-bottom: 0;
}

.staff-metrics {
  padding-top: 2px;
}

.staff-metrics .metric-card {
  min-height: 72px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.028);
}

.staff-metrics .metric-card strong {
  display: block;
  font-size: 16px;
  margin-bottom: 4px;
}
