:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --border: #e5e5e8;
  --text: #1c1c1e;
  --text-muted: #7a7a80;
  --accent: #2f6fed;
  --accent-hover: #2559c4;
  --yellow-bg: #fff6db;
  --yellow-border: #f0d573;
  --red-bg: #fde4e4;
  --red-border: #ef9a9a;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: #f0f0f2;
}

.btn-danger {
  background: #e5484d;
  color: #fff;
}
.btn-danger:hover {
  background: #cf3b40;
}

.btn-small {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 8px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.tab {
  background: none;
  border: none;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

.groups {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.group-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.row-yellow {
  background: var(--yellow-bg);
}
.row-red,
.row-overdue {
  background: var(--red-bg);
}

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--text);
  background: #eee;
}
.row-yellow .badge {
  background: var(--yellow-border);
}
.row-red .badge,
.row-overdue .badge {
  background: var(--red-border);
  color: #fff;
}

.actions-cell {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.comment-cell {
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
}

.hidden {
  display: none !important;
}

/* Модалки */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.modal h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.modal-hint {
  color: var(--text-muted);
  font-size: 13px;
  margin: -8px 0 16px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field span {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.form-error {
  color: #cf3b40;
  font-size: 13px;
  margin: -6px 0 10px;
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  table, thead, tbody, th, td, tr {
    display: block;
  }

  thead {
    display: none;
  }

  tbody tr {
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }

  td {
    border: none;
    padding: 4px 16px;
  }

  td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
  }
}
