:root {
  --navy-1: #020b3a;
  --navy-2: #01052a;
  --navy-3: #06114f;
  --purple: #4318ff;
  --purple-2: #601cff;
  --purple-soft: #f2edff;
  --text: #09114a;
  --text-soft: #5c689a;
  --line: #e8ebf4;
  --panel: #ffffff;
  --bg: #fbfcff;
  --green: #16a34a;
  --green-soft: #ebf8ef;
  --orange: #ff7a00;
  --orange-soft: #fff2e8;
  --red: #ff2f2f;
  --red-soft: #fdeaea;
  --blue: #2563eb;
  --blue-soft: #eaf3ff;
  --shadow: 0 12px 28px rgba(13, 19, 64, 0.04);
  --sidebar-w: 224px;
  --sidebar-collapsed: 92px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; border: 0; background: transparent; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }

.history-app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
body.sidebar-collapsed .history-app { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }

.history-sidebar {
  display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: 16px 14px 18px;
  background: radial-gradient(circle at 22px 22px, rgba(96, 32, 255, 0.3), transparent 84px), linear-gradient(180deg, var(--navy-3) 0%, var(--navy-2) 54%, #000b33 100%);
  box-shadow: 18px 0 44px rgba(4, 11, 51, 0.16);
}
.sidebar-brand-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 10px 18px; }
.sidebar-brand-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #3200ef 0%, #651dff 100%); box-shadow: 0 12px 24px rgba(68, 24, 255, 0.32); flex: 0 0 44px; }
.sidebar-brand-icon svg { width: 24px; height: 24px; stroke-width: 2; }
.brand-copy strong { display: block; color: #fff; font-size: 18px; font-weight: 800; letter-spacing: -0.03em; }
.brand-copy small { display: block; margin-top: 2px; color: rgba(255,255,255,0.92); font-size: 10px; font-weight: 700; letter-spacing: 0.06em; }
.sidebar-toggle { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; color: rgba(255,255,255,0.86); border-radius: 10px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.06); }
.sidebar-toggle svg { width: 18px; height: 18px; stroke-width: 2.2; transition: transform .2s ease; }

.history-nav { padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); }
.nav-item, .logout-link {
  height: 46px; display: flex; align-items: center; gap: 14px; padding: 0 12px; margin-bottom: 5px; border-radius: 10px;
  color: rgba(255,255,255,0.96); font-size: 14px; font-weight: 600; transition: background .2s ease, color .2s ease;
}
.nav-item:hover, .logout-link:hover { background: rgba(255,255,255,0.05); }
.nav-item.active { color: #fff; background: linear-gradient(135deg, #3500ee 0%, #5e1cff 100%); box-shadow: 0 14px 26px rgba(67, 14, 255, 0.26); }
.nav-icon { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 28px; }
.nav-icon svg { width: 21px; height: 21px; stroke-width: 1.9; }
.nav-text { white-space: nowrap; }

.assist-card {
  margin: 18px 4px 18px; padding: 18px 16px 16px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(81, 20, 255, 0.28) 0%, rgba(63, 18, 180, 0.66) 100%);
  border: 1px solid rgba(255,255,255,0.08); color: #fff;
}
.assist-card h3 { margin: 0 0 8px; font-size: 18px; font-weight: 800; line-height: 1.35; }
.assist-card p { margin: 0 0 18px; color: rgba(255,255,255,0.96); font-size: 14px; line-height: 1.45; }
.assist-bottom-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.assist-bottom-row button { min-width: 114px; height: 38px; padding: 0 14px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, #3500ee 0%, #5d1cff 100%); font-size: 13px; font-weight: 700; }
.assist-bot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,0.12); }
.assist-bot svg { width: 22px; height: 22px; stroke-width: 1.8; }
.logout-link { margin-top: 8px; }

.history-main { min-width: 0; padding: 22px 24px 18px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.page-head p { margin: 6px 0 0; color: var(--text-soft); font-size: 14px; }
.head-actions { display: flex; align-items: center; gap: 20px; }
.date-btn, .export-btn, .filter-btn, .clear-btn, .per-page-btn {
  height: 52px; display: inline-flex; align-items: center; justify-content: center; gap: 12px; border-radius: 12px; font-size: 15px; font-weight: 650;
}
.date-btn {
  min-width: 286px; padding: 0 18px; color: #172359; border: 1px solid #dde2f0; background: #fff;
}
.export-btn {
  min-width: 122px; color: #fff; background: linear-gradient(135deg, #3500ee 0%, #5d1cff 100%); box-shadow: 0 14px 30px rgba(67, 14, 255, 0.2);
}
.date-btn svg, .export-btn svg, .filter-btn svg, .clear-btn svg, .search-box svg, .pay-badge svg, .view-btn svg, .per-page-btn svg { width: 20px; height: 20px; stroke-width: 1.9; }
.caret { width: 18px !important; height: 18px !important; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.summary-card { min-height: 116px; display: flex; align-items: center; gap: 20px; padding: 20px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.summary-icon { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; flex: 0 0 60px; }
.summary-icon svg { width: 30px; height: 30px; stroke-width: 1.8; }
.summary-icon.purple { color: #fff; background: linear-gradient(135deg, #4318ff 0%, #6621ff 100%); box-shadow: 0 12px 22px rgba(67, 24, 255, 0.24); }
.summary-icon.green { color: #fff; background: linear-gradient(135deg, #17a44c 0%, #2ec86a 100%); box-shadow: 0 12px 22px rgba(23, 164, 76, 0.2); }
.summary-icon.soft-green { color: #16a34a; background: #e8f7ed; }
.summary-icon.pale-green { color: #20a84b; background: #e7f6ea; }
.card-label { display: block; color: #29346f; font-size: 14px; font-weight: 600; }
.summary-card h2 { margin: 6px 0 6px; font-size: 22px; line-height: 1.2; font-weight: 800; letter-spacing: -0.03em; }
.summary-card p { margin: 0; color: var(--text-soft); font-size: 14px; }

.table-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.filter-row {
  display: grid; grid-template-columns: minmax(260px, 1.9fr) minmax(170px, .75fr) minmax(220px, 1fr) minmax(160px, .8fr) minmax(160px, .8fr); gap: 14px; padding: 18px; border-bottom: 1px solid var(--line);
}
.search-box {
  height: 50px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border: 1px solid #dde2f0; border-radius: 12px; background: #fff;
}
.search-box svg { color: #4b5795; flex: 0 0 20px; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 15px; }
.search-box input::placeholder { color: #6672a5; }
.filter-btn, .clear-btn { min-width: 0; padding: 0 16px; color: #172359; border: 1px solid #dde2f0; background: #fff; white-space: nowrap; }
.filter-btn.wide { padding-left: 14px; padding-right: 14px; }

.table-wrap { overflow-x: auto; }
.history-table {
  min-width: 1220px; display: grid; grid-template-columns: 1.15fr 1.1fr 1.2fr 1.45fr .55fr 1.05fr 1.15fr 1fr .8fr; align-items: center;
}
.history-header {
  min-height: 46px; padding: 0 18px; color: #141f5a; font-size: 13px; font-weight: 800; border-bottom: 1px solid var(--line);
}
.sort-arrow { color: #7380b2; font-size: 12px; }
.history-row {
  min-height: 76px; padding: 0 18px; color: #1d255f; font-size: 14px; border-bottom: 1px solid #edf0f7;
}
.invoice-col a { display: block; color: #3524ff; font-size: 15px; font-weight: 800; }
.invoice-col span, .date-col span, .customer-col span { display: block; margin-top: 5px; color: #576293; font-size: 13px; }
.date-col strong, .customer-col strong { display: block; font-size: 15px; font-weight: 500; }
.cashier-col { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-block; position: relative; box-shadow: 0 4px 10px rgba(10,18,60,0.12); }
.avatar.male { background: radial-gradient(circle at 50% 32%, #6d3e21 0 16%, transparent 16%), radial-gradient(circle at 50% 38%, #db9f72 0 24%, transparent 24%), linear-gradient(180deg, #111a4d 0 46%, #fff 46% 61%, #0f1e74 61% 100%); }
.avatar.male::before { content: ''; position: absolute; top: 4px; left: 7px; width: 20px; height: 9px; border-radius: 50% 50% 40% 40%; background: #1f1107; }
.avatar.male::after { content: ''; position: absolute; bottom: 1px; right: 1px; width: 7px; height: 7px; border-radius: 50%; background: #14c35b; border: 2px solid #fff; }
.avatar.female { background: radial-gradient(circle at 50% 35%, #d88f63 0 22%, transparent 22%), linear-gradient(180deg, #191a3b 0 43%, #e88720 43% 45%, #fff 45% 62%, #11174a 62% 100%); }
.avatar.female::before { content: ''; position: absolute; top: 3px; left: 4px; width: 26px; height: 19px; border-radius: 50% 50% 48% 48%; background: #0c0b11; }
.pay-badge, .status-badge, .view-btn {
  min-height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; font-size: 14px; font-weight: 700;
}
.pay-badge { min-width: 96px; padding: 0 12px; color: #172359; background: #f5f7fb; }
.pay-badge svg { width: 18px; height: 18px; color: #16a34a; }
.pay-badge.cash svg { color: #19a84c; }
.status-badge { min-width: 100px; padding: 0 12px; color: #178f43; background: #ebf8ef; font-size: 13px; }
.view-btn { min-width: 80px; padding: 0 12px; color: #3524ff; background: #fff; border: 1px solid #dfe4f1; }
.view-btn svg { width: 17px; height: 17px; }

.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 16px 16px; }
.table-footer p { margin: 0; color: #223066; font-size: 14px; font-weight: 550; }
.pagination { display: flex; align-items: center; gap: 12px; }
.page-btn { width: 42px; height: 42px; border-radius: 10px; color: #202a62; background: #fff; border: 1px solid #dfe4f1; font-size: 15px; font-weight: 700; }
.page-btn.active { color: #fff; border-color: transparent; background: linear-gradient(135deg, #3500ee 0%, #5d1cff 100%); box-shadow: 0 14px 26px rgba(67, 14, 255, 0.22); }
.page-btn.muted { color: #8d96bc; }
.per-page-btn { min-width: 152px; padding: 0 18px; color: #202a62; border: 1px solid #dfe4f1; background: #fff; }

body.sidebar-collapsed .history-sidebar { padding-left: 10px; padding-right: 10px; }
body.sidebar-collapsed .brand-copy, body.sidebar-collapsed .nav-text, body.sidebar-collapsed .assist-copy, body.sidebar-collapsed .assist-bottom-row button, body.sidebar-collapsed .logout-link .nav-text { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-right: 0; padding-left: 0; }
body.sidebar-collapsed .sidebar-brand-row { flex-direction: column; align-items: center; gap: 12px; }
body.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
body.sidebar-collapsed .nav-item, body.sidebar-collapsed .logout-link { justify-content: center; padding: 0; }
body.sidebar-collapsed .assist-card { padding: 12px; display: grid; place-items: center; }
body.sidebar-collapsed .assist-bottom-row { justify-content: center; }

@media (max-width: 1380px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-row { grid-template-columns: minmax(240px, 1.6fr) minmax(170px, 1fr) minmax(210px, 1fr); }
}
@media (max-width: 1160px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .head-actions { justify-content: flex-end; }
  .filter-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 980px) {
  .history-app, body.sidebar-collapsed .history-app { grid-template-columns: 1fr; }
  .history-sidebar { min-height: auto; }
  .history-main { padding: 16px; }
  .summary-grid, .filter-row { grid-template-columns: 1fr; }
  .head-actions { flex-direction: column; align-items: stretch; }
  .date-btn, .export-btn, .filter-btn, .clear-btn, .per-page-btn { width: 100%; }
  .table-footer { flex-direction: column; align-items: flex-start; }
}
