:root { font-family: system-ui, sans-serif; color: #183a36; background: #f3f5f2; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.5rem clamp(1rem, 5vw, 5rem); border-bottom: 1px solid #d6e0da; background: #fff; }
.brand { color: inherit; font-size: 1.35rem; font-weight: 700; text-decoration: none; }
.brand span { font-weight: 400; }
.version { color: #51675e; font-size: .85rem; white-space: nowrap; }
main { width: min(100% - 2rem, 72rem); margin: auto; padding: 2rem 0; }
.welcome { background: #fff; border: 1px solid #d6e0da; border-radius: 1rem; padding: clamp(1.5rem, 6vw, 5rem); }
.eyebrow { font-size: .8rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
h1 { font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.12; max-width: 18ch; margin: 1.25rem 0; }
p { color: #51675e; line-height: 1.7; }
.notice { margin-top: 2rem; border-left: 3px solid #3c7664; background: #edf4ee; padding: 1rem; line-height: 1.5; }
footer { padding: 1.5rem; text-align: center; font-size: .8rem; color: #51675e; }
a:focus-visible { outline: 3px solid #3c7664; outline-offset: 5px; }
@media (max-width: 360px) { header { flex-wrap: wrap; } }
.main-nav { display: flex; gap: 1.5rem; flex-wrap: wrap; padding: 1rem clamp(1rem, 5vw, 5rem); background: #fff; border-bottom: 1px solid #d6e0da; }
.main-nav a, a { color: #245a48; }
.form-card, .panel { background: white; padding: clamp(1.25rem, 4vw, 3rem); border: 1px solid #d6e0da; border-radius: 1rem; }
.form-card { max-width: 38rem; margin: 0 auto; }
.form-card h1, .panel h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); max-width: none; }
form { margin: 1rem 0; }
label { display: block; font-weight: 600; margin: 1rem 0 .4rem; }
input, select { font: inherit; width: 100%; border: 1px solid #869b90; border-radius: .4rem; padding: .8rem; color: #183a36; background: white; }
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid #90bda7; outline-offset: 3px; }
button, .button { display: inline-block; font: inherit; font-weight: 600; cursor: pointer; color: white; background: #245a48; padding: .8rem 1.2rem; border: 1px solid #245a48; border-radius: .4rem; margin-top: 1.2rem; text-decoration: none; }
button.secondary { background: white; color: #245a48; }
header form, header button { margin: 0; }
.errors { background: #fff1ef; color: #853427; border: 1px solid #c87365; border-radius: .4rem; padding: 1rem; margin-bottom: 1rem; }
.errors p { color: inherit; }
main > .notice { margin: 0 0 1rem; }
details { margin-top: 1.5rem; }
summary { cursor: pointer; font-weight: 600; line-height: 1.6; }
.qr { display: block; max-width: 100%; height: auto; margin: 1rem auto; }
.secret { display: block; overflow-wrap: anywhere; margin: 1rem 0; }
.recovery-codes { padding: 1rem 1rem 1rem 2rem; line-height: 2; background: #f3f5f2; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .9rem; border-bottom: 1px solid #d6e0da; vertical-align: top; }
th { background: #edf4ee; }
.pagination { display: flex; gap: 1.5rem; justify-content: center; margin: 1.5rem 0; }
.narrow { max-width: 35rem; }
.system-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.system-grid div { background: #edf4ee; padding: 1rem; border-radius: .5rem; }
dt { color: #51675e; } dd { margin: .5rem 0 0; font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.form-grid, .contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 1rem; }
.contact-grid dd { overflow-wrap: anywhere; white-space: pre-wrap; }
textarea { font: inherit; width: 100%; border: 1px solid #869b90; border-radius: .4rem; padding: .8rem; color: #183a36; resize: vertical; }
textarea:focus-visible { outline: 3px solid #90bda7; outline-offset: 3px; }
.panel h2 { margin-top: 2.5rem; }
small { color: #51675e; }
.check { width: auto; margin-right: .5rem; }
.preserve { white-space: pre-wrap; overflow-wrap: anywhere; }
.order-item { border: 1px solid #b9cec1; border-radius: .5rem; margin: 1.5rem 0; padding: 1rem; }
.item-preview { white-space: pre-wrap; overflow-wrap: anywhere; }
.main-nav form { display: flex; align-items: end; gap: .5rem; margin: 0; }
.main-nav form label { margin: 0; }
.main-nav form input { margin: 0; padding: .45rem; }
.main-nav form button { margin: 0; padding: .45rem .8rem; }
.table-wrap { overflow-x: auto; }
.fulfillment-summary { background: #edf3ef; border: 1px solid #bacdc2; border-radius: .6rem; padding: 1rem; }
.fulfillment-summary progress { width: 100%; height: 1rem; accent-color: #245a48; }
.delivery-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,320px),1fr)); gap: 1rem; }
.delivery-compact { border: 1px solid #bacdc2; border-radius: .5rem; padding: 1rem; overflow-wrap: anywhere; }
.delivery-compact h3 { margin-top: 0; }
.remaining-group { border-left: 3px solid #bacdc2; padding-left: 1rem; }
.process-steps li { margin-bottom: .6rem; }
.issue-blocked-alert { margin: 1.5rem 0 1rem; border: 2px solid #a32626; border-left-width: .5rem; border-radius: .5rem; background: #fff1ef; color: #721c1c; padding: 1rem 1.15rem; }
.issue-blocked-alert p { color: inherit; margin: .45rem 0; }
.issue-blocked-alert a { color: #721c1c; font-weight: 700; }
.issue-blocked-alert__title { display: block; margin-bottom: .7rem; font-size: 1.05rem; letter-spacing: .04em; }
.issue-confirmation--blocked label { color: #65746d; }
.issue-confirmation--blocked input:disabled { cursor: not-allowed; opacity: .65; }
.issue-confirmation--blocked button:disabled { cursor: not-allowed; color: #65746d; background: #e1e6e3; border-color: #b8c5be; opacity: 1; }
input[type="checkbox"] { width: auto; }
#order-customer-section [hidden] { display: none !important; }
.selected-customer-card { border: 2px solid #3c7664; border-radius: .6rem; background: #edf4ee; padding: 1rem 1.25rem; margin: 1.2rem 0; }
.selected-customer-card strong { font-size: 1.05rem; }
.selected-customer-card p { margin: .45rem 0; overflow-wrap: anywhere; }
.selected-customer-card #selected-customer-label { color: #183a36; font-weight: 700; }
.selected-customer-card button { margin-top: .5rem; }
.customer-result { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; border: 1px solid #bacdc2; border-radius: .5rem; padding: .85rem 1rem; margin: .7rem 0; background: #fff; }
.customer-result p { margin: .25rem 0; overflow-wrap: anywhere; }
.customer-result button { margin: 0; white-space: nowrap; }
.module-tabs { display: flex; gap: .35rem; overflow-x: auto; max-width: 100%; border-bottom: 2px solid #bacdc2; margin: 1.3rem 0; padding: .35rem .2rem; }
.module-tabs a { flex: 0 0 auto; padding: .8rem 1rem; color: #245a48; border-radius: .4rem .4rem 0 0; text-decoration: none; }
.module-tabs a[aria-current="page"] { background: #245a48; color: white; font-weight: 700; box-shadow: inset 0 -3px #a6dac0; }
.module-tabs a:focus-visible { outline: 3px solid #245a48; outline-offset: 2px; }
.record-header { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; }
.record-header h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.record-header dl { flex: 1 1 100%; margin: .5rem 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.more-actions { margin: 1rem 0; max-width: 48rem; }
@media (max-width: 600px) {
    header { flex-wrap: wrap; padding: 1rem; }
    .main-nav { gap: .75rem; padding: 1rem; }
    .main-nav form { flex: 1 1 100%; min-width: 0; }
    .main-nav form label { min-width: 0; }
    .module-tabs a { padding: .75rem; }
    .record-header dl { grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
}
.task-list { display: grid; gap: .75rem; margin-top: 1.5rem; }
.task-card { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border: 1px solid #bacdc2; border-radius: .6rem; padding: .9rem 1rem; background: #fff; }
.task-card p { margin: .25rem 0; }
.task-overdue { border-left: 4px solid #b06a45; background: #fff8f3; }
.status-pill { display: inline-block; border-radius: 99px; padding: .3rem .65rem; background: #edf4ee; color: #245a48; font-size: .85rem; font-weight: 700; }
.status-pill.overdue { background: #fff0e8; color: #853f25; }
.task-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.task-actions form, .task-actions button, .task-actions .button { margin: 0; }
.task-history { border-left: 3px solid #bacdc2; padding: .4rem 1rem; }
.nav-badge { display: inline-block; min-width: 1.4rem; padding: .1rem .35rem; border-radius: 99px; background: #853f25; color: white; text-align: center; font-size: .75rem; }
.notification-unread { border-left: 4px solid #245a48; background: #edf4ee; }
.calendar-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1rem 0; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(8rem, 1fr)); overflow-x: auto; border: 1px solid #d6e0da; }
.calendar-day { min-height: 9rem; padding: .55rem; border-right: 1px solid #d6e0da; border-bottom: 1px solid #d6e0da; background: white; }
.calendar-day h2 { margin: 0 0 .5rem; font-size: .9rem; }
.calendar-day h2 span { font-weight: 400; }
.calendar-outside { background: #f3f5f2; opacity: .75; }
.calendar-today { box-shadow: inset 0 0 0 2px #3c7664; }
.calendar-task { display: block; margin: .3rem 0; padding: .4rem; border-radius: .35rem; background: #edf4ee; text-decoration: none; font-size: .82rem; overflow-wrap: anywhere; }
.calendar-task small { display: block; }
.calendar-empty { margin: .25rem; }
@media (max-width: 700px) { .task-card { align-items: flex-start; flex-direction: column; } .calendar-grid { grid-template-columns: repeat(7, minmax(7rem, 1fr)); } .calendar-nav { flex-wrap: wrap; } }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 1rem; margin: 1.25rem 0; }
.metric { display: flex; flex-direction: column; gap: .45rem; border: 1px solid #bacdc2; border-radius: .7rem; padding: 1rem; background: #f8fbf9; }
.metric > span { color: #51675e; font-weight: 650; }
.metric > strong { color: #183a36; font-size: 1.45rem; }
.metric-inline strong { color: #183a36; font-size: 1.35rem; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 1rem; margin: 1.25rem 0; }
.dashboard-card { border: 1px solid #d6e0da; border-radius: .7rem; padding: 1rem 1.2rem; background: #fff; }
.dashboard-card h2 { margin-top: .2rem; }
.metric-list { list-style: none; padding: 0; margin: 0; }
.metric-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid #e6ece8; }
.metric-list strong { font-size: 1.1rem; }
.compact-row { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid #e6ece8; }
.report-filters { background: #f8fbf9; border: 1px solid #d6e0da; border-radius: .7rem; padding: 1rem; }
.report-filters label { margin-top: .2rem; }
.filter-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.filter-actions button, .filter-actions .button { margin-top: .7rem; }
@media (max-width: 600px) { .metric-grid, .dashboard-grid { grid-template-columns: 1fr; } .compact-row { flex-direction: column; gap: .2rem; } }

/* M12: wspólny, responsywny szkielet aplikacji */
.topbar { position: sticky; top: 0; z-index: 40; padding: .8rem clamp(1rem, 3vw, 2rem); }
.app-shell { flex: 1; display: flex; min-width: 0; }
.content-shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content-shell main { flex: 1; margin: 0 auto; }
.sidebar { flex: 0 0 16rem; width: 16rem; border-right: 1px solid #d6e0da; background: #fff; transition: width .15s ease, transform .15s ease; }
.sidebar-inner { position: sticky; top: 4.2rem; display: flex; flex-direction: column; gap: .65rem; padding: .75rem; max-height: calc(100vh - 4.2rem); overflow-y: auto; }
.main-nav { display: flex; flex-direction: column; flex-wrap: nowrap; gap: .25rem; padding: .65rem 0 0; border: 0; border-top: 1px solid #d6e0da; }
.main-nav a { display: flex; align-items: center; gap: .7rem; min-height: 2.75rem; padding: .55rem .7rem; border-radius: .45rem; text-decoration: none; }
.main-nav a:hover, .main-nav a[aria-current="location"] { background: #edf4ee; font-weight: 700; }
.nav-icon { display: inline-flex; flex: 0 0 2rem; width: 2rem; min-height: 2rem; align-items: center; justify-content: center; border-radius: .4rem; background: #edf4ee; color: #245a48; font-size: .78rem; font-weight: 800; }
.nav-toggle { display: none; margin: 0; min-width: 2.75rem; min-height: 2.75rem; padding: .5rem .7rem; }
.desktop-nav-toggle { display: flex; align-items: center; gap: .7rem; width: 100%; margin: 0 0 .4rem; min-height: 2.75rem; }
.mobile-nav-close { display: none; }
.nav-search { display: grid !important; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .35rem !important; padding-bottom: .2rem; }
.nav-search label { min-width: 0; }
.nav-search button { min-height: 2.75rem; }
.nav-overlay { display: none; }
.nav-collapsed .sidebar { flex-basis: 4.5rem; width: 4.5rem; }
.nav-collapsed .sidebar .nav-label, .nav-collapsed .nav-search { display: none; }
.nav-collapsed .main-nav a, .nav-collapsed .desktop-nav-toggle { justify-content: center; padding-inline: .35rem; }
.nav-collapsed .nav-badge { position: absolute; margin: -1.8rem 0 0 1.7rem; }

button, .button, input, select, textarea, summary { min-height: 2.75rem; }
input[type="checkbox"], input[type="radio"] { min-width: 1.3rem; min-height: 1.3rem; }
table { min-width: 38rem; }
.table-scroll, .table-wrap, .panel { max-width: 100%; }
.pagination { flex-wrap: wrap; }
.private-upload { border: 1px solid #bacdc2; border-radius: .6rem; padding: 1rem; background: #f8fbf9; }
.upload-status { min-height: 1.5rem; }
.scan-order { display: grid; gap: .5rem; margin: 0; padding-left: 1.4rem; }
.scan-order:empty { display: none; }
.scan-order li { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.scan-order li span { margin-right: auto; overflow-wrap: anywhere; }
.attachment-list { display: grid; gap: .75rem; margin: 1rem 0; }
.attachment-card { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border: 1px solid #d6e0da; border-radius: .6rem; padding: 1rem; overflow-wrap: anywhere; }
.attachment-card p { margin: .25rem 0; }
.attachment-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .4rem; }
.attachment-actions .button, .attachment-actions button, .attachment-actions form { margin: 0; }
.compact-details { margin: 0; }
.admin-actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 1rem; margin: 1rem 0 1.5rem; }
.status-ok { color: #176b45; font-weight: 700; }
.status-warning { color: #895b00; font-weight: 700; }
.status-error { color: #a32626; font-weight: 700; }
.system-grid dd small { display: block; margin-top: .25rem; font-weight: 400; }

@media (max-width: 800px) {
    .topbar { flex-wrap: nowrap; }
    .topbar .version { display: none; }
    .nav-toggle { display: inline-flex; align-items: center; gap: .4rem; }
    .sidebar { position: fixed; z-index: 60; inset: 0 auto 0 0; width: min(86vw, 19rem); transform: translateX(-105%); box-shadow: .5rem 0 1.5rem rgb(24 58 54 / 20%); }
    .sidebar-inner { position: static; max-height: 100vh; min-height: 100%; padding-top: 0; }
    .main-nav { padding-top: .65rem; }
    .mobile-nav-close { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; gap: .5rem; width: 100%; margin: 0; background: #fff; }
    .desktop-nav-toggle { display: none; }
    .mobile-nav-open { overflow: hidden; }
    .mobile-nav-open .sidebar { transform: translateX(0); }
    .nav-overlay { position: fixed; z-index: 50; inset: 0; width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0; background: rgb(24 58 54 / 45%); }
    .mobile-nav-open .nav-overlay { display: block; }
    .nav-collapsed .sidebar { width: min(86vw, 19rem); }
    .nav-collapsed .sidebar .nav-label { display: inline; }
    .nav-collapsed .nav-search { display: grid !important; }
    main { width: min(100% - 1rem, 72rem); padding: 1rem 0; }
    .panel, .form-card { padding: 1rem; border-radius: .65rem; }
    .form-grid, .contact-grid { grid-template-columns: 1fr; }
    .filter-actions, .task-actions, .attachment-card, .attachment-actions { flex-direction: column; align-items: stretch; }
    .filter-actions > *, .task-actions > *, .attachment-actions > * { width: 100%; }
    .button, button { text-align: center; }
    .calendar-nav > * { flex: 1 1 auto; }
}

@media (max-width: 390px) {
    .brand { font-size: 1.05rem; }
    .topbar { gap: .5rem; }
    .nav-toggle-label { display: none; }
    h1 { font-size: 1.75rem; }
    th, td { padding: .7rem; }
}
