/* === Единый светлый стиль — Система Поток === */
:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --card-hover: #f8f9fd;
  --text: #1a1d26;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #eef2ff;
  --green: #10b981;
  --green-light: #d1fae5;
  --green-bg: #ecfdf5;
  --red: #ef4444;
  --red-light: #fee2e2;
  --amber: #f59e0b;
  --amber-light: #fef3c7;
  --blue: #3b82f6;
  --blue-light: #dbeafe;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --radius-lg: 1rem;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

@media (min-width: 640px) {
  .app-container { padding: 1.5rem 2rem; }
}

/* Navigation */
.nav-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 1.5rem;
  background: var(--card);
  padding: 0.375rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--accent); color: #fff; }

/* Page title */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

@media (max-width: 640px) {
  .page-title { font-size: 1.25rem; }
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.card-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.card-value {
  font-size: 1.625rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

@media (max-width: 640px) {
  .card { padding: 0.875rem; }
  .card-value { font-size: 1.25rem; }
}

/* Stat grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.625rem;
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
}

.stats-grid-2 { grid-template-columns: repeat(2, 1fr); }

/* Tables */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap::-webkit-scrollbar { height: 4px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.8125rem;
}

tr:hover td { background: var(--card-hover); }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.4;
}

.badge-green { background: var(--green-light); color: #065f46; }
.badge-blue { background: var(--blue-light); color: #1e40af; }
.badge-amber { background: var(--amber-light); color: #92400e; }
.badge-red { background: var(--red-light); color: #991b1b; }
.badge-gray { background: var(--bg); color: var(--text-secondary); }
.badge-accent { background: var(--accent-light); color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

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

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

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

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 0.25rem; }

.form-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-family: inherit;
  background: var(--card);
  transition: border-color 0.15s;
  width: 100%;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  background: var(--card);
  padding: 1rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

@media (max-width: 640px) {
  .form-row { flex-direction: column; align-items: stretch; }
  .form-row .btn { width: 100%; justify-content: center; }
}

/* Section */
.section {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1rem;
}

.section-header {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Quick links */
.quick-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.625rem;
}

@media (min-width: 640px) {
  .quick-links { grid-template-columns: repeat(4, 1fr); }
}

.quick-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1rem;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  font-size: 0.8125rem;
  transition: all 0.15s;
}

.quick-link:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.quick-link-icon {
  font-size: 1.25rem;
}

/* Status messages */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  margin-bottom: 1rem;
}

.alert-success { background: var(--green-bg); color: #065f46; }
.alert-error { background: var(--red-light); color: #991b1b; }
.alert-info { background: var(--blue-light); color: #1e40af; }

/* User detail */
.user-detail { display: none; }
.user-detail.open { display: table-row; }
.user-detail td { background: var(--card-hover); padding: 0.875rem 1rem; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  font-size: 0.8125rem;
  max-width: 600px;
}

.detail-grid dt { font-weight: 600; color: var(--text); }
.detail-grid dd { color: var(--text-secondary); }

/* Loading pulse */
.pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* Link */
.link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8125rem;
}

.link:hover { text-decoration: underline; }

/* Text helpers */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.75rem; }
.text-xs { font-size: 0.6875rem; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Spacing helpers */
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.hidden { display: none !important; }

/* Date display */
.date-tag {
  background: var(--card);
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

/* Row-hover for clickable rows */
.row-clickable { cursor: pointer; transition: background 0.15s; }
.row-clickable:hover { background: var(--card-hover); }
