/* =====================================================
   СКЛАДПРО — Minimalist Dark UI
   ===================================================== */

:root {
  /* --- Neutral dark backgrounds (no color tint) --- */
  --bg-primary:   #0a0a0a;
  --bg-secondary: #111116;
  --bg-card:      #1a1a20;
  --bg-hover:     #222229;
  --border:       #2c2c35;
  --border-light: #3a3a46;

  /* --- Accent: clean indigo-blue --- */
  --accent:       #5b7cf6;
  --accent-hover: #4668e8;
  --accent-light: rgba(91,124,246,0.12);

  /* --- Status colours --- */
  --green:        #34d399;
  --green-light:  rgba(52,211,153,0.12);
  --red:          #f87171;
  --red-light:    rgba(248,113,113,0.12);
  --yellow:       #fbbf24;
  --yellow-light: rgba(251,191,36,0.12);
  --blue:         #38bdf8;
  --blue-light:   rgba(56,189,248,0.12);

  /* --- Typography --- */
  --text-primary:   #f0f0f4;
  --text-secondary: #a0a0bc;
  --text-muted:     #6e6e8a;

  /* --- Layout --- */
  --sidebar-w:  220px;
  --header-h:   56px;
  --radius:     8px;
  --radius-sm:  5px;
  --shadow:     0 8px 32px rgba(0,0,0,0.5);
  --transition: 0.15s ease;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

/* ───────────────────────────────────────────
   LOGIN PAGE
─────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-secondary);
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 46px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo .logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px; height: 52px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 22px;
}
.login-logo h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.login-logo p { color: var(--text-secondary); font-size: 0.85rem; }

/* ───────────────────────────────────────────
   LAYOUT
─────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  position: fixed; left: 0; top: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.sidebar-logo span {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}

.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }

.nav-section { margin-bottom: 4px; }
.nav-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 10px 10px 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  font-size: 0.96rem;
  font-weight: 500;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.nav-item .nav-icon { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex; align-items: center; gap: 9px;
  padding: 8px;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
  color: white;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.825rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: var(--text-muted); }
.logout-btn {
  background: none; border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  font-size: 15px;
  transition: color var(--transition);
}
.logout-btn:hover { color: var(--red); }

/* ─── Main content ─── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 700; flex: 1; letter-spacing: -0.01em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.menu-toggle {
  display: none;
  background: none; border: none;
  color: var(--text-primary);
  font-size: 19px;
  padding: 4px;
}

.page-content { padding: 24px; flex: 1; }

/* ───────────────────────────────────────────
   CARDS
─────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.card-title { font-size: 0.925rem; font-weight: 700; }

/* ─── Stats Grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border-light); }
.stat-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.stat-icon.purple { background: var(--accent-light); color: var(--accent); }
.stat-icon.green  { background: var(--green-light);  color: var(--green); }
.stat-icon.red    { background: var(--red-light);    color: var(--red); }
.stat-icon.blue   { background: var(--blue-light);   color: var(--blue); }
.stat-icon.yellow { background: var(--yellow-light); color: var(--yellow); }
.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; margin-bottom: 2px; letter-spacing: -0.02em; }
.stat-label { font-size: 0.775rem; color: var(--text-secondary); }
.stat-sub   { font-size: 0.73rem; color: var(--text-muted); margin-top: 4px; }

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px;
}

/* ───────────────────────────────────────────
   TABLE
─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-hover); }
.td-actions { display: flex; gap: 5px; }

/* ───────────────────────────────────────────
   BUTTONS
─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-success  { background: var(--green); color: #0a1a14; border-color: var(--green); }
.btn-success:hover:not(:disabled) { opacity: 0.85; }
.btn-danger   { background: var(--red-light); color: var(--red); border-color: var(--red); }
.btn-danger:hover:not(:disabled)  { background: var(--red); color: white; }
.btn-ghost    { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover:not(:disabled)   { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.btn-sm  { padding: 5px 10px; font-size: 0.78rem; }
.btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon.danger:hover { color: var(--red); }

/* ───────────────────────────────────────────
   FORMS
─────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
select.form-control option { background: var(--bg-card); }
textarea.form-control { resize: vertical; min-height: 76px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-error { font-size: 0.76rem; color: var(--red); margin-top: 4px; }
.form-hint  { font-size: 0.76rem; color: var(--text-muted); margin-top: 4px; }

/* ───────────────────────────────────────────
   BADGES
─────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-red    { background: var(--red-light);    color: var(--red); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-blue   { background: var(--blue-light);   color: var(--blue); }
.badge-purple { background: var(--accent-light); color: var(--accent); }
.badge-gray   { background: var(--bg-hover);     color: var(--text-secondary); }

/* ───────────────────────────────────────────
   MODAL
─────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.12s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
  animation: slideUp 0.15s ease;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-lg { max-width: 780px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text-muted); font-size: 18px;
  padding: 4px; border-radius: 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--red); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ───────────────────────────────────────────
   TOOLBAR / SEARCH
─────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.search-box { position: relative; flex: 1; min-width: 180px; }
.search-box input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px 8px 34px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition);
}
.search-box input:focus { border-color: var(--accent); }
.search-box .search-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none; font-size: 14px;
}
.filter-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--accent); }

/* ─── Operation item rows ─── */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
  text-align: left; padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.72rem;
  font-weight: 600; text-transform: uppercase;
}
.items-table td { padding: 5px 4px; }
.add-item-row {
  padding: 10px; text-align: center;
  border-top: 1px dashed var(--border);
  margin-top: 8px;
}

/* ───────────────────────────────────────────
   TOAST
─────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  min-width: 220px; max-width: 360px;
  pointer-events: all;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--yellow); }
.toast.info    { border-left: 3px solid var(--accent); }
.toast-icon { font-size: 16px; }

/* ─── Empty state ─── */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 0.875rem; }

/* ─── Spinner ─── */
.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(10,10,10,0.65);
  display: flex; align-items: center; justify-content: center;
  border-radius: inherit; z-index: 10;
}

/* ─── Tabs ─── */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tab-btn {
  background: none; border: none;
  padding: 9px 14px;
  color: var(--text-secondary);
  font-size: 0.875rem; font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Page header ─── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-header-title h2 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }
.page-header-title p  { color: var(--text-secondary); font-size: 0.825rem; margin-top: 2px; }

/* ───────────────────────────────────────────
   RESPONSIVE
─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.6); }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .page-content { padding: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .content-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .toolbar .search-box { width: 100%; }
  .modal { max-width: calc(100vw - 24px); margin: 12px; border-radius: 10px; }
  .modal-body { max-height: 70vh; overflow-y: auto; }
  .login-box { padding: 32px 22px 28px; margin: 16px; }
  .login-box .login-logo h1 { font-size: 1.2rem; }

  /* Таблицы — горизонтальная прокрутка */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }

  /* Карточки статистики */
  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 1.2rem !important; }

  /* Страница заголовка */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header-title h2 { font-size: 1.05rem; }
  .page-header .flex { flex-wrap: wrap; }

  /* Карточки задач */
  .task-card { grid-template-columns: 1fr; }
  .task-actions { flex-direction: row; flex-wrap: wrap; }

  /* Кнопки в таблицах — чуть крупнее для тапа */
  .btn-icon { min-width: 34px; min-height: 34px; font-size: 1rem; }
  .td-actions { gap: 6px; }

  /* Скрываем некоторые колонки на мобиле */
  .hide-sm { display: none !important; }

  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 99; display: none;
  }
  .sidebar-overlay.show { display: block; }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-title { font-size: 0.875rem; }
  .page-content { padding: 10px; }
  .card { padding: 14px; }
  .topbar { padding: 0 14px; }

  /* Операции форма — стек */
  .op-form-card { padding: 14px; }
  .item-row-head, .item-row { font-size: 0.8rem; }
}

/* ───────────────────────────────────────────
   UTILITIES
─────────────────────────────────────────── */
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue   { color: var(--blue); }
.text-muted  { color: var(--text-muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-bold   { font-weight: 700; }
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.mb-16       { margin-bottom: 16px; }
.mb-20       { margin-bottom: 20px; }
.hidden      { display: none !important; }
.monospace   { font-family: 'Courier New', monospace; font-size: 0.92em; }

/* Operation type colours */
.op-receipt  { color: var(--green); }
.op-expense  { color: var(--red); }
.op-transfer { color: var(--blue); }
.op-writeoff { color: var(--yellow); }

/* ─── User dropdown (logout popup) ─── */
.user-card {
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.user-card:hover { background: var(--bg-hover); }
.user-chevron {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.user-dropdown {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 4px 0 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  color: var(--red);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.user-dropdown-item:hover { background: var(--red-light); }

/* ── Responsive helpers ── */
@media (max-width: 768px) {
  .hide-sm { display: none !important; }
}
.money-blur { filter: blur(5px); transition: filter 0.2s; }
.money-blur:hover { filter: none; }
