:root {
  --accent: #e8542a;
  --accent-bg: #fdeee9;
  --text-dark: #171923;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --border: #e5e7eb;
  --bg-page: #f7f8fa;
  --bg-white: #ffffff;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text-dark);
  background: var(--bg-page);
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  width: 20px;
  height: 20px;
  display: block;
}

.brand-name {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.3px;
}

.brand-sub {
  font-size: 9px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-muted);
  text-align: right;
}

.chevron-left { font-size: 13px; }

.nav {
  flex: 1;
  padding: 0 10px;
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.5px;
  padding: 14px 10px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin: 1px 0;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.12s ease;
}

.nav-item:hover {
  background: #f3f4f6;
}

.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 700;
  border-left: 3px solid var(--accent);
  margin-left: -3px;
}

.nav-item .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Main */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-page);
}

.breadcrumb-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.user-name {
  font-weight: 700;
  font-size: 13.5px;
}

.user-sub {
  font-size: 11px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.user-sub .role {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.3px;
}

.user-sub .phone {
  color: var(--text-faint);
}

.content {
  padding: 8px 32px 48px;
}

.breadcrumb {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.breadcrumb .current {
  color: var(--text-dark);
  font-weight: 600;
}

.breadcrumb .sep {
  margin: 0 4px;
}

h1 {
  font-size: 28px;
  font-weight: 800;
  margin: 0 0 8px;
}

.page-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 22px;
  max-width: 720px;
}

.modules-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
}

.module-card {
  display: block;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.module-card:hover {
  border-color: #d8dbe0;
  box-shadow: 0 2px 10px rgba(16, 20, 30, 0.06);
}

.module-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.module-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.module-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 4px 8px;
  border-radius: 6px;
}

.module-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.module-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
}

@media (max-width: 1100px) {
  .modules-grid { grid-template-columns: repeat(2, minmax(200px, 1fr)); }
}

@media (max-width: 700px) {
  .modules-grid { grid-template-columns: 1fr; }
}

.search-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-faint);
}

.search-box input {
  border: none;
  outline: none;
  font-size: 14px;
  flex: 1;
  background: transparent;
  color: var(--text-dark);
}

.search-box input::placeholder {
  color: var(--text-faint);
}

.count {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.tab-strip {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 4px;
  margin-right: 20px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.tab:hover {
  color: var(--text-dark);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.table-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.table-card-scroll {
  overflow: auto;
  max-height: 65vh;
}

.data-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  text-align: left;
}

.data-table thead th {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #202631;
  letter-spacing: 0.2px;
  background: var(--accent-bg);
  border-bottom: 2px solid var(--accent);
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.2;
  vertical-align: bottom;
  padding: 16px 14px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table thead th.col-frozen {
  left: 0;
  z-index: 3;
}

.data-table tbody td {
  font-size: 12.5px;
  font-weight: 400;
  color: #475569;
  line-height: 1.3;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  padding: 15px 14px;
}

.data-table tbody td.cell-strong {
  font-weight: 600;
  color: #1f2937;
}

.data-table tbody td.col-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table thead th.col-right {
  text-align: right;
}

.data-table tbody td.col-frozen {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
}

.data-table .dash {
  color: #94a3b8;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:nth-child(even) td {
  background: var(--bg-page);
}

.data-table tbody tr:hover td {
  background: #f1f5f9;
}

.dash {
  color: var(--text-faint);
}

.no-results {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
}


@media (max-width: 900px) {
  .sidebar { display: none; }
}

.logout-btn {
  appearance: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 8px;
}

.logout-btn:hover {
  background: #fafafa;
  color: var(--text-dark);
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  margin: 0 0 4px;
}

.login-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 16px 0 6px;
}

.login-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-page);
}

.login-input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-submit {
  width: 100%;
  margin-top: 22px;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.login-submit:hover {
  opacity: 0.92;
}

.login-error {
  background: #fdeee9;
  color: var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  margin: 22px 0;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.login-divider span {
  padding: 0 10px;
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-white);
  color: var(--text-dark);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-sizing: border-box;
}

.google-btn:hover {
  background: #fafafa;
}

/* Analytics */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: #1f2937;
  line-height: 1.2;
}

.stat-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 16px;
}

.analytics-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.analytics-card h2 {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 16px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 110px 1fr 44px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12.5px;
}

.breakdown-label {
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breakdown-bar-track {
  background: var(--bg-page);
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
}

.breakdown-bar {
  background: var(--accent);
  height: 100%;
  border-radius: 6px;
}

.breakdown-count {
  text-align: right;
  font-weight: 600;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .analytics-grid { grid-template-columns: 1fr; }
}
