:root {
  --primary: #2c3e50;
  --primary-dark: #1a252f;
  --accent: #5b9bd5;
  --accent-hover: #4a8bc4;
  --accent-light: #e8f2fa;
  --success: #68d391;
  --danger: #e74c3c;
  --warning: #f6ad55;
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --text: #2d3748;
  --text-light: #718096;
  --border: #e2e8f0;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
}

header {
  background-color: var(--primary);
  color: white;
  padding: 1.25rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
}

header h1 {
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.2s;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

nav {
  background-color: var(--card-bg);
  padding: 0 2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0;
}

nav a {
  color: var(--text-light);
  text-decoration: none;
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

nav a:hover {
  color: var(--accent);
}

nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

main {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  transition: all 0.2s;
  background-color: white;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 155, 213, 0.15);
}

button,
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.625rem 1.25rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-block;
  font-family: inherit;
}

button:hover,
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

th,
td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background-color: #f8fafc;
  font-weight: 600;
  color: var(--text);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

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

tr:hover {
  background-color: var(--accent-light);
}

.toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.875rem;
}

.grade-5 {
  background-color: #d1fae5;
  color: #065f46;
}

.grade-4 {
  background-color: #dbeafe;
  color: #1e40af;
}

.grade-3 {
  background-color: #fef3c7;
  color: #92400e;
}

.grade-2 {
  background-color: #fee2e2;
  color: #991b1b;
}

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #cbd5e0;
}

/* Login page */
.login-container {
  max-width: 400px;
  margin: 4rem auto;
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.login-container h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-container input {
  margin-bottom: 1rem;
}

.login-container button {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  margin-top: 0.5rem;
}

.hidden {
  display: none;
}

.diagram-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 2rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 2rem;
}

.chart-box {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ==================== МОДАЛЬНОЕ ОКНО ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: none;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex !important;
}

.modal-window {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  width: 90%;
  max-width: 450px;
  box-shadow: var(--shadow-lg);
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-window h2 {
  margin: 0 0 1.5rem 0;
  color: var(--primary);
  font-size: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

.modal-window .form-group {
  margin-bottom: 1rem;
}

.modal-window .form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
}

.modal-window .form-group input,
.modal-window .form-group select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.modal-window .form-group input:focus,
.modal-window .form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 155, 213, 0.2);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.modal-actions button {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.modal-actions button[type="submit"] {
  background: var(--accent);
  color: white;
}

.modal-actions button[type="submit"]:hover {
  background: var(--accent-hover);
}

.modal-actions button[type="button"] {
  background: var(--border);
  color: var(--text);
}

.modal-actions button[type="button"]:hover {
  background: #cbd5e0;
}

/* Notifications */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 1rem;
  border-radius: 6px;
  z-index: 10000;
  font-family: inherit;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.notification.success {
  background-color: #d1fae5;
  border-left: 4px solid var(--success);
  color: #065f46;
}

.notification.error {
  background-color: #fee2e2;
  border-left: 4px solid var(--danger);
  color: #991b1b;
}

/* Footer */
footer {
  text-align: center;
  padding: 1rem;
  background-color: #ecf0f1;
  margin-top: 2rem;
  font-size: 0.9rem;
  color: var(--text-light);
}

/* Responsive */
@media (max-width: 768px) {
  header {
    padding: 1rem;
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }
  
  header h1 {
    font-size: 1.25rem;
  }
  
  nav {
    padding: 0 1rem;
    flex-wrap: wrap;
  }
  
  nav a {
    padding: 0.75rem 0.875rem;
    font-size: 0.85rem;
  }
  
  main {
    padding: 1rem;
  }
  
  .card {
    padding: 1.25rem;
  }
  
  table {
    font-size: 0.85rem;
  }
  
  th,
  td {
    padding: 0.625rem 0.75rem;
  }
  
  .diagram-container,
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .toolbar {
    flex-direction: column;
  }
  
  .login-container {
    margin: 2rem 1rem;
    padding: 1.5rem;
  }
  
  .modal-window {
    padding: 1.5rem;
    width: 95%;
  }
}