/* ===================================
   AccBooks — Professional Dark Theme
   =================================== */

:root {
  --bg-900: #0d0f14;
  --bg-800: #13161e;
  --bg-700: #1a1e2a;
  --bg-600: #222736;
  --bg-500: #2b3045;
  --border: #2e3447;
  --border-light: #3d4460;

  --accent: #4f6ef7;
  --accent-light: #6b85ff;
  --accent-dim: rgba(79, 110, 247, 0.15);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --yellow: #f59e0b;
  --yellow-dim: rgba(245, 158, 11, 0.15);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.15);

  --text-primary: #e8eaf0;
  --text-secondary: #8892a4;
  --text-muted: #4f5b72;

  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.3);

  --header-h: 56px;
  --nav-h: 64px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-900);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--nav-h) + 8px);
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg-800); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

/* ---- HEADER ---- */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-800);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.app-logo {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 8px; }

/* ---- BOTTOM NAV ---- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg-800);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: color 0.2s;
  position: relative;
}

.nav-item i { font-size: 18px; transition: transform 0.2s; }

.nav-item.active {
  color: var(--accent-light);
}

.nav-item.active i { transform: translateY(-2px); }

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

/* ---- MAIN CONTENT ---- */
.main-content { padding: 0; min-height: calc(100vh - var(--header-h) - var(--nav-h)); }

/* ---- TABS ---- */
.tabs { display: flex; background: var(--bg-800); border-bottom: 1px solid var(--border); }
.tab-btn {
  flex: 1;
  padding: 14px 8px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}
.tab-btn.active { color: var(--accent-light); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---- CARDS ---- */
.card {
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 14px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

.stat-card {
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.stat-card .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}

.stat-card .value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-card.green { border-color: rgba(34,197,94,0.3); background: var(--green-dim); }
.stat-card.green .value { color: var(--green); }
.stat-card.red { border-color: rgba(239,68,68,0.3); background: var(--red-dim); }
.stat-card.red .value { color: var(--red); }
.stat-card.blue { border-color: rgba(79,110,247,0.3); background: var(--accent-dim); }
.stat-card.blue .value { color: var(--accent-light); }
.stat-card.yellow { border-color: rgba(245,158,11,0.3); background: var(--yellow-dim); }
.stat-card.yellow .value { color: var(--yellow); }

/* ---- SECTION HEADER ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-light); transform: translateY(-1px); }

.btn-success {
  background: var(--green);
  color: #fff;
}
.btn-success:hover { filter: brightness(1.1); }

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent-light); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.btn-fab {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 11px 20px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(79,110,247,0.4);
  transition: all 0.2s;
}
.btn-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(79,110,247,0.5); }
.btn-fab i { font-size: 16px; }

/* ---- LIST ITEMS ---- */
.list-item {
  display: flex;
  align-items: center;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 14px 8px;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
}
.list-item:hover { border-color: var(--accent); background: var(--bg-600); }

.list-item .item-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.list-item .item-info { flex: 1; min-width: 0; }
.list-item .item-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .item-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.list-item .item-right { text-align: right; flex-shrink: 0; }
.list-item .item-amount {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
}
.list-item .item-due {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}
.item-due.has-due { color: var(--red); }
.item-due.no-due { color: var(--green); }

/* ---- FORMS ---- */
.form-page { padding: 16px 14px 20px; }

.form-section {
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.form-section-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

select option { background: var(--bg-700); }
textarea { resize: vertical; min-height: 80px; }

.input-prefix {
  position: relative;
}
.input-prefix span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
}
.input-prefix input { padding-left: 28px; }

/* Radio groups */
.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-option {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.radio-option input[type="radio"] { display: none; }
.radio-option.selected, .radio-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent-light);
}

/* ---- PRODUCT TABLE IN SALE FORM ---- */
.product-table-wrap { overflow-x: auto; }
.product-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.product-table th {
  background: var(--bg-700);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.product-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.product-table tr:last-child td { border-bottom: none; }
.product-table input {
  width: 70px;
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 6px;
}
.product-table .del-btn {
  color: var(--red);
  background: var(--red-dim);
  border: none;
  border-radius: 6px;
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: 12px;
}

/* ---- TOTALS BOX ---- */
.totals-box {
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  color: var(--text-secondary);
}
.totals-row.total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 12px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-display);
}

/* ---- SEARCH BAR ---- */
.search-wrap {
  padding: 10px 14px;
}
.search-bar {
  position: relative;
}
.search-bar i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}
.search-bar input {
  padding-left: 36px;
  background: var(--bg-700);
}

/* ---- BADGE ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-blue { background: var(--accent-dim); color: var(--accent-light); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }

/* ---- DIVIDER ---- */
.divider { height: 1px; background: var(--border); margin: 8px 0; }

/* ---- EMPTY STATE ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  gap: 12px;
}
.empty-state i { font-size: 40px; opacity: 0.4; }
.empty-state p { font-size: 14px; text-align: center; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 20px 16px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(40px);
  transition: transform 0.25s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-close {
  background: var(--bg-600);
  border: none;
  border-radius: 50%;
  width: 30px; height: 30px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ---- ALERT ---- */
.alert {
  margin: 10px 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}
.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.alert-error, .alert-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }

/* ---- AUTOCOMPLETE ---- */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--bg-700);
  border: 1px solid var(--border-light);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.autocomplete-item:hover { background: var(--bg-600); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item .price { color: var(--accent-light); font-weight: 600; font-size: 12px; }

/* ---- PRINT HIDE ---- */
@media print {
  .bottom-nav, .app-header, .btn-fab, .no-print { display: none !important; }
  body { padding: 0; background: #fff; color: #000; }
}

/* ---- CHART WRAPPER ---- */
.chart-wrap {
  padding: 0 14px 14px;
  height: 220px;
}

/* ---- PAGE HEADER ---- */
.page-header {
  background: var(--bg-800);
  border-bottom: 1px solid var(--border);
  padding: 14px 14px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-header .back-btn {
  background: var(--bg-600);
  border: none;
  border-radius: var(--radius-sm);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  flex-shrink: 0;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  flex: 1;
}