@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');

:root {
  --font-family-primary: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sidebar-bg: #161b2c;
  --sidebar-bg-hover: #212842;
  --accent: #17c299;       /* EV / charge green */
  --accent-dark: #109f7d;
  --accent-soft: #eefaf5;
  --text-dark: #1a1d24;
  --text-muted: #6b7280;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --border: #e7e9f0;
  --danger: #e0524b;
  --sidebar-w: 250px;
  --topbar-h: 60px;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(20,22,35,0.05), 0 1px 1px rgba(20,22,35,0.03);
  --shadow-md: 0 4px 14px rgba(20,22,35,0.06), 0 1px 3px rgba(20,22,35,0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-family-primary);
  background: var(--bg);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ---------- Layout shell ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #d7dae2;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 40;
  transition: transform 0.25s ease;
  box-shadow: 2px 0 12px rgba(20,22,35,0.08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.sidebar-brand span {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.3px;
  color: #fff;
}

.nav-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 20px 8px;
  padding: 0;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #6d7383;
}
.nav-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, rgba(255,255,255,0.10), rgba(255,255,255,0));
}
.nav-section-label:first-of-type { margin-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 10px;
  padding: 9px 12px;
  font-size: 14px;
  color: #c3c7d1;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover { background: var(--sidebar-bg-hover); color: #fff; }

.nav-parent::after {
  content: '';
  width: 6px;
  height: 6px;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: 0.55;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.nav-parent.open::after { transform: rotate(45deg); }

.nav-item.active {
  background: var(--accent);
  color: #06231b;
  font-weight: 600;
}
.nav-item.active .icon { opacity: 1; }

.nav-item .icon { width: 20px; display: inline-flex; align-items: center; justify-content: center; opacity: 0.85; }
.nav-item .icon svg { display: block; }

.nav-sub {
  padding-left: 20px;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.2s ease;
}

.nav-sub.open { max-height: 400px; }

.nav-sub .nav-item { padding-left: 44px; font-size: 13.5px; }

/* ---------- Main area ---------- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(20,22,35,0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-welcome {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
}

.topbar .page-title {
  font-size: 17px;
  font-weight: 600;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-dark);
  margin-right: 10px;
}

.logout-link {
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.content {
  padding: 22px;
  flex: 1;
}

/* ---------- Cards / grid ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}

.card h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; }

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

input[type=text], input[type=password], input[type=number], input[type=tel],
input[type=date], input[type=month], input[type=email], input[type=search],
select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  background: #fbfbfc;
  color: var(--text-dark);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(23,194,153,0.15);
}

.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: #06231b; box-shadow: 0 2px 6px rgba(23,194,153,0.25); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #eef0f3; color: var(--text-dark); }
.btn-secondary:hover { background: #e4e6ec; }
.btn-danger { background: #fceceb; color: var(--danger); }
.btn-danger:hover { background: #fbdedc; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; border: 1px solid var(--border); }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { background: #fafbfd; color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text-dark); }
tr:hover td { background: #fafbfc; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* ---------- Action menu (kebab / 3-dot) ---------- */
.action-menu { position: relative; display: inline-block; }
.action-menu-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px;
  height: 28px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
}
.action-menu-btn:hover { background: #eef0f3; color: var(--text-dark); }
.action-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  min-width: 130px;
  z-index: 45;
  padding: 4px;
  text-align: left;
}
.action-menu-dropdown.open { display: block; }
.action-menu-item {
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dark);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.action-menu-item:hover { background: #f4f5f7; }
.action-menu-item.danger { color: var(--danger); }
.action-menu-item.danger:hover { background: #fceceb; }

.status-pill {
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.status-active { background: #eefaf5; color: var(--accent-dark); }
.status-inactive { background: #f4f4f5; color: #8a8f98; }

.alert {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.alert-success { background: #eefaf5; color: #0e7a5f; border: 1px solid #b9ecdd; }
.alert-error { background: #fceceb; color: #b3261e; border: 1px solid #f3c8c5; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Dashboard widgets ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  border-top: 3px solid var(--accent);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card .label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat-card .card-desc { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; line-height: 1.3; }

.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10,12,16,0.5);
  z-index: 35;
}
.overlay.show { display: block; }

/* ---------- Modal ---------- */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10,12,16,0.55);
  z-index: 60;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(20,22,35,0.25);
  width: 100%;
  max-width: 480px;
  padding: 22px;
}

/* ---------- Pill tab bars (Master Data, New Voucher Creation, Stock Report...) ---------- */
.master-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.master-tab {
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.master-tab:hover { color: #fff; background: #e1ad01; border-color: #e1ad01; }
.master-tab.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}
.modal-box .modal-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-box .modal-title-row h3 { margin: 0; border: none; padding: 0; }
.modal-close-x {
  background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted);
}

/* ---------- Bottom nav (Sales role) ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 60px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  text-align: center;
  padding: 4px 2px;
}
.bottom-nav-item .bn-icon { display: flex; align-items: center; justify-content: center; }
.bottom-nav-item .bn-icon svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--accent-dark); }
body.has-bottom-nav .content { padding-bottom: 80px; }

.sidebar-user-info {
  display: block;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 10px;
}
.sidebar-user-info .sidebar-user-name {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.sidebar-user-info .badge {
  background: #eefaf5;
  color: var(--accent-dark);
  border: 1px solid #b9ecdd;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: inline-block;
}
.sidebar-user-info .logout-link {
  display: block;
  margin-top: 10px;
  color: #f0827c;
  font-size: 13px;
  font-weight: 600;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .topbar-welcome { display: none; }
}
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: inline-block; }
  .content { padding: 14px; }
  .card { padding: 14px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  th, td { padding: 8px; font-size: 12.5px; }
}
