/* ============================================================
   Senidek admin panel
   ============================================================ */
:root {
  --paper: #F1F4F3;
  --surface: #FFFFFF;
  --ink: #10282B;
  --ink-soft: #3F5659;
  --line: #D3DEDC;
  --teal: #0A8F9C;
  --teal-deep: #076973;
  --deep: #0B3B40;
  --gold: #E3B23C;
  --danger: #B3261E;
  --ok: #0E7A3D;
  --font: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --nav-h: 56px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font: inherit; color: inherit; }

/* ── Layout ───────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--deep); color: #fff;
  padding: 20px 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: 12px;
}
.sidebar .brand b { font-size: 15px; font-weight: 700; }
.sidebar .brand small { display: block; color: #9fc0c3; font-size: 11px; }
.sidebar nav { display: grid; }
.sidebar nav a {
  color: #c7dcde;
  padding: 10px 20px;
  display: flex; align-items: center; gap: 10px;
  border-left: 3px solid transparent;
  font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.sidebar nav a.on { background: rgba(10,143,156,.2); border-left-color: var(--teal); color: #fff; }
.sidebar nav .badge {
  margin-left: auto;
  background: var(--gold); color: var(--ink);
  font-size: 11px; padding: 1px 7px; border-radius: 10px;
  font-weight: 700;
}
.sidebar .user {
  margin-top: auto; padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 13px; color: #9fc0c3;
}
.sidebar .user b { color: #fff; display: block; font-weight: 600; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.topbar h1 { font-size: 17px; font-weight: 700; }
.topbar .right { display: flex; gap: 12px; align-items: center; }
.content { padding: 24px; flex: 1; }

/* ── Cards, tables ────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  background: #fafcfb;
}
.card-head h2 { font-size: 15px; font-weight: 700; }
.card-body { padding: 18px; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}
th {
  background: #fafcfb;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #f9fbfa; }

/* ── Forms ────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 13px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: #fff;
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--teal-deep);
  box-shadow: 0 0 0 3px rgba(10,143,156,.15);
}
.field textarea { resize: vertical; min-height: 90px; font-family: inherit; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  border: 1.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-solid { background: var(--teal-deep); color: #fff; }
.btn-solid:hover { background: var(--deep); }
.btn-line { border-color: var(--ink); color: var(--ink); background: transparent; }
.btn-line:hover { background: var(--ink); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8b1c16; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Flash ────────────────────────────────────────────────── */
.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
}
.flash-ok  { background: #E3F4EA; border: 1px solid #9ACFAF; color: #0E4B26; }
.flash-err { background: #FCE9E7; border: 1px solid #E6A39D; color: #7A1912; }

/* ── Pills ────────────────────────────────────────────────── */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 12px;
  font-size: 11.5px; font-weight: 600;
  background: #e5edec; color: var(--ink-soft);
}
.pill.new      { background: #FEF3C7; color: #7C5C00; }
.pill.unread   { background: #FEF3C7; color: #7C5C00; }
.pill.read     { background: #E0E7FF; color: #3730A3; }
.pill.replied  { background: #DCFCE7; color: #166534; }
.pill.archived,
.pill.lost     { background: #F3F4F6; color: #4B5563; }
.pill.contacted{ background: #DBEAFE; color: #1E40AF; }
.pill.quoted   { background: #FEF3C7; color: #7C5C00; }
.pill.converted{ background: #DCFCE7; color: #166534; }

/* ── Login ────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 20px;
  background: radial-gradient(circle at 30% 20%, #124C52, #0B3B40 60%, #082a2e);
}
.login-card {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 380px;
  padding: 32px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.5);
}
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card p.lede { color: var(--ink-soft); font-size: 14px; margin-bottom: 22px; }
.login-card .btn { width: 100%; }
.login-err {
  background: #FCE9E7; border: 1px solid #E6A39D; color: #7A1912;
  padding: 10px 12px; border-radius: 6px; font-size: 14px;
  margin-bottom: 14px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto;
    display: flex; align-items: center; gap: 8px;
    overflow-x: auto; padding: 8px 12px;
  }
  .sidebar .brand, .sidebar .user { display: none; }
  .sidebar nav { display: flex; flex-direction: row; gap: 4px; }
  .sidebar nav a { padding: 8px 12px; white-space: nowrap; border-left: 0; border-radius: 6px; }
  .sidebar nav a.on { border-left: 0; }
  .field-row { grid-template-columns: 1fr; }
}
/* ── Dashboard + small-screen helpers ─────────────────────── */
.dash-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 24px; }
.dash-cols  { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card { overflow-x: auto; }               /* wide tables scroll inside the card on phones */
.login-err[role="alert"] { margin-bottom: 16px; font-weight: 500; }
.topbar .right { flex-wrap: wrap; }

@media (max-width: 1100px) {
  .dash-cols { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-rows: auto 1fr; }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .card table { min-width: 620px; }
  .btn { min-height: 40px; }
  select.btn { min-height: 40px; }
}
