/* Kiküldetés-elszámoló -- palette + theme mirror the fleet dashboard/CRM. */
:root {
  --bg: #faf9f5; --panel: #ffffff; --panel2: #f0eee6; --panel-hover: #f5f4ed;
  --text: #141413; --muted: #87867f; --accent: #d97757; --accent-hover: #c46849;
  --line: #d1cfc5; --ok: #788c5d; --warn: #c08a2d; --bad: #bf4d43;
  --shadow: 0 1px 3px rgba(20,20,19,0.06); --shadow-pop: 0 8px 28px rgba(20,20,19,.14); --ink-soft: #5b5a54;
}
[data-theme="dark"] {
  --bg: #141413; --panel: #1f1e1d; --panel2: #30302e; --panel-hover: #262624;
  --text: #faf9f5; --muted: #73726c; --accent: #d97757; --accent-hover: #c46849;
  --line: #3d3d3a; --ok: #8ba46d; --warn: #d9a441; --bad: #d9695f;
  --shadow: 0 1px 3px rgba(0,0,0,0.25); --shadow-pop: 0 10px 30px rgba(0,0,0,.5); --ink-soft: #c7c6bf;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
.muted { color: var(--muted); font-weight: 400; font-size: .85em; }
a { color: var(--accent); }
button { cursor: pointer; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-size: 14px; transition: .2s ease; }
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border: none; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); color: #fff; }
button.danger { background: #b3261e; border-color: #b3261e; color: #fff; }
button.danger:hover { background: #8f1d17; color: #fff; }
select, input, textarea { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 14px; }
textarea { width: 100%; min-height: 54px; }

/* topbar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.topbar .brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.topbar .brand .co { color: var(--muted); font-weight: 400; font-size: .78em; margin-left: 6px; }
.topbar .grow { flex: 1 1 auto; }
.topbar .cta { border: none; background: var(--accent); color: #fff; font-weight: 600; padding: 9px 15px; border-radius: 9px; white-space: nowrap; }
.topbar .cta:hover { background: var(--accent-hover); color: #fff; }
.menuhost { position: relative; }
.avatar { display: flex; align-items: center; gap: 9px; padding: 5px 6px 5px 5px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); }
.ava { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.avatar .who { font-size: 13px; font-weight: 600; text-align: left; line-height: 1.15; }
.avatar .who small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
.avatar .caret { color: var(--muted); font-size: 10px; margin-right: 4px; }
.menu { position: absolute; z-index: 50; min-width: 214px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 6px; top: calc(100% + 8px); right: 0; }
.menu .mhead { padding: 9px 11px 7px; font-size: 12px; color: var(--muted); }
.menu .mhead b { display: block; color: var(--text); font-size: 14px; }
.menu .msep { height: 1px; background: var(--line); margin: 6px 8px; }
.mrow { display: block; width: 100%; text-align: left; padding: 9px 11px; border-radius: 8px; font-size: 13.5px; color: var(--text); background: transparent; border: none; }
.mrow:hover { background: var(--panel-hover); color: var(--text); }
.mrow.danger { color: var(--bad); }

main { padding: 20px; max-width: 1000px; margin: 0 auto; }

/* list */
.list-search { width: 100%; margin-bottom: 12px; padding: 9px 12px; }
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter.active { border-color: var(--accent); color: var(--accent); }
.trip-list { display: grid; gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; cursor: pointer; box-shadow: var(--shadow); }
.card:hover { border-color: var(--accent); background: var(--panel-hover); }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .row { display: flex; gap: 14px; color: var(--muted); font-size: 13px; flex-wrap: wrap; align-items: center; }
.card .settle { margin-left: auto; color: var(--accent); font-weight: 600; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); }
.pill.draft { color: var(--muted); } .pill.submitted { color: var(--accent); } .pill.closed { color: var(--ok); }

/* detail */
.back { margin-bottom: 14px; }
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.detail-head h2 { margin: 0; font-size: 20px; }
h3.sect { margin: 20px 0 8px; font-size: 15px; border-bottom: 1px solid var(--line); padding-bottom: 5px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 8px; box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 14px; }
.form-grid .field.wide { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.field input, .field select, .field textarea { width: 100%; }
.inline-field { display: inline-flex; flex-direction: column; gap: 2px; }
.inline-field label { font-size: 11px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* line items */
.line-list { display: grid; gap: 4px; margin-bottom: 10px; }
.line { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; background: var(--panel2); }
.line .l-cat { font-weight: 600; min-width: 70px; }
.line .l-desc { flex: 1; }
.line .l-amt { font-variant-numeric: tabular-nums; }
.line .l-pay { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.pay-ceges_bk, .pay-ceges_deviza_bk { color: var(--warn); }
.pay-magan_huf, .pay-magan_deviza { color: var(--accent); }
.pay-elolegbol { color: var(--ok); }
.t-del { padding: 2px 8px; color: var(--bad); border: none; background: transparent; font-size: 16px; line-height: 1; }
.t-del:hover { color: var(--bad); border: none; }
.leg-row { display: grid; grid-template-columns: 1fr 1fr .7fr 1fr 1fr auto; gap: 6px; margin-bottom: 6px; }
.leg-row input { width: 100%; }
.add-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding-top: 10px; border-top: 1px dashed var(--line); }
.huf-out { font-weight: 700; font-variant-numeric: tabular-nums; padding: 6px 0; }

/* summary */
.summary { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 12px; padding: 14px 16px; margin: 16px 0; box-shadow: var(--shadow); }
.summary .s-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.summary .s-row.subtotal { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; font-weight: 600; }
.summary .s-row.muted-row { color: var(--muted); }
.summary .s-row b { font-variant-numeric: tabular-nums; }
.s-net { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 2px solid var(--accent); font-size: 16px; font-weight: 700; }
.s-net b.pos { color: var(--ok); } .s-net b.neg { color: var(--bad); }

/* overlays */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--accent); padding: 10px 16px; border-radius: 8px; z-index: 50; box-shadow: var(--shadow-pop); }
.toast.err { border-color: var(--bad); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 40; }
.modal .sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(440px, 92vw); box-shadow: var(--shadow-pop); }
.modal .sheet h3 { margin-top: 0; }
.modal .sheet input { width: 100%; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.login { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 60; }
.login .sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(420px, 92vw); box-shadow: var(--shadow); }
.login input { width: 100%; margin: 10px 0; }
.login button { width: 100%; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .leg-row { grid-template-columns: 1fr 1fr auto; }
}
