:root {
  --fm-green-900: #123c2a;
  --fm-green-800: #17503a;
  --fm-green-700: #1c6647;
  --fm-green-600: #217a55;
  --fm-green-500: #2b8f65;
  --fm-sand: #e9dfc8;
  --fm-sand-soft: #f7f2e7;
  --fm-ink: #20312a;
  --fm-muted: #6b7d74;
  --fm-bg: #f4f7f4;
  --fm-card: #ffffff;
  --fm-warning: #b7791f;
  --fm-danger: #b23a3a;
  --fm-info: #2c6e91;
  --fm-sidebar-width: 268px;
  --fm-radius: 16px;
}

* {
  scrollbar-width: thin;
}

body {
  font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(43, 143, 101, 0.08), transparent 38%),
    radial-gradient(circle at 90% 10%, rgba(201, 168, 94, 0.1), transparent 30%),
    var(--fm-bg);
  color: var(--fm-ink);
  min-height: 100vh;
}

a {
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

/* ---------- الشريط الجانبي ---------- */
.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--fm-sidebar-width);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent 45%),
    linear-gradient(180deg, var(--fm-green-900), #0d2a1e);
  color: #eef6f0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  overflow-y: auto;
  transition: transform 0.25s ease;
  box-shadow: -12px 0 30px rgba(15, 45, 32, 0.08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 12px;
}

.sidebar-brand .brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(145deg, #d9b45f, #b78f37);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  color: #173a2a;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

.sidebar-brand h1 {
  font-size: 1.08rem;
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.sidebar-brand small {
  display: block;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.72rem;
  margin-top: 2px;
}

.sidebar-section {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, 0.42);
  padding: 16px 12px 6px;
  font-weight: 700;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-nav a {
  color: rgba(255, 255, 255, 0.78);
  padding: 10px 12px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.sidebar-nav a i {
  font-size: 1.08rem;
  width: 22px;
  text-align: center;
  opacity: 0.9;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  transform: translateX(-2px);
}

.sidebar-nav a.active {
  background: linear-gradient(90deg, rgba(217, 180, 95, 0.24), rgba(217, 180, 95, 0.08));
  color: #f4dfae;
  box-shadow: inset 3px 0 0 #d9b45f;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.52);
  line-height: 1.8;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 25, 18, 0.55);
  z-index: 1030;
  backdrop-filter: blur(2px);
}

.sidebar-open .sidebar-overlay {
  display: block;
}

/* ---------- المحتوى ---------- */
.app-main {
  margin-inline-start: var(--fm-sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(23, 80, 58, 0.08);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar .page-heading h2 {
  font-size: 1.16rem;
  font-weight: 800;
  margin: 0;
}

.topbar .page-heading p {
  margin: 2px 0 0;
  color: var(--fm-muted);
  font-size: 0.78rem;
}

.sidebar-toggle {
  display: none;
  border: 1px solid rgba(23, 80, 58, 0.16);
  background: #fff;
  color: var(--fm-green-800);
  border-radius: 10px;
  width: 42px;
  height: 42px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(23, 80, 58, 0.1);
  box-shadow: 0 4px 12px rgba(18, 60, 42, 0.05);
}

.user-chip .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--fm-green-600), var(--fm-green-800));
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
}

.user-chip strong {
  display: block;
  font-size: 0.8rem;
  line-height: 1.2;
}

.user-chip span {
  display: block;
  font-size: 0.68rem;
  color: var(--fm-muted);
}

.page-content {
  padding: 26px;
  flex: 1;
}

.app-footer {
  padding: 14px 26px 22px;
  color: var(--fm-muted);
  font-size: 0.72rem;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- البطاقات ---------- */
.fm-card {
  background: var(--fm-card);
  border: 1px solid rgba(23, 80, 58, 0.08);
  border-radius: var(--fm-radius);
  box-shadow: 0 8px 26px rgba(18, 60, 42, 0.05);
}

.fm-card .card-header {
  background: transparent;
  border-bottom: 1px solid rgba(23, 80, 58, 0.07);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.fm-card .card-header h5,
.fm-card .card-header h6 {
  margin: 0;
  font-weight: 800;
  font-size: 0.98rem;
}

.fm-card .card-body {
  padding: 20px;
}

.kpi-card {
  position: relative;
  overflow: hidden;
  height: 100%;
  padding: 18px;
}

.kpi-card::after {
  content: "";
  position: absolute;
  inset-inline-start: -30px;
  bottom: -40px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(43, 143, 101, 0.06);
}

.kpi-card .kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  margin-bottom: 14px;
}

.kpi-card .kpi-label {
  color: var(--fm-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.kpi-card .kpi-value {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 4px 0 2px;
}

.kpi-card .kpi-note {
  font-size: 0.7rem;
  color: var(--fm-muted);
}

.bg-soft-green { background: rgba(43, 143, 101, 0.12); color: var(--fm-green-700); }
.bg-soft-gold { background: rgba(201, 168, 94, 0.18); color: #8f6c1f; }
.bg-soft-blue { background: rgba(44, 110, 145, 0.12); color: var(--fm-info); }
.bg-soft-red { background: rgba(178, 58, 58, 0.12); color: var(--fm-danger); }

/* ---------- الطقس ---------- */
.weather-hero {
  background:
    linear-gradient(120deg, rgba(18, 60, 42, 0.96), rgba(33, 122, 85, 0.88)),
    url("");
  color: #fff;
  border-radius: var(--fm-radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.weather-hero::before {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  top: -90px;
  inset-inline-start: -40px;
}

.weather-hero .temp {
  font-size: 2.7rem;
  font-weight: 800;
  line-height: 1;
}

.weather-hero .weather-icon {
  font-size: 2.9rem;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

.weather-hero .meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  opacity: 0.9;
}

.forecast-day {
  border: 1px solid rgba(23, 80, 58, 0.09);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  background: #fff;
  height: 100%;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.forecast-day:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(18, 60, 42, 0.08);
}

.forecast-day .icon {
  font-size: 1.8rem;
}

.forecast-day .temps {
  font-weight: 800;
  font-size: 0.9rem;
}

.recommendation-item {
  border-inline-start: 4px solid var(--fm-green-500);
  background: #fbfdfb;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.recommendation-item.severity-high,
.recommendation-item.severity-critical {
  border-inline-start-color: var(--fm-danger);
  background: #fdf8f8;
}

.recommendation-item.severity-medium {
  border-inline-start-color: #c9972f;
  background: #fdfbf5;
}

.recommendation-item .actions {
  margin: 8px 0 0;
  padding-inline-start: 18px;
  font-size: 0.82rem;
  color: var(--fm-muted);
}

/* ---------- الجداول ---------- */
.table {
  font-size: 0.82rem;
  vertical-align: middle;
  margin-bottom: 0;
}

.table > :not(caption) > * > * {
  padding: 11px 12px;
  border-color: rgba(23, 80, 58, 0.07);
}

.table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--fm-muted);
  font-weight: 700;
  background: #f8faf8;
  white-space: nowrap;
}

.table-hover > tbody > tr:hover > * {
  background: rgba(43, 143, 101, 0.04);
}

.table-responsive {
  border-radius: 12px;
}

/* ---------- الشارات ---------- */
.badge-soft {
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 0.7rem;
}

.badge-pending { background: #fff4d9; color: #8a6413; }
.badge-in_progress { background: #e3f0f7; color: #226383; }
.badge-done { background: #e2f4ea; color: #176b45; }
.badge-cancelled { background: #eceff1; color: #5c6b72; }
.badge-postponed { background: #f1e6f5; color: #6d3b7c; }
.badge-scheduled { background: #e3f0f7; color: #226383; }
.badge-completed { background: #e2f4ea; color: #176b45; }
.badge-high { background: #fdeaea; color: #9c2f2f; }
.badge-normal { background: #eef2f0; color: #4d6157; }
.badge-urgent { background: #f8d7d7; color: #842029; }
.badge-low { background: #eef2f0; color: #5f7268; }
.badge-paid { background: #e2f4ea; color: #176b45; }
.badge-partial { background: #fff4d9; color: #8a6413; }
.badge-pending-pay { background: #fdeaea; color: #9c2f2f; }

/* ---------- النماذج ---------- */
.form-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #395247;
  margin-bottom: 5px;
}

.form-control,
.form-select {
  border-radius: 10px;
  border-color: rgba(23, 80, 58, 0.16);
  font-size: 0.85rem;
  padding: 9px 12px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--fm-green-500);
  box-shadow: 0 0 0 0.2rem rgba(43, 143, 101, 0.12);
}

.btn {
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 16px;
}

.btn-brand {
  background: linear-gradient(135deg, var(--fm-green-700), var(--fm-green-500));
  color: #fff;
  border: none;
}

.btn-brand:hover,
.btn-brand:focus {
  background: linear-gradient(135deg, var(--fm-green-800), var(--fm-green-600));
  color: #fff;
}

.btn-soft {
  background: rgba(43, 143, 101, 0.09);
  color: var(--fm-green-700);
  border: 1px solid rgba(43, 143, 101, 0.12);
}

.btn-soft:hover {
  background: rgba(43, 143, 101, 0.16);
  color: var(--fm-green-800);
}

.btn-xs {
  font-size: 0.7rem;
  padding: 5px 9px;
  border-radius: 8px;
}

.filter-bar {
  background: #fff;
  border: 1px solid rgba(23, 80, 58, 0.08);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 6px 18px rgba(18, 60, 42, 0.04);
}

/* ---------- التنبيهات ---------- */
.alert {
  border-radius: 12px;
  border: none;
  font-size: 0.84rem;
  box-shadow: 0 6px 16px rgba(18, 60, 42, 0.05);
}

.alert-success { background: #e5f5ec; color: #14583a; }
.alert-danger { background: #fbe9e9; color: #8e2b2b; }
.alert-warning { background: #fdf5e2; color: #7f5b11; }
.alert-info { background: #e7f1f6; color: #1e5a78; }

/* ---------- صفحة الدخول ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 15% 15%, rgba(217, 180, 95, 0.2), transparent 35%),
    radial-gradient(circle at 85% 80%, rgba(43, 143, 101, 0.25), transparent 40%),
    linear-gradient(150deg, #0c2b1e, #17503a 55%, #1c6647);
}

.login-card {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  border-radius: 24px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
}

.login-visual {
  background:
    linear-gradient(150deg, rgba(12, 43, 30, 0.92), rgba(28, 102, 71, 0.86)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.035) 0 12px, transparent 12px 24px);
  color: #fff;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 30px;
}

.login-visual .logo {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  background: linear-gradient(145deg, #e2c273, #b78f37);
  display: grid;
  place-items: center;
  font-size: 1.9rem;
  color: #143728;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.login-visual h1 {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.5;
  margin: 0;
}

.login-visual p {
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.86rem;
  line-height: 1.9;
  margin: 8px 0 0;
}

.login-visual ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.85);
}

.login-visual li::before {
  content: "✓";
  color: #d9b45f;
  font-weight: 800;
  margin-inline-end: 8px;
}

.login-form {
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-form h2 {
  font-weight: 800;
  font-size: 1.3rem;
}

.login-form .form-control {
  padding: 12px 14px;
}

/* ---------- متفرقات ---------- */
.section-title {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title i {
  color: var(--fm-green-600);
}

.text-muted-sm {
  font-size: 0.75rem;
  color: var(--fm-muted);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--fm-muted);
}

.empty-state i {
  font-size: 2.4rem;
  opacity: 0.35;
  display: block;
  margin-bottom: 10px;
}

.progress {
  border-radius: 999px;
  background: #edf2ee;
  height: 7px;
}

.progress-bar {
  background: linear-gradient(90deg, var(--fm-green-500), var(--fm-green-700));
}

.timeline {
  position: relative;
  padding-inline-start: 22px;
}

.timeline::before {
  content: "";
  position: absolute;
  inset-block: 4px;
  inset-inline-start: 6px;
  width: 2px;
  background: #e0e9e3;
}

.timeline-item {
  position: relative;
  padding-bottom: 16px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  inset-inline-start: -21px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbdad1;
  border: 2px solid #fff;
}

.timeline-item.active::before {
  background: var(--fm-green-500);
  box-shadow: 0 0 0 3px rgba(43, 143, 101, 0.15);
}

.timeline-item.past::before {
  background: #9fb5a8;
}

.ai-result-card {
  border: 1px solid rgba(23, 80, 58, 0.09);
  border-radius: 14px;
  overflow: hidden;
  height: 100%;
}

.ai-result-card img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  background: #eef2ef;
}

.ai-result-card .ai-body {
  padding: 14px;
}

.confidence-pill {
  font-weight: 800;
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(43, 143, 101, 0.1);
  color: var(--fm-green-700);
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
}

details.action-details summary {
  cursor: pointer;
  color: var(--fm-green-700);
  font-size: 0.75rem;
  font-weight: 700;
  list-style: none;
}

details.action-details summary::-webkit-details-marker {
  display: none;
}

details.action-details summary::after {
  content: " ▾";
}

.chart-wrap {
  position: relative;
  min-height: 280px;
}

.data-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f2f6f3;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.72rem;
  color: #496256;
  margin: 0 0 6px 6px;
}

.login-footer {
  margin-top: 26px;
  font-size: 0.7rem;
  color: var(--fm-muted);
  text-align: center;
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(100%);
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app-main {
    margin-inline-start: 0;
  }

  .sidebar-toggle {
    display: inline-grid;
    place-items: center;
  }

  .page-content {
    padding: 18px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .login-card {
    grid-template-columns: 1fr;
  }

  .login-visual {
    padding: 32px 26px;
  }

  .login-form {
    padding: 32px 26px;
  }
}

@media (max-width: 575.98px) {
  .topbar .user-chip .user-text {
    display: none;
  }

  .weather-hero .temp {
    font-size: 2.2rem;
  }

  .kpi-card .kpi-value {
    font-size: 1.3rem;
  }
}

/* ---------- المساعد الذكي العائم ---------- */
.assistant-fab {
  position: fixed;
  left: 24px;
  right: auto;
  bottom: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--fm-green-600), var(--fm-green-900));
  color: #fff;
  font-size: 1.35rem;
  display: grid;
  place-items: center;
  box-shadow: 0 14px 30px rgba(18, 60, 42, 0.32);
  z-index: 1050;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.assistant-fab::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(43, 143, 101, 0.35);
  animation: assistant-pulse 2.6s ease-out infinite;
}

.assistant-fab:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 18px 36px rgba(18, 60, 42, 0.4);
}

.assistant-open .assistant-fab {
  background: linear-gradient(145deg, #c9a85e, #b08331);
}

@keyframes assistant-pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

.assistant-panel {
  position: fixed;
  left: 24px;
  right: auto;
  bottom: 94px;
  width: min(410px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 130px));
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 26px 70px rgba(12, 43, 30, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1051;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.assistant-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.assistant-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--fm-green-800), var(--fm-green-600));
  color: #fff;
}

.assistant-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.assistant-title strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 800;
}

.assistant-title small {
  display: block;
  font-size: 0.7rem;
  opacity: 0.8;
}

.assistant-close {
  margin-inline-start: auto;
  background: rgba(255, 255, 255, 0.14);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

.assistant-head-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.assistant-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 0.9rem;
  transition: background 0.15s ease;
}

.assistant-icon-btn:hover {
  background: rgba(255, 255, 255, 0.26);
}

.assistant-icon-btn.small {
  width: 26px;
  height: 26px;
  font-size: 0.75rem;
  background: transparent;
  color: var(--fm-muted);
  border-radius: 7px;
}

.assistant-icon-btn.small:hover {
  background: rgba(23, 80, 58, 0.08);
  color: var(--fm-green-700);
}

/* لوحة الذاكرة */
.assistant-memory-panel {
  position: absolute;
  top: 62px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  z-index: 3;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.22s ease;
  pointer-events: none;
}

.assistant-memory-panel.open {
  transform: translateY(0);
  pointer-events: auto;
}

.assistant-memory-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(23, 80, 58, 0.08);
  font-size: 0.88rem;
}

.assistant-memory-head strong {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fm-green-800);
}

.assistant-memory-head .assistant-icon-btn.small {
  margin-inline-start: auto;
}

.assistant-memory-form {
  display: flex;
  gap: 6px;
  padding: 10px 12px 6px;
}

.assistant-memory-form input {
  flex: 1;
  border: 1px solid rgba(23, 80, 58, 0.16);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-family: inherit;
}

.assistant-memory-form button {
  width: 34px;
  border: none;
  border-radius: 10px;
  background: var(--fm-green-600);
  color: #fff;
}

.assistant-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 12px 6px;
  padding: 6px 10px;
  border: 1px solid rgba(23, 80, 58, 0.12);
  border-radius: 10px;
  background: #f8faf8;
}

.assistant-search i {
  color: var(--fm-muted);
  font-size: 0.8rem;
}

.assistant-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.75rem;
  font-family: inherit;
  outline: none;
}

.assistant-search-results {
  max-height: 150px;
  overflow-y: auto;
  padding: 0 12px;
}

.assistant-search-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f7faf7;
  margin-bottom: 4px;
  font-size: 0.72rem;
}

.assistant-search-role {
  font-weight: 800;
  color: var(--fm-green-700);
}

.assistant-search-text {
  color: var(--fm-ink);
  line-height: 1.6;
}

.assistant-search-date {
  color: var(--fm-muted);
  font-size: 0.65rem;
}

.assistant-search-empty,
.assistant-memory-empty {
  padding: 10px;
  font-size: 0.74rem;
  color: var(--fm-muted);
  text-align: center;
}

.assistant-memory-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.assistant-memory-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid rgba(23, 80, 58, 0.1);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fbfdfb;
}

.assistant-memory-item.pinned {
  border-color: rgba(201, 168, 94, 0.55);
  background: #fffdf6;
}

.assistant-memory-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.assistant-memory-cat {
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--fm-green-700);
}

.assistant-memory-text {
  font-size: 0.76rem;
  line-height: 1.65;
  color: var(--fm-ink);
}

.assistant-memory-actions {
  display: flex;
  gap: 2px;
}

.assistant-time {
  font-size: 0.64rem;
}

.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 6px;
  background: linear-gradient(180deg, #f7faf7, #ffffff 60%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.assistant-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.assistant-msg-user {
  align-self: flex-start;
  align-items: flex-start;
}

.assistant-msg-assistant {
  align-self: flex-end;
  align-items: flex-end;
}

.assistant-meta {
  font-size: 0.66rem;
  color: var(--fm-muted);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.assistant-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.83rem;
  line-height: 1.85;
  display: flex;
  flex-direction: column;
  gap: 2px;
  word-break: break-word;
}

.assistant-msg-user .assistant-bubble {
  background: linear-gradient(140deg, var(--fm-green-600), var(--fm-green-700));
  color: #fff;
  border-end-start-radius: 4px;
}

.assistant-msg-assistant .assistant-bubble {
  background: #fff;
  border: 1px solid rgba(23, 80, 58, 0.12);
  color: var(--fm-ink);
  border-end-end-radius: 4px;
  box-shadow: 0 6px 16px rgba(18, 60, 42, 0.06);
}

.assistant-bubble code {
  background: rgba(43, 143, 101, 0.1);
  color: var(--fm-green-800);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.78rem;
}

.assistant-li {
  padding-inline-start: 2px;
}

.assistant-h {
  font-weight: 800;
  color: var(--fm-green-800);
  margin-top: 4px;
}

.assistant-rule {
  height: 1px;
  background: rgba(23, 80, 58, 0.12);
  margin: 6px 0;
}

.assistant-table-wrap {
  overflow-x: auto;
  margin: 6px 0;
  border-radius: 10px;
  border: 1px solid rgba(23, 80, 58, 0.1);
}

.assistant-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.74rem;
  background: #fff;
}

.assistant-table th,
.assistant-table td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid rgba(23, 80, 58, 0.08);
  white-space: nowrap;
}

.assistant-table th {
  background: rgba(43, 143, 101, 0.08);
  color: var(--fm-green-800);
  font-weight: 800;
}

.assistant-msg-user .assistant-table {
  color: var(--fm-ink);
}

.assistant-gap {
  height: 6px;
}

.assistant-typing {
  flex-direction: row;
  gap: 5px;
  align-items: center;
  padding: 12px 16px;
}

.assistant-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9fb5a8;
  animation: assistant-blink 1.2s infinite ease-in-out;
}

.assistant-typing span:nth-child(2) { animation-delay: 0.2s; }
.assistant-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes assistant-blink {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.assistant-action {
  align-self: stretch;
  display: flex;
  gap: 10px;
  border: 1px solid rgba(201, 168, 94, 0.55);
  background: #fffdf6;
  border-radius: 14px;
  padding: 12px;
}

.assistant-action.done {
  border-color: rgba(43, 143, 101, 0.4);
  background: #f5fbf7;
}

.assistant-action.cancelled,
.assistant-action.failed {
  border-color: rgba(23, 80, 58, 0.12);
  background: #f8faf8;
}

.assistant-action-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(201, 168, 94, 0.2);
  color: #8f6c1f;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.assistant-action-body {
  flex: 1;
  min-width: 0;
}

.assistant-action-title {
  font-size: 0.7rem;
  font-weight: 800;
  color: #8f6c1f;
  margin-bottom: 3px;
}

.assistant-action-text {
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--fm-ink);
}

.assistant-action-buttons {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.assistant-action-status {
  margin-top: 8px;
  font-size: 0.76rem;
  font-weight: 700;
}

.assistant-action-status.ok { color: #176b45; }
.assistant-action-status.error { color: var(--fm-danger); }
.assistant-action-status.muted { color: var(--fm-muted); }

.assistant-suggestions {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px;
  border-top: 1px solid rgba(23, 80, 58, 0.07);
  background: #fbfdfb;
  scrollbar-width: none;
}

.assistant-suggestions::-webkit-scrollbar {
  display: none;
}

.assistant-suggestions button {
  white-space: nowrap;
  border: 1px solid rgba(43, 143, 101, 0.2);
  background: #fff;
  color: var(--fm-green-700);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 5px 11px;
}

.assistant-suggestions button:hover {
  background: rgba(43, 143, 101, 0.08);
}

.assistant-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(23, 80, 58, 0.08);
  background: #fff;
}

.assistant-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid rgba(23, 80, 58, 0.16);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 0.83rem;
  font-family: inherit;
  max-height: 120px;
  line-height: 1.6;
}

.assistant-form textarea:focus {
  outline: none;
  border-color: var(--fm-green-500);
  box-shadow: 0 0 0 0.18rem rgba(43, 143, 101, 0.12);
}

.assistant-form button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(140deg, var(--fm-green-600), var(--fm-green-800));
  color: #fff;
  flex: 0 0 auto;
}

.assistant-form button:disabled {
  opacity: 0.5;
}

.assistant-foot {
  padding: 6px 12px 9px;
  font-size: 0.64rem;
  color: var(--fm-muted);
  text-align: center;
  background: #fff;
}

@media (max-width: 575.98px) {
  .assistant-panel {
    left: 10px;
    right: 10px;
    bottom: 86px;
    width: auto;
    height: min(70vh, calc(100vh - 110px));
  }

  .assistant-fab {
    left: 16px;
    right: auto;
    bottom: 16px;
    width: 52px;
    height: 52px;
  }
}

@media print {
  .sidebar,
  .topbar,
  .app-footer,
  .no-print,
  .assistant-fab,
  .assistant-panel {
    display: none !important;
  }

  .app-main {
    margin: 0;
  }

  body {
    background: #fff;
  }
}
