:root {
  --green: #235E3F; --green-2: #2f7a52; --red: #E12A2F; --dark: #111827; --panel: #1f2937; --line: #374151;
  --muted: #9ca3af; --text: #e5e7eb; --bg: #0f172a; --ok: #4ade80;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 'Inter', 'Segoe UI', Arial, sans-serif; -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: #86efac; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; background: #1A1A1A; border-bottom: 1px solid #262626; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.topbar .in { max-width: 1500px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand .e { 
    /*width: 30px;*/
    /*height: 30px;*/
    padding:10px;
    border-radius: 6px;
    background: var(--text);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 16px;
}
.brand b { display: block; font-size: 13px; }
.brand small { color: var(--muted); font-size: 11px; }
nav.main { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
nav.main a { color: #d1d5db; padding: 7px 11px; border-radius: 7px; font-weight: 600; font-size: 12.5px; }
nav.main a:hover { background: #262626; text-decoration: none; }
nav.main a.on { background: var(--green); color: #fff; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }

/* ---------- layout ---------- */
.page { max-width: 1500px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 19px; color: #fff; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.card h2 { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ok); margin-bottom: 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 22px; font-weight: 800; color: #fff; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }

/* ---------- buttons & inputs ---------- */
.btn { border: 1px solid var(--line); background: #1f2937; color: var(--text); font: 600 12px 'Inter', sans-serif; padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #374151; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-2); }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.red:hover { background: #b91c1c; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 11.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], textarea, select {
  width: 100%; background: var(--dark); border: 1px solid var(--line); color: #fff; border-radius: 7px; padding: 7px 9px;
  font: 12.5px 'Inter', sans-serif; outline: none; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--green); }
input:disabled, textarea:disabled, select:disabled { opacity: .7; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters > * { width: auto; min-width: 150px; }
.filters input[type=text] { min-width: 240px; }

/* ---------- tables ---------- */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); font-weight: 700; }
table.list td { padding: 9px 10px; border-bottom: 1px solid #263041; vertical-align: top; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #243041; }
table.list .r { text-align: right; font-variant-numeric: tabular-nums; }
table.list .muted, .muted { color: var(--muted); }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #374151; color: #e5e7eb; }
.st-draft { background: #374151; } .st-issued { background: #1e3a8a; color: #bfdbfe; } .st-sent { background: #3730a3; color: #c7d2fe; }
.st-accepted { background: #14532d; color: #bbf7d0; } .st-rejected { background: #7f1d1d; color: #fecaca; } .st-paid { background: #166534; color: #dcfce7; }
.st-partially_paid { background: #78350f; color: #fde68a; } .st-cancelled { background: #450a0a; color: #fca5a5; text-decoration: line-through; }
.st-active { background: #14532d; color: #bbf7d0; } .st-archived { background: #374151; color: #9ca3af; } .st-tender { background: #1e3a8a; color: #bfdbfe; }
.st-open, .st-in_progress { background: #1e3a8a; color: #bfdbfe; } .st-completed { background: #14532d; color: #bbf7d0; } .st-closed { background: #374151; }
.type { font-weight: 700; color: #fff; }
.type small { display: block; color: var(--muted); font-weight: 500; }

/* ---------- document editor ---------- */
.editor { display: flex; gap: 20px; align-items: flex-start; }
.ed-panel { width: 400px; flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; position: sticky; top: 64px;
  max-height: calc(100vh - 80px); overflow: auto; }
.ed-panel h2 { margin: 0 0 8px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ok); }
.ed-panel h2:not(:first-child) { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.ed-panel label { display: block; color: var(--muted); font-weight: 500; margin: 7px 0 3px; font-size: 12px; }
.ed-panel .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ed-panel .row4 { display: grid; grid-template-columns: .8fr .9fr 1.1fr 1.3fr; gap: 6px; }
.ed-panel .chk { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; color: var(--muted); }
.ed-panel .chk input { width: 16px; height: 16px; accent-color: var(--green); }
.itemcard { background: var(--dark); border: 1px solid var(--line); border-radius: 8px; padding: 9px; margin-bottom: 9px; }
.itemcard .hd { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.itemcard .hd b { color: var(--ok); font-size: 11px; }
.mini { border: 0; background: #374151; color: #e5e7eb; width: 24px; height: 24px; border-radius: 5px; cursor: pointer; font-size: 12px; margin-left: 3px; }
.mini:hover { background: #4b5563; }
.mini.del:hover { background: #b91c1c; }
.addbtn { width: 100%; padding: 8px; border: 1px dashed #4b5563; background: transparent; color: var(--text); border-radius: 8px; cursor: pointer; font: 600 12px 'Inter', sans-serif; }
.addbtn:hover { background: var(--dark); }
.hint { color: var(--muted); font-size: 11px; line-height: 1.5; margin-top: 6px; }
.hint code { background: var(--dark); padding: 1px 4px; border-radius: 3px; color: var(--text); }
.ed-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.saving { font-size: 11px; color: var(--muted); }
.ed-totals { margin-top: 10px; background: var(--dark); border-radius: 8px; padding: 10px; font-variant-numeric: tabular-nums; }
.ed-totals div { display: flex; justify-content: space-between; padding: 2px 0; }
.ed-totals .g { color: var(--ok); font-weight: 800; font-size: 14px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; }
.chain { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chain a { background: var(--dark); border: 1px solid var(--line); padding: 3px 8px; border-radius: 6px; font-size: 11.5px; }
.pages { flex: 1; min-width: 0; overflow-x: auto; display: flex; flex-direction: column; align-items: center; gap: 10mm; padding-bottom: 20px; }
.dropdown { position: relative; display: inline-block; }
.dropdown .menu { display: none; position: absolute; right: 0; top: 100%; margin-top: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  min-width: 220px; z-index: 30; box-shadow: 0 10px 30px rgba(0,0,0,.4); padding: 4px; }
.dropdown.open .menu { display: block; }
.dropdown .menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 8px 10px; border-radius: 6px; cursor: pointer; font: 12.5px 'Inter', sans-serif; }
.dropdown .menu button:hover { background: #374151; }
@media (max-width: 1100px) { .editor { flex-direction: column; } .ed-panel { width: 100%; position: static; max-height: none; } }

/* ---------- modal & toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal.wide { width: min(820px, 100%); }
.modal h3 { font-size: 15px; color: #fff; margin-bottom: 14px; }
.modal .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.modal label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
.modal label.span2 { grid-column: span 2; }
.modal label.chk { flex-direction: row; align-items: center; gap: 8px; }
.modal label.chk input { width: 16px; height: 16px; accent-color: var(--green); }
.modal small { color: #6b7280; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.confirm-text { margin: 0; font-size: 14px; color: #fff; line-height: 1.5; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 200; background: var(--green); color: #fff; padding: 10px 16px; border-radius: 9px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); opacity: 0; transform: translateY(10px); transition: .25s; max-width: 420px; }
.toast.err { background: #b91c1c; }
.toast.show { opacity: 1; transform: none; }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth form { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px; }
.auth img { width: 160px; display: block; margin: 0 auto 14px; background: #fff; border-radius: 8px; padding: 8px 12px; }
.auth h1 { font-size: 16px; text-align: center; color: #fff; margin-bottom: 4px; }
.auth p { text-align: center; color: var(--muted); margin: 0 0 18px; }
.auth label { display: block; color: var(--muted); font-size: 12px; margin: 10px 0 4px; }
.auth .btn { width: 100%; margin-top: 18px; padding: 10px; }
.auth .err { color: #fca5a5; text-align: center; margin-top: 10px; min-height: 18px; }

@media print {
  body { background: #fff !important; }
  .topbar, .ed-panel, .no-print, .page-head { display: none !important; }
  .page { padding: 0 !important; max-width: none !important; }
  .editor { display: block !important; }
  .pages { display: block !important; overflow: visible !important; gap: 0 !important; padding: 0 !important; }
}

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
@media (max-width: 700px) { .settings-grid, .modal .grid2 { grid-template-columns: 1fr; } .modal label.span2 { grid-column: auto; } }
