/* ============================================================
   Fiable Hydraulics CRM — Stylesheet
   Brand color: #1a3a5c
   ============================================================ */

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

:root {
  --brand: #1a3a5c;
  --brand-dark: #122a44;
  --brand-tint: #e8eef5;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e3e8ef;
  --text: #1f2a37;
  --muted: #6b7785;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----------------------- Home page ----------------------- */
.home-body {
  background: linear-gradient(135deg, #f4f7fb 0%, #e9eef5 100%);
  min-height: 100vh;
}
.home-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 80px 24px 60px;
  text-align: center;
}
.logo-mark {
  width: 78px; height: 78px;
  border-radius: 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 8px 22px rgba(26, 58, 92, .25);
}
.home-title {
  margin: 0;
  font-size: 38px;
  color: var(--brand);
  letter-spacing: -.5px;
}
.home-sub { color: var(--muted); margin: 8px 0 32px; }
.home-eyebrow {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--muted);
  margin: 18px 0 16px;
}
.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 8px;
}
.role-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 20px;
  box-shadow: var(--shadow);
  color: var(--text);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.role-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(26, 58, 92, .12);
  border-color: #c9d3e0;
  text-decoration: none;
}
.role-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.role-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
  color: var(--brand);
}
.role-card p { margin: 0; color: var(--muted); font-size: 14px; }

/* ----------------------- Header (inner pages) ----------------------- */
.app-header {
  background: var(--brand);
  color: #fff;
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.app-header h1 { margin: 0; font-size: 18px; font-weight: 600; }
.logo-mark-sm {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.role-tag {
  background: rgba(255, 255, 255, .14);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
}
.header-actions a {
  color: #fff;
  background: rgba(255, 255, 255, .12);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
}
.header-actions a:hover {
  background: rgba(255, 255, 255, .22);
  text-decoration: none;
}

/* ----------------------- Main / cards ----------------------- */
.app-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 28px 60px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.card-title { margin: 0 0 16px; font-size: 17px; color: var(--brand); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-head .card-title { margin: 0; }

/* ----------------------- Form ----------------------- */
.lead-form .form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .6px;
  color: var(--muted);
  text-transform: uppercase;
}
.field input,
.field select,
.field textarea {
  font: inherit;
  color: var(--text);
  background: #fff;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, .12);
}
.field input[disabled] { background: #f1f4f8; color: #5e6b7a; }
.field textarea { resize: vertical; min-height: 78px; }

.form-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 18px;
}

/* ----------------------- Buttons ----------------------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: #b8c2d0; background: #f7f9fc; }
.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #f1c9c2;
}
.btn-danger:hover { background: #fff3f1; border-color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
a.btn { display: inline-block; text-decoration: none; }
a.btn:hover { text-decoration: none; }

/* ----------------------- Filters ----------------------- */
.filters {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.filters input[type="text"],
.filters select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  outline: none;
}
.filters input[type="text"] { min-width: 220px; }
.filters input[type="text"]:focus,
.filters select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, .12);
}

/* ----------------------- Table ----------------------- */
.table-wrap { overflow-x: auto; }
.leads-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.leads-table th,
.leads-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
.leads-table thead th {
  font-size: 11px;
  letter-spacing: .6px;
  color: var(--muted);
  text-transform: uppercase;
  background: #fafbfd;
  border-bottom: 1px solid var(--border);
}
.leads-table tbody tr:hover { background: #fafbfd; }
.td-name { font-weight: 600; }
.td-muted { color: var(--muted); }
.td-actions { white-space: nowrap; display: flex; gap: 6px; }
.empty-state {
  text-align: center; color: var(--muted); padding: 28px 8px !important;
}

/* ----------------------- Badges ----------------------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  border: 1px solid transparent;
}
.badge-new        { background: #e0ecff; color: #1d4ed8; border-color: #c5d8ff; }
.badge-contacted  { background: #fef3c7; color: #92400e; border-color: #fde6a4; }
.badge-quotation  { background: #ede9fe; color: #5b21b6; border-color: #d9d0fb; }
.badge-followup   { background: #ffe4d6; color: #9a3412; border-color: #ffcdb1; }
.badge-won        { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-lost       { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

/* ----------------------- Stats ----------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-label {
  margin: 0; font-size: 11px; letter-spacing: .8px;
  color: var(--muted); font-weight: 600;
}
.stat-value {
  margin: 8px 0 4px; font-size: 32px; font-weight: 700;
  color: var(--brand);
}
.stat-foot { margin: 0; font-size: 12px; color: var(--muted); }

/* ----------------------- Placeholder ----------------------- */
.placeholder-card {
  background: var(--card);
  border: 1px dashed #c9d3e0;
  border-radius: 12px;
  padding: 60px 30px;
  text-align: center;
  color: var(--muted);
  max-width: 720px;
  margin: 32px auto;
}
.placeholder-card h2 { margin: 0 0 8px; color: var(--brand); }
.placeholder-card p { margin: 6px 0; }

/* ----------------------- Toast ----------------------- */
.toast {
  position: fixed;
  top: 20px; right: 20px;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .15);
  z-index: 9999;
}
.toast-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.toast-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ----------------------- Installer ----------------------- */
.install-block { padding: 14px 16px; border-radius: 8px; }
.install-block ul { margin: 8px 0 0; padding-left: 22px; }
.install-ok    { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.install-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.install-warn  {
  margin-top: 18px; padding: 10px 14px;
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 8px; font-size: 13px; color: #78350f;
}

/* ----------------------- Mobile ----------------------- */
@media (max-width: 960px) {
  .lead-form .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid            { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .role-grid            { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .app-header { padding: 12px 16px; flex-wrap: wrap; }
  .app-header h1 { font-size: 16px; }
  .app-main { padding: 16px; }
  .card { padding: 16px; }
  .home-wrap { padding: 50px 18px 40px; }
  .home-title { font-size: 28px; }
  .lead-form .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .filters input[type="text"] { min-width: 0; flex: 1; }
  .card-head { flex-direction: column; align-items: stretch; }
}
