:root {
  --blue: #2f5aae; --blue-d: #24478c; --blue-l: #eef3fc; --ink: #1d2330; --muted: #5d6677; --line: #e1e4ea; --bg: #f4f5f7; --card: #fff;
  --ok: #1f7a4d; --ok-bg: #e3f3ea; --warn: #8a5300; --warn-bg: #fdf0d9; --red: #b3261e; --red-bg: #fde6e4; --grey-bg: #eceef2;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace; --sans: 'IBM Plex Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.5 var(--sans); color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #1d2330 0%, #24478c 100%); }
.login form { background: #fff; width: 380px; max-width: 100%; padding: 34px; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login img { height: 32px; width: auto; margin-bottom: 24px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 22px; }

label.f { display: block; font-weight: 500; margin-bottom: 12px; }
label.f > span { display: block; margin-bottom: 4px; font-size: 13px; }
label.f small { color: var(--muted); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #c8ced8; border-radius: 4px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b9cbee; border-color: var(--blue); }
input:disabled { background: var(--bg); color: var(--muted); }
textarea { resize: vertical; min-height: 120px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 5px; border: 1px solid var(--blue); background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--blue-d); }
.btn.ghost { background: #fff; color: var(--blue); }
.btn.plain { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.plain:hover { background: var(--bg); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.danger { background: #fff; color: var(--red); border-color: #efc3bf; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.full { width: 100%; justify-content: center; padding: 11px; }
.btn:disabled { opacity: .5; cursor: progress; }
.iconbtn { border: 1px solid var(--line); background: #fff; border-radius: 4px; width: 28px; height: 28px; cursor: pointer; color: var(--muted); }
.iconbtn:hover { background: var(--bg); color: var(--ink); }

.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--ink); color: #c9cfdb; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.sidebar .brand { display: flex; gap: 10px; align-items: center; padding: 4px 10px 20px; }
.sidebar .brand img { height: 26px; width: auto; filter: brightness(0) invert(1); }
.sidebar .brand small { display: block; font: 400 11px var(--mono); color: #8a93a6; }
.sidebar nav a { display: flex; align-items: center; justify-content: space-between; color: #c9cfdb; text-decoration: none; padding: 9px 10px; border-radius: 5px; margin-bottom: 2px; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); }
.sidebar nav a.on { background: var(--blue); color: #fff; }
.sidebar .group { font: 500 10px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: #6c7586; padding: 14px 10px 6px; }
.badge { background: #e2574c; color: #fff; font: 600 11px var(--mono); padding: 1px 7px; border-radius: 10px; }
.sidebar .foot { margin-top: auto; font-size: 13px; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar .foot a { color: #c9cfdb; display: block; padding: 3px 0; }
.sidebar .user { color: #fff; font-weight: 600; margin-bottom: 6px; }
.sidebar .user small { display: block; font-weight: 400; color: #8a93a6; }
main { padding: 26px 30px 70px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { font-size: 22px; margin: 0; }
.head p { margin: 2px 0 0; color: var(--muted); }
.head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.card > h3 { margin: 0; padding: 14px 16px 0; font-size: 14px; display: flex; justify-content: space-between; }
.card .body { padding: 16px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi { padding: 16px; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .v { font: 600 28px var(--mono); margin-top: 2px; }
.kpi .d { font-size: 12px; color: var(--muted); }
.kpi .d.up { color: var(--ok); }
.kpi .d.down { color: var(--red); }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.chartbox { position: relative; height: 260px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; font-weight: 500; }
.seg button.on { background: var(--ink); color: #fff; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; font-weight: 600; }
.tbl th.nc { text-transform: none; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #f7f9fd; }
.tbl tr.sel td { background: var(--blue-l); }
.tbl tr.unseen td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.tbl .sub { color: var(--muted); font-size: 13px; }
.scroll { overflow-x: auto; }
.thumb { width: 52px; height: 40px; object-fit: cover; border-radius: 4px; display: block; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.pill.uj { background: var(--blue-l); color: var(--blue); }
.pill.folyamatban { background: var(--warn-bg); color: var(--warn); }
.pill.postazva, .pill.ajanlat { background: var(--ok-bg); color: var(--ok); }
.pill.lezarva { background: var(--grey-bg); color: var(--muted); }
.pill.minta { background: #f2ebf7; color: #6b3d86; }
.pill.ajanlatkeres { background: #fbeeed; color: #8d342d; }
.pill.auto { background: var(--warn-bg); color: var(--warn); }
.pill.docs { background: #e8f1fb; color: #2a5c8f; }
.lang { font: 600 11px var(--mono); text-transform: uppercase; background: var(--grey-bg); padding: 2px 6px; border-radius: 3px; }

.tbl td.who { min-width: 200px; }
.inbox { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 14px; align-items: start; }
.toolbar { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.toolbar input[type=text] { width: 230px; }
.toolbar select { width: auto; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); }
.detail { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.detail .sec { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.detail .sec:last-child { border-bottom: 0; }
.detail h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.items div { font-family: var(--mono); font-size: 13px; padding: 3px 0; }
.timeline { font-size: 12.5px; }
.timeline div { padding: 5px 0 5px 14px; border-left: 2px solid var(--line); margin-left: 4px; position: relative; }
.timeline div::before { content: ''; position: absolute; left: -5px; top: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.timeline div.mail::before { background: var(--ok); }
.timeline div.note::before { background: var(--warn); }
.timeline b { font-weight: 500; }
.timeline .meta { color: var(--muted); font-size: 11.5px; }
.timeline div.note .txt { background: var(--warn-bg); padding: 6px 8px; border-radius: 4px; margin-top: 3px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.mailedit { border: 1px solid var(--line); border-radius: 6px; margin-top: 10px; overflow: hidden; }
.mailedit input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; font-weight: 600; }
.mailedit textarea { border: 0; border-radius: 0; min-height: 200px; font-size: 13px; line-height: 1.55; }
.mailedit .meta { padding: 6px 10px; background: #fafbfc; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.toggle { position: relative; width: 36px; height: 20px; display: inline-block; vertical-align: middle; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: #c8ced8; border-radius: 20px; cursor: pointer; transition: .15s; }
.toggle span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; }
.toggle input:checked + span { background: var(--ok); }
.toggle input:checked + span::before { transform: translateX(16px); }
.toggle input:disabled + span { opacity: .5; cursor: default; }
.langdots { display: flex; gap: 3px; }
.langdots i { font: 600 10px var(--mono); font-style: normal; padding: 1px 4px; border-radius: 3px; background: var(--ok-bg); color: var(--ok); text-transform: uppercase; }
.langdots i.miss { background: var(--red-bg); color: var(--red); }

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 4px 0 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; font-weight: 600; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.tabs button.on { border-color: var(--blue); color: var(--ink); }
.tabs button .dot { color: var(--red); }
.imgpick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.imgpick button { border: 2px solid transparent; padding: 0; border-radius: 5px; overflow: hidden; cursor: pointer; aspect-ratio: 4 / 3; background: var(--bg); }
.imgpick button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.imgpick button.on { border-color: var(--blue); }
.preview-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; margin-bottom: 10px; border: 1px solid var(--line); }
.vt input[type=number] { width: 80px; }
.vt input[type=text] { min-width: 140px; }
.vars { font: 12px var(--mono); color: var(--muted); margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.vars code { background: var(--bg); padding: 2px 6px; border-radius: 3px; cursor: pointer; border: 1px solid var(--line); }
.vars code:hover { border-color: var(--blue); color: var(--blue); }
.tplgrid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: start; }
.tpllist a { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; }
.tpllist a:hover { background: #fafbfc; }
.tpllist a.on { background: var(--blue-l); }
.tpllist a small { display: block; color: var(--muted); margin-top: 2px; }
.tpllist .grp { padding: 10px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #fafbfc; border-bottom: 1px solid var(--line); }
.bar { height: 6px; background: var(--grey-bg); border-radius: 3px; overflow: hidden; width: 120px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.bar i { display: block; height: 100%; background: var(--ok); }
.bar i.part { background: #e0a030; }
.opttbl input[type=text] { min-width: 150px; }
.mailbody { white-space: pre-wrap; font: 13px/1.55 var(--sans); background: #fafbfc; padding: 12px; border-radius: 5px; margin: 6px 0 0; }

.toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 6px; box-shadow: 0 8px 30px rgba(0,0,0,.2); max-width: 380px; animation: tin .2s ease-out; }
.toast b { color: #8fd3ae; }
.toast.err { background: #8c1d18; }
.toast.err b { color: #fff; }
.toast a { color: #b9cbee; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, 1fr); } .grid3 { grid-template-columns: 1fr; } }
@media (max-width: 1100px) {
  .inbox, .tplgrid, .editor { grid-template-columns: 1fr; }
  .detail { position: static; max-height: none; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 10px; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar .brand, .sidebar .group, .sidebar .foot { display: none; }
  main { padding: 18px 16px 50px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .toolbar input[type=text] { width: 100%; }
}
