:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f9faf9;
  --border: #e2e6e4;
  --border-strong: #cfd6d2;
  --text: #182620;
  --text-secondary: #5b6863;
  --text-muted: #8b9793;
  --primary: #0f6e56;
  --primary-dark: #0a4d3d;
  --primary-light: #e1f5ee;
  --accent: #185fa5;
  --accent-light: #e6f1fb;
  --green: #1d9e75;
  --green-bg: #e1f5ee;
  --amber: #ba7517;
  --amber-bg: #faeeda;
  --red: #a32d2d;
  --red-bg: #fcebeb;
  --gray-bg: #f1efe8;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(20, 30, 25, 0.06), 0 1px 2px rgba(20, 30, 25, 0.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-logo {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  color: var(--primary-dark);
}
.login-logo i { font-size: 22px; color: var(--primary); }
.login-box h1 { font-size: 20px; font-weight: 600; margin: 0 0 6px; }
.login-sub { font-size: 13px; color: var(--text-secondary); margin: 0 0 22px; }

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

.sidebar {
  width: 230px;
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-logo {
  padding: 20px 18px;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-logo i { font-size: 20px; color: #7fd9bc; }
.nav-group { padding: 14px 10px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13.5px;
  margin-bottom: 2px;
  cursor: pointer;
  transition: background 0.15s;
}
.nav-item i { font-size: 17px; width: 18px; text-align: center; }
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 500; }
.sidebar-foot {
  padding: 14px 18px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  line-height: 1.5;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.search-wrap { position: relative; flex: 1; max-width: 420px; }
.search-input {
  width: 100%;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0 12px 0 34px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.search-input:focus { border-color: var(--primary); }
.search-wrap i {
  position: absolute;
  left: 10px;
  top: 9px;
  color: var(--text-muted);
  font-size: 16px;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }
.badge-dot {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--surface);
}
.dropdown {
  position: absolute;
  right: 0;
  top: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  width: 300px;
  display: none;
  z-index: 40;
  overflow: hidden;
}
.dropdown.open { display: block; }
.dropdown-head {
  padding: 12px 14px;
  font-weight: 500;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.dropdown-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-secondary);
}
.dropdown-item b { color: var(--text); font-weight: 500; }
.dropdown-item:last-child { border-bottom: none; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: 20px;
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.user-menu {
  position: absolute;
  right: 0;
  top: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  width: 190px;
  display: none;
  z-index: 40;
  overflow: hidden;
}
.user-menu.open { display: block; }
.user-menu a {
  display: block;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.user-menu a:last-child { border-bottom: none; color: var(--red); }
.user-menu a:hover { background: var(--surface-2); }

.content { padding: 24px; flex: 1; overflow-y: auto; }
.section { display: none; }
.section.active { display: block; }

h1.page-title { font-size: 19px; font-weight: 600; margin: 0 0 4px; }
p.page-sub { font-size: 13px; color: var(--text-secondary); margin: 0 0 20px; }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.metric-card p.label { font-size: 12.5px; color: var(--text-secondary); margin: 0 0 8px; }
.metric-card p.value { font-size: 23px; font-weight: 600; margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-head h3 { font-size: 14.5px; font-weight: 600; margin: 0; }

.two-col {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
}
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .sidebar { width: 72px; }
  .sidebar-logo span, .nav-item span, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .sidebar-logo { justify-content: center; padding: 18px 10px; }
}

.alert-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--amber-bg);
  color: #633806;
  border: 1px solid #f0d9a8;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-strip.danger {
  background: var(--red-bg);
  color: #501313;
  border-color: #eec2c2;
}
.alert-strip i { font-size: 16px; }

.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.qa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.qa-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
}
.qa-card:hover { border-color: var(--primary); background: var(--primary-light); }
.qa-card i { font-size: 20px; color: var(--primary); }
.qa-card p.t { font-size: 13px; font-weight: 500; margin: 8px 0 2px; }
.qa-card p.s { font-size: 11.5px; color: var(--text-secondary); margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable:hover { background: var(--surface-2); cursor: pointer; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
}
.badge.green, .status-delivered, .status-completed { background: var(--green-bg); color: #085041; }
.badge.amber, .status-processing, .status-pending { background: var(--amber-bg); color: #854f0b; }
.badge.red, .status-cancelled, .status-delayed { background: var(--red-bg); color: #791f1f; }
.badge.blue, .status-dispatched { background: var(--accent-light); color: #0c447c; }
.badge.gray { background: var(--gray-bg); color: #444441; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.detail-row span:first-child { color: var(--text-secondary); }
.detail-row:last-child { border-bottom: none; }

.channels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.channel-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  text-align: center;
  background: var(--surface);
}
.channel-card i {
  font-size: 22px;
  color: var(--primary);
  margin-bottom: 8px;
  display: block;
}
.channel-card p { margin: 0; font-size: 13px; font-weight: 500; }

label.field-label {
  font-size: 12.5px;
  font-weight: 500;
  margin: 0 0 5px;
  display: block;
  color: var(--text-secondary);
}
.field { margin-bottom: 14px; }
.field input, .field select, .field textarea,
.form-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text);
}
.field input:focus, .form-input:focus {
  outline: none;
  border-color: var(--primary);
}

.video-container {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #0a4d3d;
  aspect-ratio: 16 / 9;
  max-width: 800px;
}
.video-frame { width: 100%; height: 100%; border: none; display: block; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li {
  font-size: 13px;
  padding: 8px 0 8px 18px;
  position: relative;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.checklist li:last-child { border-bottom: none; }
.checklist.do li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
}
.checklist.dont li::before {
  content: '×';
  position: absolute;
  left: 0;
  color: var(--red);
  font-weight: 700;
  font-size: 14px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 20, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.open, .modal-overlay[style*="block"] {
  display: flex !important;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 480px;
  max-width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 24px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h3 { font-size: 15.5px; font-weight: 600; margin: 0; }
.modal-head .close { font-size: 20px; color: var(--text-muted); cursor: pointer; }

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--primary-dark);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 200;
  display: none;
  align-items: center;
  gap: 8px;
}
.toast.show { display: flex; }

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Order cards from app.js */
.order-cards-container { display: grid; gap: 14px; margin-top: 16px; }
.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.progress-card:hover { border-color: var(--primary); }
.view-details-btn, .view-documents-btn, .download-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
}
.view-details-btn { background: var(--primary); border-color: var(--primary); color: #fff; }
.view-documents-btn:hover, .download-btn:hover { background: var(--surface-2); }
.view-details-btn:hover { background: var(--primary-dark); }

.order-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 18px;
  color: var(--text);
}
.order-summary::before { display: none; }
.summary-title { color: var(--text) !important; font-size: 15px !important; }
.summary-subtitle { color: var(--text-secondary) !important; }
.summary-stat {
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
}
.stat-value { color: var(--text) !important; -webkit-text-fill-color: unset !important; background: none !important; }
.stat-value.active { color: var(--primary) !important; -webkit-text-fill-color: var(--primary) !important; }
.stat-label { color: var(--text-secondary) !important; }
.status-breakdown {
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
}
.status-title { color: var(--text) !important; }
.status-item {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
}
.status-text { color: var(--text) !important; }
.filter-btn {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: 8px !important;
}
.filter-btn.active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

.order-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.detail-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: var(--surface-2);
  display: flex;
  gap: 10px;
}
.pi-copy, .do-document, .lr-scanned-copy, .dc-document, .eway-bill {
  background: var(--primary-light);
  border-color: #b8e0d8;
}
.no-docs {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
}

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  background: var(--surface-2);
}

@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav-group {
    display: flex;
    overflow-x: auto;
    padding: 8px;
    flex: 1;
  }
  .nav-item { white-space: nowrap; margin-bottom: 0; }
  .sidebar-foot { display: none; }
  .order-details { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .content { padding: 16px; }
}
