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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f5f7fa;
  min-height: 100vh;
}

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

.sidebar {
  width: 240px;
  background: linear-gradient(180deg, #1a1f36 0%, #2d3555 100%);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header .logo {
  font-size: 36px;
  margin-bottom: 10px;
}

.sidebar-header h2 {
  font-size: 18px;
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-left-color: #667eea;
}

.nav-icon {
  margin-right: 12px;
  font-size: 18px;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-btn {
  width: 100%;
  padding: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.main-content {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
}

.top-header {
  background: white;
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left h1 {
  font-size: 22px;
  color: #333;
}

.admin-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-avatar {
  font-size: 24px;
}

.admin-name {
  color: #333;
  font-weight: 500;
}

.content-area {
  padding: 30px;
  flex: 1;
}

.page-content {
  display: none;
}

.page-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.stat-icon.blue { background: #e3f2fd; }
.stat-icon.green { background: #e8f5e9; }
.stat-icon.orange { background: #fff3e0; }
.stat-icon.purple { background: #f3e5f5; }

.stat-info h3 {
  font-size: 28px;
  color: #333;
  margin-bottom: 5px;
}

.stat-info p {
  color: #888;
  font-size: 14px;
}

.recent-section {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.recent-section h2 {
  font-size: 18px;
  color: #333;
  margin-bottom: 20px;
}

.dashboard-freight-overview {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-top: 24px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.dashboard-freight-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.dashboard-freight-header h2 {
  font-size: 18px;
  color: #333;
  margin: 0;
}

.dashboard-freight-year-label {
  font-size: 14px;
  color: #666;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-freight-year-label input {
  width: 88px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.dashboard-freight-hint {
  font-size: 12px;
  color: #888;
  margin: 0 0 12px;
  line-height: 1.5;
}

.dashboard-freight-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 10px;
  margin: 0 -2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #c5cad3 #eef0f3;
}

.dashboard-freight-scroll::-webkit-scrollbar {
  height: 8px;
}

.dashboard-freight-scroll::-webkit-scrollbar-thumb {
  background: #c5cad3;
  border-radius: 4px;
}

.dashboard-freight-scroll::-webkit-scrollbar-track {
  background: #eef0f3;
  border-radius: 4px;
}

.dashboard-freight-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 12px;
  width: max-content;
  min-height: 1px;
}

.dashboard-freight-module {
  border: 1px solid #e8eaec;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fafbfc;
  min-height: 120px;
  flex: 0 0 176px;
  width: 176px;
  max-width: 176px;
  box-sizing: border-box;
}

.dashboard-freight-module--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 13px;
}

.dashboard-freight-module--solo {
  flex: 1 1 auto;
  width: auto;
  max-width: none;
  min-width: 160px;
}

.dashboard-freight-module-name {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 6px;
  font-weight: 600;
  font-size: 15px;
  color: #2c3e50;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e8eaec;
}

.dashboard-freight-module-name .dfm-user {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-freight-module-name .dfm-year-total {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: #2d8cf0;
  font-variant-numeric: tabular-nums;
}

.dashboard-freight-month-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
  font-size: 12px;
}

.dashboard-freight-month-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  color: #444;
}

.dashboard-freight-month-row .dfm-label {
  color: #888;
  flex-shrink: 0;
  width: 2.2em;
}

.dashboard-freight-month-row .dfm-amt {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.data-table th {
  background: #f8f9fa;
  color: #666;
  font-weight: 500;
  font-size: 14px;
}

.data-table td {
  color: #333;
  font-size: 14px;
}

.data-table td.remark-cell {
  max-width: 220px;
  word-break: break-word;
  vertical-align: top;
  line-height: 1.45;
}

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

.data-table .inline-delivery-date {
  width: 100%;
  max-width: 200px;
  min-width: 160px;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid #c5cae9;
  border-radius: 6px;
  background: #fafbff;
  box-sizing: border-box;
}

.data-table .inline-delivery-date:focus {
  outline: none;
  border-color: #5c6bc0;
  background: #fff;
}

.data-table .loading {
  text-align: center;
  color: #888;
  padding: 40px;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.pending {
  background: #fff3e0;
  color: #f57c00;
}

.status-badge.approved {
  background: #e8f5e9;
  color: #388e3c;
}

.status-badge.rejected {
  background: #ffebee;
  color: #d32f2f;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.search-box input {
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  width: 250px;
  font-size: 14px;
}

.filter-box {
  display: flex;
  gap: 10px;
  align-items: center;
}

.filter-box select {
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  background: white;
}

.users-page-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 20px;
}

.users-page-title-row h2 {
  margin: 0;
}

.users-record-month-filter label {
  font-size: 14px;
  color: #555;
  white-space: nowrap;
}

.users-record-month-filter input[type='month'] {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  background: white;
}

.btn-primary {
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.btn-success {
  padding: 10px 20px;
  background: #4caf50;
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-success:hover {
  background: #43a047;
}

.btn-danger {
  padding: 10px 20px;
  background: #f44336;
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-danger:hover {
  background: #e53935;
}

.btn-secondary {
  padding: 10px 20px;
  background: #e0e0e0;
  border: none;
  border-radius: 6px;
  color: #333;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background: #d0d0d0;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-small.view {
  background: #e3f2fd;
  color: #1976d2;
}

.btn-small.edit {
  background: #fff3e0;
  color: #f57c00;
}

.btn-small.delete {
  background: #ffebee;
  color: #d32f2f;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.pagination-info {
  color: #666;
  font-size: 13px;
  margin-right: 8px;
}

.pagination-current {
  padding: 6px 12px;
  color: #333;
  font-size: 13px;
}

.pagination button {
  padding: 8px 15px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pagination button:hover:not(:disabled),
.pagination button.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  animation: modalIn 0.3s ease;
}

.modal-content.modal-content--wide-users {
  max-width: min(720px, 96vw);
  width: 94%;
}

.modal-content.modal-content--cover {
  max-width: min(720px, 96vw);
}

.modal-body.modal-body--cover {
  max-height: min(82vh, 860px);
  padding: 16px 20px;
}

.shared-loc-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.shared-loc-gallery-item {
  position: relative;
  background: #f5f5f5;
  border-radius: 8px;
  overflow: hidden;
  padding: 8px;
  text-align: center;
}

.shared-loc-pending-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  font-size: 12px;
  color: #fff;
  background: rgba(180, 90, 30, 0.92);
  padding: 2px 8px;
  border-radius: 6px;
  pointer-events: none;
}

.shared-loc-gallery-item img {
  display: block;
  width: 100%;
  max-height: 160px;
  object-fit: contain;
  margin-bottom: 8px;
  vertical-align: middle;
}

.shared-loc-gallery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.cell-remark {
  max-width: 180px;
  font-size: 13px;
  color: #444;
  vertical-align: middle;
  word-break: break-word;
}

.remark-preview {
  cursor: default;
}

.shared-loc-loc-block {
  margin-bottom: 10px;
}

.shared-loc-loc-block:last-child {
  margin-bottom: 0;
}

.cell-coord--set {
  vertical-align: middle;
  min-width: 112px;
}

.shared-loc-set-hint {
  font-size: 12px;
  color: #666;
  margin-top: 6px;
  letter-spacing: 0.02em;
}

.shared-loc-loc-switch {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.shared-loc-switch-btn.is-active {
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.35);
}

.cell-coord--multi .coord-preview {
  margin-top: 2px;
}

.shared-loc-cover-wrap {
  text-align: center;
  background: #f5f5f5;
  border-radius: 8px;
  overflow: hidden;
  min-height: 120px;
}

.shared-loc-cover-wrap img {
  display: block;
  max-width: 100%;
  max-height: min(70vh, 640px);
  width: auto;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  vertical-align: middle;
}

.cell-cover {
  vertical-align: middle;
  min-width: 88px;
}

.modal-content.modal-content--map {
  max-width: min(720px, 96vw);
}

.modal-body.modal-body--map {
  max-height: min(78vh, 820px);
}

.shared-loc-coords {
  font-size: 13px;
  color: #444;
  margin: 0 0 8px;
  line-height: 1.5;
}

.shared-loc-addr {
  font-size: 13px;
  color: #666;
  margin: 0 0 12px;
  line-height: 1.45;
}

.shared-loc-map {
  width: 100%;
  height: min(420px, 52vh);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e5e5e5;
}

.cell-coord {
  vertical-align: middle;
  min-width: 120px;
}

.coord-preview {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
  line-height: 1.3;
  word-break: break-all;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 18px;
  color: #333;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #888;
}

.modal-body {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  color: #555;
  font-size: 14px;
  margin-bottom: 8px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

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

.modal-footer {
  padding: 15px 20px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.settings-section {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.settings-section h2 {
  font-size: 18px;
  color: #333;
  margin-bottom: 20px;
}

.settings-form .form-group {
  margin-bottom: 20px;
}

.settings-form label {
  display: block;
  color: #555;
  font-size: 14px;
  margin-bottom: 8px;
}

.settings-form input {
  width: 100%;
  max-width: 300px;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

/* =============================
   Theme switching (6 schemes)
   ============================= */
:root {
  --accent: #667eea;
  --accent2: #764ba2;
  --accentRgb: 102, 126, 234; /* R,G,B */
  --sidebarTop: #1a1f36;
  --sidebarBottom: #2d3555;
  --tableHeaderBg: #f8f9fa;
}

body.theme-1 {
  --accent: #2f7f6d;
  --accent2: #2fb6a0;
  --accentRgb: 47, 127, 109;
  --sidebarTop: #0f2b26;
  --sidebarBottom: #163b33;
  --tableHeaderBg: #f1fbf8;
}

body.theme-2 {
  --accent: #ff7a62;
  --accent2: #ff3d71;
  --accentRgb: 255, 122, 98;
  --sidebarTop: #0b1220;
  --sidebarBottom: #13203a;
  --tableHeaderBg: #fff6f2;
}

body.theme-3 {
  --accent: #9b5cff;
  --accent2: #39ff88;
  --accentRgb: 155, 92, 255;
  --sidebarTop: #24124a;
  --sidebarBottom: #1d2a44;
  --tableHeaderBg: #f7f1ff;
}

body.theme-4 {
  --accent: #00e5ff;
  --accent2: #ff2d95;
  --accentRgb: 0, 229, 255;
  --sidebarTop: #081427;
  --sidebarBottom: #071021;
  --tableHeaderBg: #ecfbff;
}

body.theme-5 {
  --accent: #39ff88;
  --accent2: #00e5ff;
  --accentRgb: 57, 255, 136;
  --sidebarTop: #06141f;
  --sidebarBottom: #071a2a;
  --tableHeaderBg: #ebfffa;
}

body.theme-6 {
  --accent: #ff3d71;
  --accent2: #00c2ff;
  --accentRgb: 255, 61, 113;
  --sidebarTop: #1a1740;
  --sidebarBottom: #0f1c3a;
  --tableHeaderBg: #fff0f6;
}

body[class^="theme-"] .sidebar {
  background: linear-gradient(180deg, var(--sidebarTop) 0%, var(--sidebarBottom) 100%);
}

body[class^="theme-"] .nav-item.active {
  border-left-color: var(--accent);
  background: rgba(var(--accentRgb), 0.18);
}

body[class^="theme-"] .btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
}

body[class^="theme-"] .btn-primary:hover {
  box-shadow: 0 5px 15px rgba(var(--accentRgb), 0.35);
}

body[class^="theme-"] .pagination button:hover,
body[class^="theme-"] .pagination button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

body[class^="theme-"] .data-table th {
  background: rgba(var(--accentRgb), 0.08);
}

body[class^="theme-"] .btn-small.view {
  background: rgba(var(--accentRgb), 0.14);
  color: rgb(var(--accentRgb));
}

/* Sidebar theme switch button */
.theme-switch-btn {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
}

body[class^="theme-"] .theme-switch-btn {
  background: rgba(var(--accentRgb), 0.12);
  border-color: rgba(var(--accentRgb), 0.35);
}

body[class^="theme-"] .theme-switch-btn:hover {
  background: rgba(var(--accentRgb), 0.22);
}

@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }
  
  .sidebar-header h2,
  .nav-item span:last-child,
  .logout-btn span:last-child,
  .theme-switch-btn span:last-child {
    display: none;
  }
  
  .main-content {
    margin-left: 60px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
