* { box-sizing: border-box; }
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 12px;
  background: #f0f2f5;
  color: #333;
  overflow-x: hidden;
}

.screen { display: none; }
.screen.active { display: block; }

h1 { margin: 0 0 12px; font-size: 22px; }
h2 { margin: 0; font-size: 18px; }

input, select, button {
  padding: 10px;
  margin: 6px 0;
  font-size: 15px;
  border: 1px solid #ccc;
  border-radius: 6px;
  width: 100%;
}

button {
  background: #007aff;
  color: white;
  border: none;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
}
button:hover { background: #005bb5; }
button.secondary { background: #6c757d; }
button.secondary:hover { background: #5a6268; }

.error { color: #d32f2f; margin: 8px 0; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
#btn-logout { width: auto; padding: 8px 16px; }

#notifications-block {
  background: white;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.notifications-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

button.small {
  width: auto;
  padding: 6px 12px;
  font-size: 13px;
  background: #d32f2f;
}
button.small:hover { background: #b71c1c; }

#notifications-list p { font-size: 14px; color: #666; }

.mode-selector {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mode-selector label { font-weight: bold; margin: 0; white-space: nowrap; }
.mode-selector select { width: auto; min-width: 220px; }

.main-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

#filter-panel {
  width: 340px;
  flex-shrink: 0;
  background: white;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  max-height: 80vh;
  overflow-y: auto;
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.enabled-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

.enabled-toggle input[type="checkbox"] { width: auto; margin: 0; }

#filter-fields .filter-group {
  margin-bottom: 12px;
  border-bottom: 1px solid #eee;
  padding-bottom: 12px;
}

.filter-group summary {
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  user-select: none;
}

.filter-group summary span {
  font-size: 12px;
  color: #888;
  font-weight: normal;
}

.filter-group .options { margin-top: 8px; padding-left: 4px; }

.filter-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  font-size: 14px;
  cursor: pointer;
}

.filter-group input[type="checkbox"] { width: auto; margin: 0; }

.filter-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#tickets-panel { flex: 1; min-width: 0; }

.tickets-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tickets-toolbar select { flex: 1; min-width: 130px; }

.tickets-toolbar button { width: auto; padding: 10px 16px; white-space: nowrap; }

.ticket-card {
  background: white;
  padding: 16px;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 10px;
  position: relative;
  font-size: 14px;
  color: #333;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ticket-priority {
  position: absolute;
  top: 12px;
  right: 16px;
}

.ticket-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  margin-bottom: 8px;
  padding-right: 80px;
}

.ticket-field {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ticket-field strong { font-weight: 600; color: #555; }

.ticket-field a {
  color: #007aff;
  text-decoration: none;
  word-break: break-all;
}
.ticket-field a:hover { text-decoration: underline; }

.ticket-description {
  font-size: 14px;
  color: #333;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-weight: normal;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}

.badge-red { background: #ffcdd2; color: #b71c1c; }
.badge-yellow { background: #fff9c4; color: #f57f17; }
.badge-gray { background: #eee; color: #555; }

#btn-load-more {
  display: block;
  margin: 16px auto;
  width: auto;
  padding: 12px 30px;
  background: #007aff;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
}
#btn-load-more:hover { background: #005bb5; }

@media (max-width: 768px) {
  body { padding: 8px; }

  .main-layout {
    flex-direction: column;
  }

  #filter-panel {
    width: 100%;
    max-height: none;
    margin-bottom: 16px;
  }

  .tickets-toolbar {
    gap: 6px;
  }

  .tickets-toolbar select {
    flex: 1 1 45%;
    min-width: 0;
  }

  .ticket-row {
    padding-right: 60px;
  }

  .ticket-priority {
    top: 8px;
    right: 8px;
  }

  header h1 { font-size: 20px; }
}