/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  background: #f0f4f8;
  color: #1e293b;
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 220px;
  min-height: 100vh;
  background: #fff;
  border-right: 1px solid #e8edf4;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid #e8edf4;
}

.logo-icon {
  width: 36px; height: 36px;
  background: #1e3a5f;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.logo-text {
  color: #1e293b;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  font-size: 18px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: #64748b;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.nav-item.active {
  background: #1e3a5f;
  color: #fff;
  border-radius: 8px;
}

.nav-item svg {
  width: 17px; height: 17px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active svg { opacity: 1; }

.sidebar-bottom {
  padding: 10px 10px;
  border-top: 1px solid #e8edf4;
}

.nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.nav-item.active .nav-badge {
  background: rgba(255,255,255,0.3);
  color: #fff;
}

/* ===== MAIN LAYOUT ===== */
.main-wrap {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-title h1 {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
}

.header-title p {
  font-size: 12px;
  color: #64748b;
  margin-top: 1px;
}

.header-search {
  margin-left: auto;
  position: relative;
}

.header-search input {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 14px 8px 36px;
  font-size: 13px;
  color: #475569;
  width: 220px;
  outline: none;
  transition: border 0.2s;
}

.header-search input:focus { border-color: #2563eb; }

.header-search svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  width: 16px; height: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-bell {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  color: #475569;
}

.header-bell .dot {
  position: absolute;
  top: 6px; right: 7px;
  width: 8px; height: 8px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.user-info .name {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}

.user-info .role {
  font-size: 11px;
  color: #64748b;
}

/* ===== PAGE CONTENT ===== */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ===== CARDS ===== */
.card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e8edf4;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
}

.card-subtitle {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

.btn-link {
  font-size: 13px;
  color: #2563eb;
  background: none;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  text-decoration: none;
  font-weight: 500;
}

.btn-link:hover { opacity: 0.8; }

.btn {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
}

.btn:hover { opacity: 0.9; }

.btn-primary { background: #2563eb; color: #fff; }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-outline { background: #fff; color: #2563eb; border: 1.5px solid #2563eb; }
.btn-teal { background: #0d9488; color: #fff; }
.btn-teal:hover { background: #0f766e; }

/* ===== PROGRESS BAR ===== */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.progress-bar-bg {
  flex: 1;
  height: 7px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0d9488, #14b8a6);
  border-radius: 10px;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  white-space: nowrap;
}

.progress-label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}

/* ===== STEPS ===== */
.step-list { display: flex; flex-direction: column; gap: 0; }

.step-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
  position: relative;
}

.step-item:last-child { border-bottom: none; }

.step-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 2px solid #e2e8f0;
  background: #fff;
  color: #94a3b8;
  font-size: 13px;
}

.step-icon.done {
  border-color: #0d9488;
  background: #0d9488;
  color: #fff;
}

.step-icon.active {
  border-color: #0d9488;
  background: #e6faf8;
  color: #0d9488;
}

.step-name {
  font-size: 14px;
  font-weight: 500;
  color: #1e293b;
  flex: 1;
}

.step-name.active-link { color: #0d9488; cursor: pointer; }

.step-date {
  font-size: 12px;
  color: #94a3b8;
}

.step-status-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}

.tag-process { background: #e0f7f4; color: #0d9488; }
.tag-wait { background: #f1f5f9; color: #94a3b8; }
.tag-done { background: #ecfdf5; color: #059669; }
.tag-paid { background: #ecfdf5; color: #059669; }
.tag-pending { background: #fef3c7; color: #d97706; }

/* ===== CURRENT STAGE BOX ===== */
.current-stage-box {
  background: #e6faf8;
  border: 1px solid #99e6df;
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 12px;
}

.current-stage-box .label {
  font-size: 11px;
  font-weight: 600;
  color: #0d9488;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px;
}

.current-stage-box .title {
  font-size: 14px;
  font-weight: 700;
  color: #134e4a;
  margin-bottom: 4px;
}

.current-stage-box .desc {
  font-size: 12px;
  color: #0f766e;
}

/* ===== GRID LAYOUTS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-main { display: grid; grid-template-columns: 1fr 260px; gap: 20px; }

/* ===== QUICK ACTIONS ===== */
.quick-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quick-action-btn {
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  border-radius: 10px;
  padding: 14px 12px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #0f766e;
  transition: background 0.15s, transform 0.1s;
  text-align: center;
}

.quick-action-btn:hover { background: #ccfbf1; transform: translateY(-1px); }
.quick-action-btn.grey { background: #f8fafc; border-color: #e2e8f0; color: #475569; }
.quick-action-btn.grey:hover { background: #e2e8f0; transform: translateY(-1px); }
.quick-action-btn.blue { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.quick-action-btn.blue:hover { background: #bfdbfe; }
.quick-action-btn.orange { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }
.quick-action-btn.orange:hover { background: #fed7aa; }
.quick-action-btn.green { background: #ecfdf5; border-color: #bbf7d0; color: #166534; }
.quick-action-btn.green:hover { background: #bbf7d0; }

.quick-action-btn svg { width: 24px; height: 24px; }

/* ===== DOCUMENT LIST ===== */
.doc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}

.doc-item:last-child { border-bottom: none; }

.doc-icon {
  width: 38px; height: 38px;
  background: #f1f5f9;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #64748b;
  flex-shrink: 0;
}

.doc-info { flex: 1; }
.doc-name { font-size: 13px; font-weight: 600; color: #1e293b; }
.doc-date { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* ===== PAYMENT CARD ===== */
.payment-card {
  background: linear-gradient(135deg, #1e3a5f, #2d5fa0);
  border-radius: 12px;
  padding: 18px;
  color: #fff;
  flex: 1;
}

.payment-card .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.payment-card .meta-label {
  font-size: 12px;
  opacity: 0.8;
  display: flex; align-items: center; gap: 6px;
}

.payment-card .badge {
  background: rgba(255,255,255,0.18);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
}

.payment-card .amount {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}

.payment-card .due-date {
  font-size: 12px;
  opacity: 0.7;
}

/* ===== NOTIFICATION ITEMS ===== */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}

.notif-item:last-child { border-bottom: none; }

.notif-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: #eff6ff;
  color: #2563eb;
}

.notif-info { flex: 1; }
.notif-title { font-size: 13px; font-weight: 600; color: #1e293b; }
.notif-desc { font-size: 12px; color: #64748b; margin-top: 2px; }
.notif-time { font-size: 11px; color: #94a3b8; margin-top: 4px; }
.notif-dot { width: 8px; height: 8px; background: #22c55e; border-radius: 50%; margin-top: 5px; }

/* ===== CHAT ===== */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.message-row > div:not(.message-avatar) {
  max-width: 70%;
}

.message-row.own {
  flex-direction: row-reverse;
}

.message-row.own > div:not(.message-avatar) {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: fit-content;
  max-width: calc(100% - 42px);
}

.message-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: #94a3b8;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.message-avatar.lawyer { background: #0d9488; }

.bubble {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}

.bubble.incoming {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  color: #1e293b;
}

.bubble.own {
  background: #3b6bdb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble-time {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
  text-align: right;
}

.bubble.own .bubble-time { color: rgba(255,255,255,0.7); }

.chat-input-wrap {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 13px;
  color: #1e293b;
  background: transparent;
  resize: none;
}

.chat-send-btn {
  width: 36px; height: 36px;
  background: #2563eb;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

/* ===== TABLE ===== */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
}

td {
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  color: #1e293b;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* ===== FORM ===== */
.form-group { margin-bottom: 16px; }
.form-label { font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 6px; display: block; }
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  color: #1e293b;
  outline: none;
  transition: border 0.2s;
  background: #fff;
}

.form-input:focus { border-color: #2563eb; }
.form-input:disabled { background: #f8fafc; color: #94a3b8; }

.form-section { margin-bottom: 28px; }
.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

/* ===== AVATAR UPLOAD ===== */
.avatar-upload {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.avatar-big {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  font-weight: 700;
}

/* ===== STATUS BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-blue { background: #eff6ff; color: #1d4ed8; }
.badge-green { background: #ecfdf5; color: #059669; }
.badge-orange { background: #fff7ed; color: #c2410c; }
.badge-grey { background: #f1f5f9; color: #64748b; }
.badge-teal { background: #f0fdfa; color: #0d9488; }

/* ===== MOBILE HAMBURGER BTN ===== */
.mobile-menu-btn {
  display: none;
  width: 38px; height: 38px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #475569;
  flex-shrink: 0;
}

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 150;
}
.sidebar-overlay.open { display: block; }

/* ===== BOTTOM NAVIGATION ===== */
.bottom-nav { display: none; }

/* ===== TABLET ===== */
@media (max-width: 900px) {
  .grid-2, .grid-main { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {

  /* Sidebar: slide-in drawer */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.18);
  }
  .sidebar-toggle { display: none; }

  /* Main wrap takes full width */
  .main-wrap { margin-left: 0; }

  /* Header */
  .header { padding: 10px 14px; gap: 8px; }
  .header-title h1 { font-size: 16px; }
  .header-search { display: none; }
  .user-info { display: none; }
  .mobile-menu-btn { display: flex; }

  /* Page content — bottom padding for bottom nav */
  .page-content { padding: 14px 14px 76px; }

  /* Cards */
  .card { padding: 16px; }

  /* Grid layouts → single column */
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-main { grid-template-columns: 1fr; }

  /* Quick actions: keep 2×2 grid */
  .quick-actions-grid { grid-template-columns: 1fr 1fr; }

  /* Steps */
  .step-item { gap: 10px; }

  /* Progress */
  .progress-wrap { gap: 8px; }

  /* Buttons */
  .btn { padding: 10px 14px; font-size: 13px; }

  /* Bottom navigation bar */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 4px);
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 7px 4px 5px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 9px;
    font-weight: 600;
    position: relative;
    transition: color 0.15s;
  }
  .bottom-nav-item.active { color: #0d9488; }
  .bottom-nav-item svg { width: 21px; height: 21px; }
  .bottom-nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 18px);
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 15px; height: 15px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px;
  }

  /* Chat page */
  .chat-right-panel { display: none !important; }
  .chat-layout { height: calc(100dvh - 60px - 56px); }
  .chat-main-body { padding: 14px; }
  .chat-footer { padding: 10px 14px; }

  /* Payments page */
  .stats-grid-4 { grid-template-columns: 1fr 1fr !important; }
  .payments-bottom-grid { grid-template-columns: 1fr !important; }
  .next-payment-banner {
    flex-direction: column;
    gap: 14px;
    padding: 16px;
  }
  .next-payment-banner-actions {
    width: 100%;
    flex-direction: column;
  }
  .next-payment-banner-actions .btn-teal,
  .next-payment-banner-actions .btn-outline-white {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* Profile page */
  .profile-grid { grid-template-columns: 1fr !important; }
  .sysinfo-grid { grid-template-columns: 1fr 1fr !important; }
  .sysinfo-col:not(:last-child) {
    border-right: none;
    margin-right: 0;
    padding-right: 0;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
  }

  /* Documents page */
  .doc-row { flex-wrap: wrap; gap: 10px; }
  .doc-row-info { min-width: 0; flex: 1 1 100%; order: 2; }
  .doc-actions { order: 4; }

  /* Notifications page */
  .notif-actions-row { flex-wrap: wrap; gap: 8px; }
  .notif-actions-right { flex-wrap: wrap; }

  /* Table horizontal scroll */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }
  .table-responsive table { min-width: 460px; }
}
