/* ═══════════════════════════════════════════════════════════════
   Everner — Main stylesheet
   All styles in one file. Variables at top for easy theming.
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --brand:        #1D9E75;
  --brand-dark:   #085041;
  --brand-light:  #E1F5EE;

  /* Neutrals */
  --bg:           #f5f4f1;
  --surface:      #ffffff;
  --border:       #e2e1d9;
  --border2:      #cccbc3;
  --text:         #1a1a18;
  --text2:        #5f5e5a;
  --text3:        #888780;

  /* Sidebar */
  --sidebar-bg:   #0f2419;
  --sidebar-text: #b8d4c4;
  --sidebar-hover:#1a3d28;
  --sidebar-active:#1D9E75;

  /* Semantic */
  --critical:  #DC2626; --critical-bg: #FEF2F2;
  --high:      #D97706; --high-bg:     #FFFBEB;
  --medium:    #2563EB; --medium-bg:   #EFF6FF;
  --low:       #6B7280; --low-bg:      #F9FAFB;
  --success:   #16A34A; --success-bg:  #F0FDF4;
  --error:     #DC2626; --error-bg:    #FEF2F2;
  --warning:   #D97706; --warning-bg:  #FFFBEB;
  --info:      #2563EB; --info-bg:     #EFF6FF;

  --radius:    6px;
  --radius-lg: 10px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.brand-mark {
  width: 30px; height: 30px;
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.brand-name { color: #fff; font-weight: 600; font-size: 15px; }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--sidebar-text);
  border-radius: 0;
  transition: background .15s, color .15s;
  position: relative;
  font-size: 13.5px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(29,158,117,.2); color: var(--brand); font-weight: 500; }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--brand);
  border-radius: 0 2px 2px 0;
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--critical);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
}
.nav-section-label {
  padding: 16px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--brand);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
  flex-shrink: 0;
}
.user-details { flex: 1; overflow: hidden; }
.user-name { color: #fff; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-org  { color: var(--sidebar-text); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
  background: none; border: none; cursor: pointer;
  color: var(--sidebar-text); padding: 4px;
  border-radius: 4px; display: flex;
}
.logout-btn:hover { color: #fff; background: var(--sidebar-hover); }

/* ── Main content ─────────────────────────────────────────────────────────── */
.main-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px 0;
  flex-wrap: wrap;
}
.page-title   { font-size: 20px; font-weight: 600; }
.page-subtitle{ font-size: 13px; color: var(--text2); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-body    { padding: 20px 28px 40px; }

/* ── Auth layout ──────────────────────────────────────────────────────────── */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth-title { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.auth-form  { display: flex; flex-direction: column; gap: 16px; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin: 16px 28px 0;
}
.alert ul { padding-left: 16px; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #86efac; }
.alert-error   { background: var(--error-bg);   color: var(--error);   border: 1px solid #fca5a5; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #fcd34d; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  transition: all .15s;
  text-decoration: none !important;
  white-space: nowrap;
}
.btn-primary  { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover  { background: var(--brand-dark); }
.btn-secondary{ background: var(--surface); color: var(--text); border-color: var(--border2); }
.btn-secondary:hover{ background: var(--bg); }
.btn-danger   { background: var(--critical-bg); color: var(--critical); border-color: #fca5a5; }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost    { background: none; color: var(--text2); border-color: transparent; }
.btn-ghost:hover{ background: var(--bg); }
.btn-sm       { padding: 4px 10px; font-size: 12px; }
.btn-full     { width: 100%; }

/* ── Form elements ────────────────────────────────────────────────────────── */
.form-group   { display: flex; flex-direction: column; gap: 4px; }
.form-label   { font-size: 13px; font-weight: 500; color: var(--text2); }
.form-input, .form-select, .form-textarea {
  padding: 8px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29,158,117,.12);
}
.form-textarea { min-height: 100px; resize: vertical; }
.input-error   { border-color: var(--critical) !important; }
.form-checkbox { flex-direction: row; align-items: center; gap: 8px; }
.form-help     { font-size: 12px; color: var(--text3); }

/* ── Stat cards ───────────────────────────────────────────────────────────── */
.stat-row { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card {
  flex: 1; min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  text-decoration: none !important;
  transition: box-shadow .15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--text2); }
.stat-amber .stat-value { color: var(--high); }
.stat-blue  .stat-value { color: var(--medium); }
.stat-teal  .stat-value { color: var(--brand); }

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.filter-search { flex: 1; min-width: 200px; max-width: 280px; }
.filter-bar .form-select { width: auto; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead tr { background: var(--bg); }
.data-table th {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text3);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafaf8; }
.clickable { cursor: pointer; }
.td-primary { font-weight: 500; }
.td-meta    { display: block; font-size: 12px; color: var(--text3); margin-top: 2px; }
.td-group   { font-size: 13px; color: var(--text2); }
.td-empty   { color: var(--text3); }
.td-date    { font-size: 12px; color: var(--text3); white-space: nowrap; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

/* Priority */
.badge-critical { background: var(--critical-bg); color: var(--critical); }
.badge-high     { background: var(--high-bg);     color: var(--high); }
.badge-medium   { background: var(--medium-bg);   color: var(--medium); }
.badge-low      { background: var(--low-bg);      color: var(--low); }

/* Workflow status */
.badge-new             { background: #f3f4f6; color: #374151; }
.badge-assigned        { background: #dbeafe; color: #1d4ed8; }
.badge-in_progress     { background: #d1fae5; color: #065f46; }
.badge-actioned        { background: #ede9fe; color: #5b21b6; }
.badge-awaiting_outcome{ background: #fef3c7; color: #92400e; }
.badge-closed          { background: #f3f4f6; color: #6b7280; }
.badge-reopened        { background: #fee2e2; color: #991b1b; }

/* Decision status */
.badge-pending_review  { background: #fef3c7; color: #92400e; }
.badge-approved        { background: #d1fae5; color: #065f46; }
.badge-rejected        { background: #fee2e2; color: #991b1b; }
.badge-deferred        { background: #f3f4f6; color: #6b7280; }

/* ── Situation detail ─────────────────────────────────────────────────────── */
.situation-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .situation-layout { grid-template-columns: 1fr; }
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}
.detail-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.detail-card-title { font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; }
.detail-card-body  { padding: 16px 18px; }

/* ── Activity log ─────────────────────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: 5px;
  flex-shrink: 0;
}
.activity-content { flex: 1; }
.activity-event   { font-weight: 500; }
.activity-meta    { font-size: 12px; color: var(--text3); margin-top: 2px; }
.activity-comment { font-size: 12px; color: var(--text2); margin-top: 4px; font-style: italic; }

/* ── Action modal / inline forms ──────────────────────────────────────────── */
.action-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 10px;
  display: none;
}
.action-form.open { display: block; }
.action-form-title { font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.action-form-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-form-grid .full { grid-column: 1 / -1; }
.action-form-footer { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }

/* ── Sidebar detail panels ────────────────────────────────────────────────── */
.meta-list { display: flex; flex-direction: column; gap: 10px; }
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text3); }
.meta-value { font-size: 13px; color: var(--text); }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination-wrap { margin-top: 16px; display: flex; justify-content: center; }
.pagination-wrap nav { display: flex; gap: 4px; }
.pagination-wrap span, .pagination-wrap a {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text2);
  background: var(--surface);
}
.pagination-wrap a:hover { background: var(--bg); text-decoration: none; }
.pagination-wrap [aria-current] { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.flex    { display: flex; }
.gap-2   { gap: 8px; }
.gap-3   { gap: 12px; }
.mt-2    { margin-top: 8px; }
.mt-3    { margin-top: 12px; }
.mt-4    { margin-top: 16px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text3); }
.font-medium { font-weight: 500; }
.font-bold   { font-weight: 600; }
.w-full  { width: 100%; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 56px; }
  .brand-name, .nav-item span, .user-details, .nav-section-label { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .page-header { padding: 16px 16px 0; }
  .page-body   { padding: 14px 16px 32px; }
  .alert       { margin: 12px 16px 0; }
  .filter-bar  { flex-direction: column; align-items: stretch; }
  .filter-search { max-width: 100%; }
  .stat-row    { flex-direction: column; }
}

@media print {
  .sidebar, .page-actions, .filter-bar, .btn, .pagination-wrap { display: none !important; }
  .main-content { overflow: visible; }
  .page-body { padding: 0; }
}
