/* ===========================================================
   MarketEye — Giełda zamówień
   Biały korporacyjny SaaS. Brand: granat #052c5a, błękit #2E6FBE,
   cyjan #18BAE5, pomarańcz #EE7A0E. Fonty: Poppins + Mulish.
   =========================================================== */

:root {
    --navy:        #052c5a;
    --navy-700:    #0a3a72;
    --blue:        #2E6FBE;
    --blue-600:    #2560a8;
    --cyan:        #18BAE5;
    --orange:      #ee7a0e;
    --orange-lo:   #f6a118;
    --orange-hi:   #e16510;

    --ink:         #0b2b4e;
    --ink-2:       #47617c;
    --ink-3:       #8397ac;

    --bg:          #f3f6fb;
    --surface:     #ffffff;
    --surface-2:   #f8fafd;
    --line:        #e5edf6;
    --line-2:      #eef3f9;

    --success:     #1e9e6a;
    --success-bg:  #e6f6ef;
    --warn:        #e0910c;
    --warn-bg:     #fdf3e1;
    --danger:      #e0454a;
    --danger-bg:   #fdeceb;
    --info-bg:     #e9f1fb;

    --r-lg: 16px;
    --r-md: 11px;
    --r-sm: 8px;

    --shadow-sm: 0 1px 2px rgba(5,44,90,.06), 0 1px 3px rgba(5,44,90,.04);
    --shadow-md: 0 4px 16px rgba(5,44,90,.08);
    --shadow-lg: 0 12px 40px rgba(5,44,90,.14);

    --sidebar-w: 248px;
    --font: 'Mulish', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-head: 'Poppins', var(--font);
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { font-family: var(--font-head); color: var(--navy); margin: 0; font-weight: 600; letter-spacing: -.01em; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-600); }
.mono { font-family: var(--font-mono); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    z-index: 40;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 22px 18px;
}
.sidebar-brand img { height: 30px; width: auto; }
.nav { padding: 10px 12px; flex: 1; overflow-y: auto; }
.nav-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
    color: var(--ink-3); font-weight: 700; padding: 14px 12px 6px;
}
.nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: var(--r-md);
    color: var(--ink-2); font-weight: 600; font-size: 14px;
    margin-bottom: 2px; transition: background .12s, color .12s;
}
.nav a svg { width: 18px; height: 18px; flex: 0 0 18px; stroke-width: 2; }
.nav a:hover { background: var(--surface-2); color: var(--navy); }
.nav a.active { background: var(--info-bg); color: var(--navy); }
.nav a.active svg { color: var(--blue); }
.nav a .badge-count {
    margin-left: auto; background: var(--blue); color: #fff;
    font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px;
}
.sidebar-foot { border-top: 1px solid var(--line); padding: 14px; }
.logout-link { display: flex; align-items: center; gap: 11px; padding: 9px 12px; color: var(--ink-2); font-weight: 600; border-radius: var(--r-md); font-size: 14px; }
.logout-link:hover { background: var(--surface-2); color: var(--danger); }
.logout-link svg { width: 18px; height: 18px; flex: 0 0 18px; stroke-width: 2; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--navy), var(--blue));
    color: #fff; display: grid; place-items: center;
    font-weight: 700; font-family: var(--font-head); font-size: 13px;
}
.user-chip .u-name { font-weight: 700; font-size: 13px; color: var(--navy); line-height: 1.2; }
.user-chip .u-role { font-size: 11.5px; color: var(--ink-3); text-transform: capitalize; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 62px; background: rgba(255,255,255,.82); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 16px; padding: 0 26px;
    position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 19px; }
.topbar .sub { color: var(--ink-3); font-size: 13px; }
.topbar-spacer { flex: 1; }
.content { padding: 26px; flex: 1; }
.content.flush { padding: 0; }

.hamburger { display: none; background: none; border: 0; cursor: pointer; color: var(--navy); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: var(--font); font-weight: 700; font-size: 14px;
    padding: 10px 18px; border-radius: var(--r-md); border: 1px solid transparent;
    cursor: pointer; transition: transform .05s, box-shadow .15s, background .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: linear-gradient(135deg, var(--orange-lo), var(--orange-hi)); color: #fff; box-shadow: 0 4px 12px rgba(225,101,16,.28); }
.btn-primary:hover { box-shadow: 0 6px 18px rgba(225,101,16,.36); color:#fff; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-700); color:#fff; }
.btn-ghost { background: var(--surface); color: var(--navy); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line-2); }
.card-head h3 { font-size: 15.5px; }
.card-head .spacer { flex: 1; }

/* KPI grid */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; margin-bottom: 22px; }
.kpi {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
    padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi::before { content:''; position:absolute; left:0; top:0; bottom:0; width:3px; background: var(--blue); }
.kpi.k-orange::before { background: var(--orange); }
.kpi.k-cyan::before { background: var(--cyan); }
.kpi.k-green::before { background: var(--success); }
.kpi .k-label { font-size: 12.5px; color: var(--ink-3); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kpi .k-value { font-family: var(--font-head); font-weight: 700; font-size: 30px; color: var(--navy); line-height: 1.1; margin-top: 6px; }
.kpi .k-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }

/* ---------- Forms ---------- */
.fg { margin-bottom: 14px; }
.fg label { display: block; font-weight: 700; font-size: 13px; color: var(--navy); margin-bottom: 6px; }
.fg label small { font-weight: 500; color: var(--ink-3); }
input, select, textarea {
    width: 100%; font-family: var(--font); font-size: 14px; color: var(--ink);
    padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface); transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(46,111,190,.14);
}
textarea { resize: vertical; }
.hint { font-size: 12.5px; color: var(--ink-3); }

/* ---------- Badges / status ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.st-nowe       { background: var(--info-bg); color: var(--blue-600); }
.st-wycenione  { background: var(--warn-bg); color: var(--warn); }
.st-realizacja { background: #eae7fb; color: #6b57d6; }
.st-zrobione   { background: var(--success-bg); color: var(--success); }
.st-anulowane  { background: var(--danger-bg); color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
    text-align: left; font-weight: 700; color: var(--ink-3); font-size: 12px;
    text-transform: uppercase; letter-spacing: .04em; padding: 12px 16px; border-bottom: 1px solid var(--line);
}
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }

/* ---------- Checkmark stepper (SYGNATURA — echo ptaszka z logo) ---------- */
.stepper { display: flex; align-items: flex-start; gap: 0; margin: 8px 0; }
.step { flex: 1; text-align: center; position: relative; }
.step:not(:last-child)::after {
    content:''; position: absolute; top: 17px; left: 50%; width: 100%; height: 2px; background: var(--line);
}
.step.done:not(:last-child)::after { background: var(--success); }
.step .dot {
    width: 36px; height: 36px; border-radius: 50%; margin: 0 auto 8px; position: relative; z-index: 1;
    background: var(--surface); border: 2px solid var(--line); display: grid; place-items: center;
    color: var(--ink-3); font-weight: 700;
}
.step.done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.step.current .dot { border-color: var(--orange); color: var(--orange); box-shadow: 0 0 0 4px var(--warn-bg); }
.step .s-label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.step.done .s-label, .step.current .s-label { color: var(--navy); }
.step .dot svg { width: 18px; height: 18px; stroke-width: 3; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content:''; position: absolute; left: 4px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.timeline li::after { content:''; position: absolute; left: 8px; top: 14px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .t-status { font-weight: 700; color: var(--navy); }
.timeline .t-meta { font-size: 12.5px; color: var(--ink-3); }

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--navy); color: #fff; padding: 12px 20px; border-radius: var(--r-md);
    box-shadow: var(--shadow-lg); font-weight: 600; opacity: 0; pointer-events: none;
    transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* ---------- Multiselect ---------- */
.ms { position: relative; }
.ms-control { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 5px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); cursor: pointer; }
.ms-control:hover { border-color: var(--ink-3); }
.ms.open .ms-control { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(46,111,190,.14); }
.ms-label { flex: 1; font-size: 13.5px; color: var(--ink); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ms-label .ms-ph { color: var(--ink-3); }
.ms-chip { background: var(--info-bg); color: var(--blue-600); border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.ms-chip b { cursor: pointer; opacity: .7; }
.ms-chip b:hover { opacity: 1; }
.ms-more { background: var(--surface-2); color: var(--ink-2); border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 700; }
.ms-caret { width: 16px; height: 16px; color: var(--ink-3); flex: 0 0 16px; }
.ms-pop { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 8px; max-height: 300px; display: flex; flex-direction: column; }
.ms-pop[hidden] { display: none; }
.ms-q { margin-bottom: 6px; }
.ms-opts { overflow-y: auto; }
.ms-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; font-size: 13.5px; }
.ms-opt:hover { background: var(--surface-2); }
.ms-opt input { width: auto; }
.ms-opt em { margin-left: auto; font-style: normal; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.ms-empty { padding: 10px; color: var(--ink-3); font-size: 13px; text-align: center; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(5,44,90,.4); backdrop-filter: blur(2px); z-index: 200; display: none; align-items: center; justify-content: center; padding: 24px; }
.modal-overlay.show { display: flex; }
.modal-card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 860px; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { padding: 16px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.modal-head h3 { font-size: 17px; }
.modal-head .spacer { flex: 1; }
.modal-close { background: none; border: 0; cursor: pointer; color: var(--ink-3); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--surface-2); color: var(--navy); }
.modal-body { padding: 0; overflow-y: auto; flex: 1; }
.modal-toolbar { padding: 12px 22px; border-bottom: 1px solid var(--line-2); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-toolbar input { max-width: 260px; }
.pt-add { background: var(--info-bg); color: var(--blue-600); border: 1px solid transparent; border-radius: var(--r-sm); font-weight: 700; font-size: 12.5px; padding: 5px 11px; cursor: pointer; white-space: nowrap; }
.pt-add:hover { border-color: var(--blue); }
.pt-add.on { background: var(--success-bg); color: var(--success); }
.mini-logo { width: 26px; height: 26px; object-fit: contain; vertical-align: middle; }
@media (max-width: 700px) { .modal-card { max-height: 92vh; } .modal-overlay { padding: 10px; } }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty svg { width: 44px; height: 44px; margin-bottom: 12px; color: var(--line); }
.empty h3 { color: var(--ink-2); font-size: 16px; margin-bottom: 4px; }

/* ---------- Utilities ---------- */
.row { display: flex; gap: 16px; }
.row > * { flex: 1; }
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}
.mb-0{margin-bottom:0}.mb-2{margin-bottom:16px}
.muted { color: var(--ink-3); }
.strong { font-weight: 700; color: var(--navy); }
.text-sm { font-size: 13px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .hamburger { display: inline-flex; }
    .content { padding: 18px; }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(5,44,90,.4); z-index: 39; }
}
