:root {
  /* CloudFuze brand tokens (see cf_ui_components/css/tokens.css) */
  --bg: #F6F6F6;           /* --cf-color-bg-alt */
  --card: #FFFFFF;         /* --cf-color-bg */
  --border: #E2E8F0;       /* --cf-color-border */
  --text: #1A1F36;         /* --cf-color-navy */
  --muted: #7A8BA6;        /* --cf-color-secondary-gray */
  --primary: #0129AC;      /* --cf-color-primary */
  --primary-dark: #0C18D4; /* --cf-color-primary-deep */
  --sidebar-bg: #FFFFFF;      /* CF canonical sidenav bg */
  --sidebar-bg-hover: #F7F8FC;/* --cf-color-bg-near-white */
  --sidebar-bg-active: #E1ECFF; /* --cf-color-bg-ice */
  --sidebar-text: #1A1F36;    /* --cf-color-navy */
  --pending: #8a5a00;      /* matches cf-badge--warning text color, solid-safe for white text */
  --approved: #0a8f5c;     /* matches cf-badge--success text color, solid-safe for white text */
  --rejected: #DC2626;     /* --cf-color-danger */
  --progress: #4169E1;     /* --cf-color-royal-blue / --cf-color-info */
  --delivered: #6d28d9;    /* no CF token for this hue; kept as-is */
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }

/* Login */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
}
.login-card {
  background: var(--card);
  border-radius: 12px;
  padding: 32px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-card h1 { font-size: 18px; margin: 0 0 12px; }
.login-card label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.login-card input, .login-card select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.login-card button {
  margin-top: 16px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: var(--primary);
  color: white;
  font-size: 14px;
  cursor: pointer;
}
.login-card button:hover { background: var(--primary-dark); }
.auth-switch { font-size: 13px; color: var(--muted); text-align: center; margin: 14px 0 0; }
.auth-switch a { color: var(--primary); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

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

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: flex-start;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 20px;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
}
.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-item:hover { background: var(--sidebar-bg-hover); }
.nav-item.active { background: var(--sidebar-bg-active); color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 10px; }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.breadcrumb { font-size: 13px; color: var(--muted); white-space: nowrap; }
.breadcrumb b { color: var(--text); }
.topbar-search { flex: 1; max-width: 420px; }
.topbar-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
}
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-chip {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.topbar-right button#switch-user-btn {
  border: 1px solid var(--border);
  background: white;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  padding: 20px 24px 0;
}
.summary-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  text-align: center;
}
.summary-tile .value { font-size: 22px; font-weight: 700; }
.summary-tile .label { font-size: 12px; color: var(--muted); margin-top: 2px; }
@media (max-width: 900px) {
  .summary { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 500px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
}

.board-panel {
  margin: 20px 24px 40px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.board-scroll {
  overflow-x: auto;
}
.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.board-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.count-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 2px 9px;
}

.filter-dropdowns { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-select {
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  min-width: 130px;
}
.filter-select:focus { outline: none; border-color: var(--primary); }

button.primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
button.primary:hover { background: var(--primary-dark); }

.board-scroll { overflow-x: auto; }

.table-head {
  display: grid;
  grid-template-columns: 70px 1fr 140px 110px 190px;
  gap: 12px;
  padding: 10px 18px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  min-width: 640px;
}

.list { display: flex; flex-direction: column; min-width: 640px; }
.req-card {
  display: grid;
  grid-template-columns: 70px 1fr 140px 110px 190px;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.req-card:last-child { border-bottom: none; }
.req-card:hover { background: #f8f9fc; }
.req-id { font-size: 12px; font-weight: 700; color: var(--muted); }
.req-main { min-width: 0; }
.req-title { font-weight: 600; font-size: 14px; }
.req-desc-preview { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-owner { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.req-date { font-size: 12px; color: var(--muted); }

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  white-space: nowrap;
  color: white;
  text-align: center;
  justify-self: start;
}
.status-Pending-Presales-Review { background: var(--pending); }
.status-Approved { background: var(--approved); }
.status-Rejected { background: var(--rejected); }
.status-In-Progress { background: var(--progress); }
.status-Delivered { background: var(--delivered); }

.req-actions { display: flex; }
.row-actions { display: flex; gap: 6px; }
.row-action {
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: white;
}
.row-action.approve { background: var(--approved); }
.row-action.approve:hover { background: #036049; }
.row-action.reject { background: var(--rejected); }
.row-action.reject:hover { background: #991b1b; }
.row-action:disabled { opacity: 0.6; cursor: default; }

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

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.modal {
  background: var(--card);
  border-radius: 12px;
  padding: 28px 32px;
  width: 640px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
}
.modal h2 { margin-top: 0; font-size: 17px; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin-top: 12px; margin-bottom: 4px; }
.modal input, .modal textarea, .modal select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.modal textarea { resize: vertical; min-height: 70px; }
.modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal-actions button {
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: white;
}
.modal-actions button.primary { background: var(--primary); color: white; border: none; }
.modal-actions button.danger { background: var(--rejected); color: white; border: none; }
.modal-actions button.success { background: var(--approved); color: white; border: none; }

.history-item {
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-item .h-meta { color: var(--muted); font-size: 12px; }

.error-msg { color: var(--rejected); font-size: 13px; margin-top: 8px; }

.file-input-wrap {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.file-input-wrap input[type="file"] { width: 100%; font-size: 13px; }
.file-hint { font-size: 11px; color: var(--muted); margin-top: 6px; }
.file-list { list-style: none; margin: 8px 0 0; padding: 0; }
.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px;
  margin-bottom: 6px;
}
.file-list .file-name { display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list a { color: var(--primary); text-decoration: none; font-weight: 600; font-size: 12px; }
.file-list a:hover { text-decoration: underline; }
.file-size { color: var(--muted); font-size: 11px; flex-shrink: 0; margin-left: 8px; }

.line-row { display: flex; gap: 6px; margin-bottom: 6px; }
.line-row .f-line { flex: 1; }
.remove-line-btn {
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  width: 34px;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 16px;
  color: var(--muted);
}
.remove-line-btn:hover { color: var(--rejected); border-color: var(--rejected); }
.add-line-btn {
  border: 1px dashed var(--border);
  background: white;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  margin-top: 2px;
}
.add-line-btn:hover { background: #f4f6ff; }
.req-lines { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--text); }
.req-lines li { margin-bottom: 3px; }
.req-customer-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: #eef1ff;
  border-radius: 4px;
  padding: 1px 7px;
  margin-bottom: 4px;
}
.priority-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
  border-radius: 4px;
  padding: 0px 7px;
  margin-bottom: 4px;
}

.reports-content { padding: 18px; }
.report-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.report-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.report-table h3 { font-size: 14px; margin: 0 0 10px; }
.report-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
}
.report-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
@media (max-width: 800px) {
  .report-tiles { grid-template-columns: 1fr; }
  .report-tables { grid-template-columns: 1fr; }
}
