* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: sans-serif;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: #fff;
  padding: 2.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 380px;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: #1a1a1a;
}

.field {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 0.4rem;
}

input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

input:focus {
  outline: none;
  border-color: #4f6ef7;
}

.error {
  background: #fde8e8;
  color: #c0392b;
  border: 1px solid #f5c6cb;
  border-radius: 5px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

button {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.7rem;
  background: #4f6ef7;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover {
  background: #3a58e0;
}

/* ── Dashboard ────────────────────────────────── */

.dashboard-body {
  display: block;
  background: #f0f2f5;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  padding: 0.75rem 2rem;
  border-bottom: 1px solid #e8eaed;
}

.navbar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.navbar-logo {
  height: 22px;
  width: auto;
  display: block;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.navbar-role {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-admin {
  background: #eef0fe;
  color: #4f6ef7;
}

.badge-operator {
  background: #e8f5e9;
  color: #2e7d32;
}

.navbar-role-group {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.navbar-role-label {
  font-size: 0.875rem;
  color: #888;
}

.navbar-username {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1a1a1a;
  text-decoration: none;
  transition: color 0.2s;
}

.navbar-username:hover {
  color: #4f6ef7;
}

.btn-logout {
  font-size: 0.875rem;
  color: #888;
  text-decoration: none;
  transition: color 0.2s;
}

.btn-logout:hover {
  color: #c0392b;
}

.success {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
  border-radius: 5px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.btn-back {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: #888;
  text-decoration: none;
  transition: color 0.2s;
}

.btn-back:hover {
  color: #1a1a1a;
}

.dashboard-layout {
  display: flex;
  min-height: calc(100vh - 53px);
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e8eaed;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
}

.sidebar-link {
  display: block;
  padding: 0.65rem 1.5rem;
  font-size: 0.9rem;
  color: #444;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: #f0f2f5;
  color: #4f6ef7;
}

.dashboard-main {
  flex: 1;
  padding: 2rem;
}

.dashboard-main h1 {
  margin-bottom: 0;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card h2 {
  font-size: 1.1rem;
  color: #1a1a1a;
}

.card p {
  font-size: 0.9rem;
  color: #666;
  flex: 1;
}

.btn {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  background: #4f6ef7;
  color: #fff;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.2s;
  align-self: flex-start;
}

.btn:hover {
  background: #3a58e0;
}

/* ── Formulář ─────────────────────────────────── */

.form-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  padding: 2rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.25rem;
}

.field-full {
  grid-column: 1 / -1;
}

textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}

textarea:focus {
  outline: none;
  border-color: #4f6ef7;
}

.field-hint {
  font-size: 0.8rem;
  font-weight: 400;
  color: #aaa;
  margin-left: 0.3rem;
}

.file-input {
  padding: 0.4rem 0;
  border: none;
  font-size: 0.9rem;
}

.required {
  color: #c0392b;
}

.form-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
}

.form-actions button {
  width: auto;
  padding: 0.7rem 2rem;
  margin-top: 0;
}

/* ── Tabulka leadů ────────────────────────────── */

.table-wrapper {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  overflow: hidden;
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.leads-table thead {
  background: #f8f9fb;
  border-bottom: 1px solid #e8eaed;
}

.leads-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.leads-table td {
  padding: 0.75rem 1rem;
  color: #1a1a1a;
  border-bottom: 1px solid #f0f2f5;
}

.leads-table tbody tr:last-child td {
  border-bottom: none;
}

.leads-table tbody tr:hover td {
  background: #fafbfc;
}

.table-empty {
  text-align: center;
  color: #aaa;
  padding: 2rem !important;
}

.td-action {
  text-align: right;
  white-space: nowrap;
}

.btn-detail {
  font-size: 0.8rem;
  font-weight: 600;
  color: #4f6ef7;
  text-decoration: none;
  padding: 0.3rem 0.75rem;
  border: 1px solid #c5cdfa;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.btn-detail:hover {
  background: #4f6ef7;
  color: #fff;
}

/* ── Detail obchodního případu ─────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.detail-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  padding: 1.5rem;
}

.detail-card-full {
  grid-column: 1 / -1;
}

.detail-card-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
}

.detail-list {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 0.5rem 1rem;
}

.detail-list dt {
  font-size: 0.875rem;
  color: #888;
  font-weight: 500;
}

.detail-list dd {
  font-size: 0.875rem;
  color: #1a1a1a;
}

.detail-description {
  font-size: 0.9rem;
  color: #333;
  line-height: 1.6;
}

.text-muted {
  color: #aaa;
}

.attachment-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  align-items: start;
}

.attachment-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 1px solid #e8eaed;
  border-radius: 6px;
  padding: 0.6rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
  height: 125px;
  box-sizing: border-box;
  margin: 0;
}

.attachment-thumb:hover {
  border-color: #4f6ef7;
  background: #f5f7ff;
}

.attachment-thumb img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
}

.attachment-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid #e8eaed;
  border-radius: 6px;
  padding: 0.6rem;
  text-decoration: none;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  height: 125px;
  box-sizing: border-box;
}

.attachment-file:hover {
  border-color: #4f6ef7;
  background: #f5f7ff;
}

.attachment-icon {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f2f5;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #666;
}

.attachment-name {
  font-size: 0.75rem;
  color: #333;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Lightbox ──────────────────────────────────── */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  width: auto;
  padding: 0;
  margin: 0;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.lightbox-close:hover {
  opacity: 1;
}

/* ── Komentáře ─────────────────────────────────── */

.hidden {
  display: none !important;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.comment-bubble {
  background: #f8f9fb;
  border: 1px solid #e8eaed;
  border-radius: 8px;
  padding: 0.9rem 1rem;
}

.comment-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.comment-meta {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.comment-author {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a1a1a;
}

.comment-date {
  font-size: 0.75rem;
  color: #aaa;
}

.comment-body {
  font-size: 0.9rem;
  color: #333;
  line-height: 1.55;
}

.comment-actions-bar {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  margin-left: 0.75rem;
}

.comment-btn-edit,
.comment-btn-delete {
  background: #e8ecff;
  border: none;
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  margin: 0;
  width: auto;
  font-size: 0.78rem;
  font-weight: 500;
  color: #4f6ef7;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.comment-btn-edit:hover {
  background: #c5cffa;
}

.comment-btn-delete:hover {
  background: #fce8e8;
  color: #c0392b;
}

.comment-edit-form textarea,
.comment-add-form textarea {
  width: 100%;
  margin-top: 0.5rem;
}

.comment-edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-comment-save {
  width: auto;
  padding: 0.45rem 1.25rem;
  margin-top: 0;
  font-size: 0.875rem;
}

.btn-comment-cancel {
  background: none;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 0.45rem 1rem;
  font-size: 0.875rem;
  color: #666;
  cursor: pointer;
  width: auto;
  margin-top: 0;
  transition: border-color 0.15s, color 0.15s;
}

.btn-comment-cancel:hover {
  border-color: #aaa;
  color: #333;
}

.comment-add-form {
  border-top: 1px solid #e8eaed;
  padding-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.comment-add-form textarea {
  margin-top: 0;
}

.comment-add-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 1rem;
  width: 100%;
}

.comment-add-col-full {
  grid-column: 1 / -1;
}

.comment-add-col {
  display: flex;
  flex-direction: column;
}

.comment-nabidka-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.comment-nabidka-input:focus {
  outline: none;
  border-color: #4f6ef7;
}

.comment-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.comment-badges-readonly {
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

.comment-nabidka-badge {
  display: inline-block;
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.comment-stav-badge {
  display: inline-block;
  border: 1px solid;
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.comment-stav-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s;
}

.comment-stav-select:focus {
  outline: none;
  border-color: #4f6ef7;
}

.btn-comment-submit {
  align-self: center;
  padding: 0.5rem 2.5rem;
}

.comment-existing-files {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #f8f9fb;
  border: 1px solid #e8eaed;
  border-radius: 5px;
}

.comment-existing-label {
  font-size: 0.8rem;
  color: #888;
  font-weight: 600;
  margin-right: 0.25rem;
}

.comment-file-del-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
}

.file-marked-delete .comment-file-del-name {
  text-decoration: line-through;
  color: #aaa;
}

.comment-file-del-name {
  font-size: 0.8rem;
  color: #444;
}

.btn-file-x {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.1rem;
  width: auto;
  margin: 0;
  transition: color 0.15s;
}

.btn-file-x:hover {
  color: #c0392b;
}

.comment-file-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.5rem;
}

.comment-file-link {
  font-size: 0.8rem;
  color: #4f6ef7;
  text-decoration: none;
}

.comment-file-link:hover {
  text-decoration: underline;
}

.comment-form-file {
  width: 100%;
}

.comment-file-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 0.25rem;
}

.comment-termin-badge {
  display: inline-block;
  background: #e0f7fa;
  color: #00695c;
  border: 1px solid #80cbc4;
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.comment-resitel-badge {
  display: inline-block;
  background: #f3e5f5;
  color: #7b1fa2;
  border: 1px solid #ce93d8;
  border-radius: 4px;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ── Pár polí (LV + Podíl) ─────────────────────── */

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
