/**
 * grokbot Industrial Web Console Style
 * Clean, calm, utilitarian institutional interface.
 * Strictly serverless browser client for Crawlab procurement automation.
 */

:root {
  --gov-blue: #233876;
  --gov-dark-blue: #16244f;
  --gov-accent: #3b5cb8;
  --gov-btn-blue: #415ec7;
  --gov-btn-hover: #324aa8;
  --gov-gold: #ffcc00;
  
  --bg: #eef1f6;
  --panel-bg: #ffffff;
  --panel-header: #f2f5fa;
  --border: #b8c4d8;
  --border-dark: #8c9cb6;
  
  --text: #1a202c;
  --text-muted: #4a5568;
  --text-subtle: #718096;
  
  --status-ok-bg: #dcfce7;
  --status-ok-text: #15803d;
  --status-ok-border: #86efac;
  
  --status-err-bg: #fee2e2;
  --status-err-text: #b91c1c;
  --status-err-border: #fca5a5;
  
  --status-warn-bg: #fef3c7;
  --status-warn-text: #b45309;
  --status-warn-border: #fde68a;
  
  --status-idle-bg: #f1f5f9;
  --status-idle-text: #475569;
  --status-idle-border: #cbd5e1;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
}

/* Institutional Top Header */
.gov-banner {
  background: var(--gov-blue);
  color: #fff;
  padding: 0.55rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid var(--gov-gold);
  flex-shrink: 0;
}

.gov-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.gov-seal {
  font-size: 1.4rem;
  line-height: 1;
}

.gov-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.gov-subtitle {
  font-size: 0.75rem;
  color: #cbd5e1;
}

.gov-meta-strip {
  font-size: 0.75rem;
  font-family: var(--mono);
  color: #e2e8f0;
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.gov-meta-strip span strong {
  color: #ffeb3b;
}

.pulse-indicator {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  margin-right: 4px;
}

.pulse-indicator.error {
  background: #ef4444;
}

/* Navigation & Action Ribbon */
.action-ribbon {
  background: #dbe3ef;
  border-bottom: 1px solid var(--border);
  padding: 0.35rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.ribbon-btns {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.ribbon-utils {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ribbon-status-pill {
  font-family: var(--mono);
  font-size: 0.725rem;
  color: #1e293b;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  padding: 0.25rem 0.55rem;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  user-select: none;
}

.gov-btn {
  background: #f8fafc;
  border: 1px solid var(--border-dark);
  color: #1e293b;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  user-select: none;
  text-decoration: none;
  transition: background 0.1s;
}

.gov-btn:hover {
  background: #e2e8f0;
}

.gov-btn-primary {
  background: var(--gov-btn-blue);
  color: #fff;
  border-color: var(--gov-dark-blue);
}

.gov-btn-primary:hover {
  background: var(--gov-btn-hover);
}

.gov-btn-portal {
  background: #f0fdf4 !important;
  border-color: #86efac !important;
  color: #166534 !important;
}

.gov-btn-portal:hover {
  background: #dcfce7 !important;
  border-color: #4ade80 !important;
}

.gov-btn-sm {
  padding: 0.2rem 0.45rem;
  font-size: 0.7rem;
  white-space: nowrap;
}

.gov-select {
  background: #fff;
  border: 1px solid var(--border-dark);
  color: #1e293b;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 2px;
  cursor: pointer;
}

/* Layout: Left Sidebar + Central Workstation */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 82px);
}

/* Left Sidebar */
.sidebar {
  width: 220px;
  background: #e2e8f0;
  border-right: 1px solid var(--border);
  padding: 0.65rem 0.5rem;
  flex-shrink: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-section-title {
  font-size: 0.725rem;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.4rem 0.5rem;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-menu {
  list-style: none;
  margin-bottom: 0.4rem;
}

.sidebar-node-row {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  color: #1e293b;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.15rem;
  font-weight: 500;
  font-family: var(--mono);
}

.node-bullet {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}

.sidebar-actions-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.6rem;
}

.sidebar-action-btn {
  background: #ffffff;
  border: 1px solid var(--border);
  color: #1e293b;
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: left;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.1s, border-color 0.1s;
}

.sidebar-action-btn:hover {
  background: #f1f5fa;
  border-color: var(--gov-accent);
}

.sidebar-policy-card {
  margin-top: auto;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.6rem;
  font-size: 0.7rem;
  color: #475569;
  line-height: 1.4;
}

.sidebar-policy-title {
  font-weight: 700;
  color: var(--gov-dark-blue);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  font-size: 0.675rem;
  letter-spacing: 0.03em;
}

/* Main Content Workspace */
.content-area {
  flex: 1;
  padding: 0.65rem 0.85rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tab-content {
  display: none;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
}

/* Master-Detail Split (Grokbot 3-pane style) */
.split-container {
  display: flex;
  flex: 1;
  height: 100%;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 2px;
}

.split-left {
  width: 440px;
  min-width: 360px;
  max-width: 520px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f8fafc;
  border-right: 1px solid var(--border);
}

.split-gutter {
  width: 6px;
  background: #cbd5e1;
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  transition: background 0.1s;
  user-select: none;
}

.split-gutter:hover, .split-gutter.dragging {
  background: var(--gov-accent);
}

.split-gutter::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 1px;
  transform: translateY(-50%);
  width: 4px;
  height: 32px;
  border-left: 1px dotted #64748b;
  border-right: 1px dotted #64748b;
}

.split-right {
  flex: 1;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

/* Toolbars & Filter Chips */
.pane-toolbar {
  padding: 0.45rem 0.65rem;
  background: #f1f4f9;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
}

.filter-chips {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
}

.chip-btn {
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 0.2rem 0.5rem;
  font-size: 0.725rem;
  font-weight: 600;
  border-radius: 2px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}

.chip-btn:hover {
  background: #cbd5e1;
}

.chip-btn.active {
  background: var(--gov-blue);
  color: #fff;
  border-color: var(--gov-dark-blue);
}

.search-input {
  background: #fff;
  border: 1px solid var(--border-dark);
  padding: 0.35rem 0.55rem;
  font-size: 0.775rem;
  font-family: inherit;
  border-radius: 2px;
  width: 100%;
  outline: none;
}

.search-input:focus {
  border-color: var(--gov-accent);
}

/* Master List: Clean Email Rows */
.master-list-body {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  background: #ffffff;
}

.alert-row {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #e2e8f0;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  user-select: none;
  background: #ffffff;
}

.alert-row:hover {
  background: #f1f5fa;
}

.alert-row.selected {
  background: #e0e7ff;
  border-left: 4px solid var(--gov-blue);
  padding-left: calc(0.8rem - 4px);
}

.alert-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.alert-title {
  font-weight: 700;
  font-size: 0.825rem;
  color: var(--gov-dark-blue);
  line-height: 1.3;
}

.alert-snippet {
  font-size: 0.725rem;
  color: #475569;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.alert-row-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.675rem;
  color: var(--text-subtle);
  margin-top: 0.15rem;
}

.acct-pill {
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  padding: 0.05rem 0.35rem;
  font-family: var(--mono);
  font-size: 0.675rem;
  font-weight: 700;
  border-radius: 2px;
}

.deadline-pill {
  color: #b91c1c;
  font-weight: 700;
}

/* Detail View (Grokbot Log / Document Inspector) */
.detail-header {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-shrink: 0;
  gap: 0.75rem;
}

.detail-header-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gov-dark-blue);
}

.detail-header-subtitle {
  font-size: 0.725rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.detail-header-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.detail-body {
  padding: 0.85rem;
  overflow-y: auto;
  flex: 1;
  background: #ffffff;
}

/* Cohesive Dossier Document */
.dossier-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 950px;
}

/* 2-Column Metadata Fact Sheet */
.dossier-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 0.65rem 0.85rem;
  border-radius: 2px;
}

.dossier-cell {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.dossier-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.dossier-val {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--gov-dark-blue);
}

.dossier-val-mono {
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--gov-blue);
}

.dossier-val-deadline {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 800;
  color: #b91c1c;
}

.dossier-hint {
  font-size: 0.675rem;
  color: var(--text-subtle);
  font-family: var(--mono);
}

/* Official Excerpt Monospace Paper Box */
.dossier-section {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.dossier-section-title {
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #334155;
  letter-spacing: 0.03em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.2rem;
}

.dossier-log-view {
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 0.75rem;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.775rem;
  line-height: 1.5;
  color: #0f172a;
  white-space: pre-wrap;
}

.dossier-action-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 4px solid #16a34a;
  padding: 0.6rem 0.8rem;
  font-size: 0.775rem;
  color: #14532d;
  line-height: 1.45;
}

.dossier-details {
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 2px;
}

.dossier-details summary {
  padding: 0.4rem 0.65rem;
  font-weight: 600;
  font-size: 0.725rem;
  color: var(--gov-dark-blue);
  cursor: pointer;
  background: #f1f4f9;
  user-select: none;
}

.dossier-actions-bar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #64748b;
  padding: 2rem;
  text-align: center;
  font-size: 0.8rem;
}

/* Utilitarian Data Panel (Tabs 2, 3, 4) */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
}

.panel-fill {
  flex: 1;
  margin-bottom: 0;
  overflow: hidden;
}

.panel-header {
  background: var(--panel-header);
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.8rem;
  font-weight: 700;
  font-size: 0.775rem;
  color: var(--gov-dark-blue);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.panel-body {
  padding: 0.75rem;
  overflow-y: auto;
  flex: 1;
}

/* Industrial Data Tables */
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;
  background: #fff;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.775rem;
  background: #fff;
}

.data-table th {
  background: #f1f4f9;
  border: 1px solid var(--border);
  padding: 0.35rem 0.45rem;
  text-align: left;
  font-weight: 700;
  color: #334155;
  font-size: 0.7rem;
  text-transform: uppercase;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.45rem;
  color: #0f172a;
  vertical-align: middle;
}

.data-table tr:nth-child(even) td {
  background: #f8fafc;
}

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

/* Status Badges */
.badge-ok {
  background: var(--status-ok-bg);
  color: var(--status-ok-text);
  border: 1px solid var(--status-ok-border);
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.675rem;
  white-space: nowrap;
  display: inline-block;
}

.badge-error {
  background: var(--status-err-bg);
  color: var(--status-err-text);
  border: 1px solid var(--status-err-border);
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.675rem;
  white-space: nowrap;
  display: inline-block;
}

.badge-running {
  background: var(--status-warn-bg);
  color: var(--status-warn-text);
  border: 1px solid var(--status-warn-border);
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.675rem;
  white-space: nowrap;
  display: inline-block;
}

.badge-idle {
  background: var(--status-idle-bg);
  color: var(--status-idle-text);
  border: 1px solid var(--status-idle-border);
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.675rem;
  white-space: nowrap;
  display: inline-block;
}

.badge-subtle {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.675rem;
  white-space: nowrap;
  display: inline-block;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: #fff;
  border: 1px solid var(--border-dark);
  border-radius: 2px;
  width: 780px;
  max-width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.modal-header {
  background: var(--gov-blue);
  color: #fff;
  padding: 0.5rem 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--gov-gold);
}

.modal-header h2 {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 0.85rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.modal-footer {
  padding: 0.45rem 0.85rem;
  background: #f1f4f9;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group label {
  font-size: 0.725rem;
  font-weight: 700;
  color: var(--gov-dark-blue);
}

.form-input {
  background: #fff;
  border: 1px solid var(--border-dark);
  padding: 0.35rem 0.55rem;
  font-size: 0.775rem;
  font-family: var(--mono);
  border-radius: 2px;
  outline: none;
}

.form-input:focus {
  border-color: var(--gov-accent);
}

.json-viewer {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.65rem;
  font-family: var(--mono);
  font-size: 0.725rem;
  color: #0f172a;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
}

.terminal-viewer {
  background: #090d16;
  color: #e2e8f0;
  font-family: var(--mono);
  font-size: 0.725rem;
  padding: 0.75rem;
  border-radius: 2px;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.45;
  border: 1px solid var(--border-dark);
}

/* Institutional Footer / Status Strip */
.gov-footer {
  background: #dbe3ef;
  border-top: 1px solid var(--border);
  padding: 0.35rem 1.25rem;
  font-family: var(--mono);
  font-size: 0.725rem;
  color: #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

/* Toast */
#govToast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #0f172a;
  color: #fff;
  padding: 0.45rem 0.85rem;
  border-radius: 2px;
  font-size: 0.775rem;
  font-weight: 600;
  display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 500;
  border-left: 4px solid #16a34a;
}
