/* ===== Базовые переменные ===== */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c1f26;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0 0 8px; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ===== Auth pages ===== */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
}
.auth-card {
  background: var(--surface);
  padding: 36px 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
}
.auth-card h1 { font-size: 22px; }
.auth-card .subtitle { color: var(--text-muted); margin-bottom: 20px; }
.auth-card form label {
  display: block; margin-bottom: 14px; font-size: 14px; color: var(--text-muted);
}
.auth-card form input {
  width: 100%; padding: 10px 12px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 15px;
}

.btn {
  display: inline-block; padding: 10px 18px; border-radius: 8px;
  border: none; font-size: 14px; font-weight: 600; transition: 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef0f3; color: var(--text); }
.btn-secondary:hover { background: #dfe3e8; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; text-align: center; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.msg { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.msg-error { background: #fee2e2; color: #991b1b; }
.msg-success { background: #dcfce7; color: #166534; }
.msg-info { background: #dbeafe; color: #1e40af; }

/* ===== App shell (admin) ===== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: #111827; color: #e5e7eb;
  flex-shrink: 0; padding: 20px 0; display: flex; flex-direction: column;
}
.sidebar .brand { padding: 0 20px 20px; font-size: 18px; font-weight: 700; color: #fff; border-bottom: 1px solid #1f2937; margin-bottom: 10px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; color: #9ca3af; font-size: 14px; font-weight: 500;
}
.sidebar nav a:hover { background: #1f2937; color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar .sidebar-footer { margin-top: auto; padding: 16px 20px; border-top: 1px solid #1f2937; font-size: 13px; color: #9ca3af; }
.sidebar .sidebar-footer a { color: #f87171; }

.main { flex: 1; padding: 28px 32px; min-width: 0; }
.main-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.main-header h1 { font-size: 22px; }

/* ===== Cards / KPI ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi-card .kpi-label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.kpi-card .kpi-value { font-size: 24px; font-weight: 700; }
.kpi-card .kpi-value.positive { color: var(--success); }
.kpi-card .kpi-value.negative { color: var(--danger); }
.kpi-card .kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card h2 { font-size: 16px; margin-bottom: 14px; }
.card-row { display: flex; gap: 20px; flex-wrap: wrap; }
.card-row > .card { flex: 1; min-width: 320px; }

/* ===== Tables ===== */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
table th, table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table th { color: var(--text-muted); font-weight: 600; font-size: 13px; }
table tr:hover td { background: #fafafa; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag-green { background: #dcfce7; color: #166534; }
.tag-red { background: #fee2e2; color: #991b1b; }
.tag-gray { background: #f3f4f6; color: #4b5563; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ===== POS terminal ===== */
.pos-shell { display: flex; height: 100vh; overflow: hidden; }
.pos-main { flex: 1; display: flex; flex-direction: column; padding: 16px 20px; overflow-y: auto; }
.pos-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.pos-topbar .brand { font-size: 18px; font-weight: 700; }
.pos-topbar .user-info { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 14px; }
.pos-search { margin-bottom: 14px; }
.pos-search input { width: 100%; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border); font-size: 15px; }
.pos-categories { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.pos-categories button {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border); background: #fff; font-size: 14px; font-weight: 500;
}
.pos-categories button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.pos-item {
  background: var(--surface); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  cursor: pointer; transition: 0.12s; border: 2px solid transparent; text-align: left;
}
.pos-item:hover { border-color: var(--primary); transform: translateY(-1px); }
.pos-item .pi-name { font-weight: 600; font-size: 14px; margin-bottom: 6px; min-height: 36px; }
.pos-item .pi-price { color: var(--primary); font-weight: 700; }

.pos-cart { width: 360px; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.pos-cart-header { padding: 16px 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; }
.pos-cart-items { flex: 1; overflow-y: auto; padding: 8px 14px; }
.cart-line { display: flex; align-items: center; gap: 8px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.cart-line .cl-name { flex: 1; font-size: 13.5px; font-weight: 500; }
.cart-line .cl-price { font-size: 12.5px; color: var(--text-muted); }
.cart-qty { display: flex; align-items: center; gap: 6px; }
.cart-qty button { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: #fff; font-size: 14px; line-height: 1; }
.cart-line .cl-remove { color: var(--danger); font-size: 13px; padding: 0 4px; }
.pos-cart-footer { padding: 16px 18px; border-top: 1px solid var(--border); }
.pos-total-row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; color: var(--text-muted); }
.pos-total-row.grand { font-size: 19px; font-weight: 700; color: var(--text); margin: 10px 0; }
.pos-pay-methods { display: flex; gap: 8px; margin-bottom: 12px; }
.pos-pay-methods button { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-weight: 600; }
.pos-pay-methods button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pos-checkout-btn { width: 100%; padding: 14px; font-size: 16px; }
.empty-cart { text-align: center; color: var(--text-muted); padding: 40px 10px; font-size: 14px; }

.discount-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.discount-row input { width: 90px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }

/* Receipt modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 24px; max-width: 360px; width: 100%; text-align: center; }
.modal-box .icon-success { font-size: 48px; color: var(--success); margin-bottom: 10px; }

@media (max-width: 900px) {
  .pos-shell { flex-direction: column; height: auto; }
  .pos-cart { width: 100%; border-left: none; border-top: 1px solid var(--border); }
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; }
  .sidebar nav { display: flex; }
}
