/* EcoHorizont CRM -- MiniCRM-style layout, Eco Horizont brand (leaf green #69b33b + charcoal). */
:root {
  --bg: #eef1f4;               /* page background (MiniCRM light gray) */
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --border: #e2e6ea;
  --border-strong: #d3d9df;
  --text: #2f3437;
  --muted: #7c868d;
  --accent: #69b33b;           /* Eco Horizont brand green */
  --accent-dark: #58991f;
  --accent-weak: #eef6e6;
  --blue: #2f7fc1;             /* MiniCRM-like accent for links/open states */
  --blue-weak: #e7f1fa;
  --danger: #d6493a;
  --warn: #d68910;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.14);
  --radius: 10px;
  --topbar-h: 56px;
  --side-w: 240px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }

.btn { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color:#fff; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.brand-logo { display: block; height: 34px; width: auto; max-width: 100%; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg,#f3f7ee,#e7eef4); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 34px 30px; width: 100%; max-width: 370px; text-align: center; }
.login-card .brand-logo { height: 44px; margin: 0 auto 6px; }
.login-card label, .login-card input { text-align: left; }
.login-card .sub { color: var(--muted); margin-bottom: 18px; }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 18px; padding: 0 18px;
}
.topbar .brand-logo { height: 30px; }
.topbar .search { flex: 1; max-width: 620px; margin: 0 auto; position: relative; }
.topbar .search input { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px 8px 38px; }
.topbar .search:before { content: "🔎"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .6; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.iconbtn { width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent; display: grid; place-items: center; font-size: 16px; color: var(--muted); }
.iconbtn:hover { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.avatar-wrap { position: relative; }
.avatar-menu { position: absolute; right: 0; top: 44px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 200px; padding: 6px; display: none; }
.avatar-menu.open { display: block; }
.avatar-menu .who { padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.avatar-menu .who b { display:block; }
.avatar-menu button { width: 100%; text-align: left; background: none; border: none; padding: 9px 10px; border-radius: 7px; color: var(--text); font-weight: 500; }
.avatar-menu button:hover { background: var(--surface-2); }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: calc(100vh - var(--topbar-h)); }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 12px 10px; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: var(--text); margin-bottom: 1px; font-weight: 500; border-left: 3px solid transparent; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-weak); color: var(--accent-dark); font-weight: 700; border-left-color: var(--accent); }
.nav a.sub { padding: 7px 12px 7px 42px; font-size: 13px; color: var(--muted); font-weight: 500; }
.nav a.sub:hover { color: var(--text); }
.nav .ico { width: 20px; text-align: center; font-size: 15px; }
.nav .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 14px 12px 5px; font-weight: 700; }
.sidebar .spacer { flex: 1; }
.sidebar .bottom { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }

.main { padding: 22px 26px; overflow: auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; margin: 0; font-weight: 700; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search], .toolbar select { width: auto; min-width: 220px; max-width: 60vw; }

/* ---------- KPI cards (Mai napom) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 22px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.tile:before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.tile.blue:before { background: var(--blue); }
.tile.red:before { background: var(--danger); }
.tile.green:before { background: var(--accent); }
.tile.gray:before { background: var(--muted); }
.tile .k { color: var(--muted); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.tile .v { font-size: 30px; font-weight: 800; margin-top: 8px; }
.tile .v small { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- Card / table ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head { padding: 13px 16px; font-weight: 700; border-bottom: 1px solid var(--border); display:flex; justify-content:space-between; align-items:center; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border); }
th { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 700; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td .rowico { color: var(--muted); margin-right: 8px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 11px 16px; color: var(--muted); border-top: 1px solid var(--border); }
.empty { padding: 46px; text-align: center; color: var(--muted); }

/* list + right filter panel */
.list-layout { display: grid; grid-template-columns: 1fr 250px; gap: 18px; align-items: start; }
.filter-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.filter-panel .fp-group { font-weight: 700; margin: 12px 0 6px; }
.filter-panel .fp-group:first-child { margin-top: 0; }
.filter-panel .fp-item { display: flex; justify-content: space-between; padding: 5px 0; color: var(--text); font-size: 13px; }
.filter-panel .fp-item .cnt { color: var(--muted); }
@media (max-width: 1000px){ .list-layout { grid-template-columns: 1fr; } .filter-panel { display:none; } }

/* ---------- Board (pipeline) ---------- */
.board { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 10px; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); min-width: 270px; width: 270px; flex: 0 0 auto; }
.col-head { padding: 10px 12px; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid var(--border-strong); }
.col-head .sum { font-size: 12px; color: var(--muted); font-weight: 600; }
.col-body { padding: 8px; min-height: 60px; display: flex; flex-direction: column; gap: 8px; }
.col-body.drag-over { background: var(--accent-weak); }
.deal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; box-shadow: var(--shadow); cursor: grab; border-left: 3px solid var(--blue); }
.deal-card:active { cursor: grabbing; }
.deal-card .t { font-weight: 600; }
.deal-card .m { color: var(--muted); font-size: 12px; margin-top: 3px; }
.deal-card .val { font-weight: 700; color: var(--accent-dark); margin-top: 6px; }

/* ---------- Status pills (MiniCRM-like, colored by group) ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.lead { background: var(--blue-weak); color: #1c5c92; }
.badge.open { background: #eaf3fb; color: #2f7fc1; }
.badge.won { background: #e6f4e6; color: #2f7d32; }
.badge.lost { background: #fbe7e4; color: #b23a2c; }
.badge.overdue { background: #fbe7e4; color: #b23a2c; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20,28,36,.5); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 540px; max-height: 90vh; overflow: auto; }
.modal.wide { max-width: 780px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.x { background: none; border: none; font-size: 22px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.section-title { font-weight: 700; margin: 16px 0 8px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--border-strong); padding: 0 0 14px 14px; position: relative; }
.timeline li:before { content: ''; position: absolute; left: -5px; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline .meta { color: var(--muted); font-size: 12px; }
.tasklist { list-style: none; padding: 0; margin: 0; }
.tasklist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.tasklist li.done .tt { text-decoration: line-through; color: var(--muted); }
.tasklist input[type=checkbox] { width: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.mt { margin-top: 14px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); font-weight: 600; }
.toast.err { background: var(--danger); }

.hamburger { display: none; }
.nav-backdrop { display: none; }
@media (max-width: 820px) {
  /* Mobile: content sits directly under the top bar; nav is an off-canvas
     drawer opened by the hamburger (MiniCRM-style). */
  .hamburger { display: grid; }
  .shell { display: block; }
  .main { padding: 16px; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0; width: 240px;
    transform: translateX(-100%); transition: transform .2s ease; z-index: 45; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .nav-backdrop { position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0,0,0,.35); z-index: 44; }
  .nav-backdrop.open { display: block; }
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar .search { display: none; }
  .detail-grid, .row2 { grid-template-columns: 1fr; }
}

/* ---------- Full record page (MiniCRM-style) ---------- */
.rec-back { color: var(--muted); font-size: 13px; margin-bottom: 4px; display: inline-flex; gap: 6px; cursor: pointer; }
.rec-back:hover { color: var(--text); }
.statusflow { display: flex; flex-wrap: wrap; gap: 3px; margin: 8px 0 22px; }
.statusflow .st {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  padding: 9px 20px 9px 26px; font-size: 12.5px; font-weight: 600; cursor: pointer; user-select: none;
  clip-path: polygon(0 0, calc(100% - 13px) 0, 100% 50%, calc(100% - 13px) 100%, 0 100%, 13px 50%);
}
.statusflow .st:first-child { padding-left: 16px; clip-path: polygon(0 0, calc(100% - 13px) 0, 100% 50%, calc(100% - 13px) 100%, 0 100%); }
.statusflow .st:hover { filter: brightness(.97); }
.statusflow .st.done { background: var(--accent-weak); color: var(--accent-dark); border-color: transparent; }
.statusflow .st.current { background: var(--accent); color: #fff; border-color: transparent; }
.statusflow .st.current.won { background: #2f7d32; }
.statusflow .st.current.lost { background: var(--danger); }
.rec-grid { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }
.rec-fields .f { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.rec-fields .f:last-child { border-bottom: none; }
.rec-fields .f .lbl { color: var(--muted); }
.card .pad { padding: 12px 16px; }
@media (max-width: 900px) { .rec-grid { grid-template-columns: 1fr; } }

/* ---------- "+ Új adatlap" dropdown ---------- */
.dd { position: relative; display: inline-block; }
.dd > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.dd > summary::-webkit-details-marker { display: none; }
.dd-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 190px; padding: 6px; z-index: 20; }
.dd-menu button { width: 100%; text-align: left; background: none; border: none; padding: 9px 12px; border-radius: 7px; color: var(--text); font-weight: 500; }
.dd-menu button:hover { background: var(--surface-2); }
