:root {
    --ink: #16213a;
    --ink-soft: #5b6478;
    --ink-faint: #8a93a6;
    --navy: #1d3e8a;
    --navy-deep: #142d66;
    --navy-wash: #e9eef9;
    --paper: #f4f6f9;
    --surface: #ffffff;
    --line: #dde1e8;
    --line-soft: #ebeef3;
    --ok: #1f7a4d;
    --ok-wash: #e4f3eb;
    --wait: #a35f00;
    --wait-wash: #fbf0dc;
    --bad: #b3261e;
    --bad-wash: #fbe7e5;
    --info: #2d5fc4;
    --info-wash: #e6edfb;
    --radius-s: 6px;
    --radius: 10px;
    --radius-l: 16px;
    --tap: 44px;
    --nav-h: 64px;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body.pls {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}

.pls a:not([class]) { color: var(--navy); }
.pls h1, .pls h2, .pls h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
.pls h1 { font-size: 22px; font-weight: 700; }
.pls h2 { font-size: 17px; font-weight: 650; }
.pls h3 { font-size: 15px; font-weight: 650; }
.pls p { margin: 0 0 12px; }

.num, .pls-money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: 13px; }
.hidden { display: none !important; }

:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.pls-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 8px 16px;
    padding-top: max(8px, env(safe-area-inset-top));
    background: var(--navy);
    color: #fff;
}
.pls-topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.pls-topbar__brand img { height: 28px; width: auto; border-radius: 4px; background: #fff; }
.pls-topbar__title { font-weight: 650; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pls-topbar__sub { font-size: 12px; opacity: .75; }
.pls-topbar a, .pls-topbar button { color: #fff; }
.pls-topbar__icon {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: var(--tap); height: var(--tap);
    border: 0; background: transparent; border-radius: 50%;
    font-size: 18px; cursor: pointer; text-decoration: none;
}
.pls-topbar__icon:hover { background: rgba(255,255,255,.12); }
.pls-dot {
    position: absolute; top: 9px; right: 9px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: #f2b134; color: var(--ink);
    font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}

.pls-main {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
}
.pls-main--plain { padding-bottom: 32px; }

.pls-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }

.pls-bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--line);
}
.pls-bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--ink-soft); text-decoration: none; font-size: 12px; font-weight: 500;
}
.pls-bottom-nav a i { font-size: 19px; }
.pls-bottom-nav a.is-active { color: var(--navy); font-weight: 650; }
.pls-bottom-nav a.is-new i {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 30px; border-radius: 15px;
    background: var(--navy); color: #fff; font-size: 16px;
}

.pls-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.pls-card--flush { padding: 0; overflow: hidden; }
.pls-card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }

.pls-grid { display: grid; gap: 12px; }
.pls-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.pls-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: inherit; display: block; }
.pls-stat__value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pls-stat__label { font-size: 13px; color: var(--ink-soft); }
.pls-stat--warn { border-color: #f0cf95; background: var(--wait-wash); }
.pls-stat--bad { border-color: #efb7b2; background: var(--bad-wash); }

.pls-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pls-row {
    position: relative;
    display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
    padding: 12px 14px 12px 18px;
    border-bottom: 1px solid var(--line-soft);
    color: inherit; text-decoration: none;
    min-height: 64px;
}
.pls-list > li:last-child .pls-row, .pls-list > .pls-row:last-child { border-bottom: 0; }
.pls-row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--rail, var(--line)); }
a.pls-row:hover, button.pls-row:hover { background: #fafbfc; }
.pls-row__title { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pls-row__meta { grid-column: 1; font-size: 13px; color: var(--ink-soft); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pls-row__amount { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.pls-row__side { grid-column: 2; grid-row: 2; text-align: right; }
button.pls-row { width: 100%; border: 0; border-bottom: 1px solid var(--line-soft); background: var(--surface); font: inherit; text-align: left; cursor: pointer; }

.pls-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap;
    background: var(--line-soft); color: var(--ink-soft);
}
.pls-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-draft { --rail: var(--line); }
.st-pending_approval, .st-amount_mismatch, .st-order_error { --rail: var(--wait); }
.st-ready, .st-sent, .st-viewed, .st-accepted { --rail: var(--info); }
.st-paid, .st-ordered { --rail: var(--ok); }
.st-rejected, .st-cancelled, .st-expired { --rail: var(--ink-faint); }
.pls-badge.st-pending_approval, .pls-badge.st-amount_mismatch { background: var(--wait-wash); color: var(--wait); }
.pls-badge.st-order_error { background: var(--bad-wash); color: var(--bad); }
.pls-badge.st-ready, .pls-badge.st-sent, .pls-badge.st-viewed, .pls-badge.st-accepted { background: var(--info-wash); color: var(--info); }
.pls-badge.st-paid, .pls-badge.st-ordered { background: var(--ok-wash); color: var(--ok); }

.pls-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px 12px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.pls-chips::-webkit-scrollbar { display: none; }
.pls-chip {
    flex: none; min-height: 36px; padding: 6px 14px;
    border: 1px solid var(--line); border-radius: 18px;
    background: var(--surface); color: var(--ink);
    font: inherit; font-size: 14px; cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center; gap: 6px;
}
.pls-chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.pls-chip__count { font-size: 12px; opacity: .8; }

.pls-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--tap); padding: 10px 18px;
    border: 1px solid transparent; border-radius: var(--radius);
    font: inherit; font-weight: 600; font-size: 15px;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    background: var(--navy); color: #fff;
}
.pls-btn:hover { background: var(--navy-deep); }
.pls-btn:disabled, .pls-btn.is-busy { opacity: .55; cursor: not-allowed; }
.pls-btn--ghost { background: var(--surface); color: var(--navy); border-color: var(--line); }
.pls-btn--ghost:hover { background: var(--navy-wash); }
.pls-btn--ok { background: var(--ok); }
.pls-btn--ok:hover { background: #17633e; }
.pls-btn--bad { background: var(--surface); color: var(--bad); border-color: #efb7b2; }
.pls-btn--bad:hover { background: var(--bad-wash); }
.pls-btn--wa { background: #1f8f4e; }
.pls-btn--wa:hover { background: #187a42; }
.pls-btn--block { width: 100%; }
.pls-btn--small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.pls-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pls-actions--stack { flex-direction: column; }
.pls-actions--stack .pls-btn { width: 100%; }

.pls-field { margin-bottom: 14px; }
.pls-field label, .pls-label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.pls-field .faint { margin-top: 4px; }
.pls-input, .pls-select, .pls-textarea {
    width: 100%; min-height: var(--tap);
    padding: 10px 12px;
    border: 1px solid var(--line); border-radius: var(--radius-s);
    background: var(--surface); color: var(--ink);
    font: inherit; font-size: 16px;
}
.pls-textarea { min-height: 88px; resize: vertical; }
.pls-input:focus, .pls-select:focus, .pls-textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-wash); }
.pls-input--num { text-align: right; font-variant-numeric: tabular-nums; }
.pls-input-group { display: flex; gap: 8px; }
.pls-input-group > .pls-input { flex: 1; min-width: 0; }
.pls-check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-size: 15px; cursor: pointer; }
.pls-check input { width: 20px; height: 20px; accent-color: var(--navy); }
.pls-seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.pls-seg button { min-height: 40px; padding: 6px 14px; border: 0; background: var(--surface); font: inherit; font-size: 14px; cursor: pointer; color: var(--ink); }
.pls-seg button + button { border-left: 1px solid var(--line); }
.pls-seg button.is-active { background: var(--navy); color: #fff; }

.pls-alert { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: 14px; border: 1px solid transparent; }
.pls-alert--warn { background: var(--wait-wash); color: #6e4000; border-color: #f0cf95; }
.pls-alert--bad { background: var(--bad-wash); color: #8a1d16; border-color: #efb7b2; }
.pls-alert--ok { background: var(--ok-wash); color: #155a38; border-color: #b6dfc8; }
.pls-alert--info { background: var(--info-wash); color: #1e438f; border-color: #c3d3f3; }

.pls-empty { text-align: center; padding: 40px 16px; color: var(--ink-soft); }
.pls-empty i { font-size: 30px; color: var(--ink-faint); margin-bottom: 10px; display: block; }

.pls-slip {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 16px 16px 20px;
    margin-bottom: 22px;
}
.pls-slip::after {
    content: "";
    position: absolute; left: -1px; right: -1px; bottom: -10px; height: 10px;
    background:
        linear-gradient(135deg, var(--surface) 50%, transparent 50%) 0 0 / 14px 10px repeat-x,
        linear-gradient(225deg, var(--surface) 50%, transparent 50%) 0 0 / 14px 10px repeat-x;
    filter: drop-shadow(0 1px 0 var(--line));
}
.pls-slip__row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14px; }
.pls-slip__row span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pls-slip__row--minus span:last-child { color: var(--ok); }
.pls-slip__total {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    margin-top: 10px; padding-top: 12px;
    border-top: 1px dashed var(--line);
}
.pls-slip__total strong { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--navy); }
.pls-slip__code { font-variant-numeric: tabular-nums; font-weight: 650; letter-spacing: .04em; color: var(--ink-soft); font-size: 13px; }

.pls-line { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.pls-line:last-child { border-bottom: 0; }
.pls-line__img { width: 48px; height: 48px; border-radius: var(--radius-s); background: var(--paper) center / cover no-repeat; border: 1px solid var(--line-soft); }
.pls-line__name { font-weight: 600; font-size: 14px; line-height: 1.35; }
.pls-line__meta { font-size: 13px; color: var(--ink-soft); }
.pls-line__edit { grid-column: 1 / -1; display: grid; grid-template-columns: 0.8fr 1.3fr 0.9fr auto; gap: 8px; align-items: end; }
.pls-line__edit label { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 12px; color: var(--ink-soft); }
.pls-line__edit .pls-input { min-width: 0; padding: 8px 10px; }
.pls-line__edit .pls-btn { min-height: var(--tap); }
.pls-line__total { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; font-size: 14px; }

.pls-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 16px; }
.pls-steps button { border: 0; background: none; padding: 0; font: inherit; cursor: pointer; text-align: left; color: var(--ink-faint); font-size: 12px; font-weight: 600; }
.pls-steps button::before { content: ""; display: block; height: 4px; border-radius: 2px; background: var(--line); margin-bottom: 6px; }
.pls-steps button.is-done, .pls-steps button.is-active { color: var(--navy); }
.pls-steps button.is-done::before, .pls-steps button.is-active::before { background: var(--navy); }

.pls-sticky-foot {
    position: fixed; left: 0; right: 0; z-index: 25;
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    background: var(--surface); border-top: 1px solid var(--line);
}
.pls-sticky-foot__sum { flex: 1; min-width: 0; }
.pls-sticky-foot__sum strong { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.pls-sticky-foot__sum span { font-size: 12px; color: var(--ink-soft); }
.has-sticky-foot .pls-main { padding-bottom: calc(var(--nav-h) + 96px + env(safe-area-inset-bottom)); }

.pls-sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(22, 33, 58, .45); display: flex; align-items: flex-end; justify-content: center; }
.pls-sheet {
    width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
    background: var(--surface); border-radius: var(--radius-l) var(--radius-l) 0 0;
    padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
    animation: pls-sheet-up .22s ease-out;
}
.pls-sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 12px; }
.pls-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
@keyframes pls-sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.pls-timeline { list-style: none; margin: 0; padding: 0; }
.pls-timeline li { position: relative; padding: 0 0 14px 20px; font-size: 14px; }
.pls-timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--navy); }
.pls-timeline li::after { content: ""; position: absolute; left: 7px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.pls-timeline li:last-child::after { display: none; }
.pls-timeline time { display: block; font-size: 12px; color: var(--ink-faint); }

.pls-toast-wrap { position: fixed; left: 16px; right: 16px; top: calc(64px + env(safe-area-inset-top)); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.pls-toast { max-width: 480px; width: 100%; padding: 12px 14px; border-radius: var(--radius); background: var(--ink); color: #fff; font-size: 14px; box-shadow: 0 6px 24px rgba(22,33,58,.25); pointer-events: auto; }
.pls-toast--ok { background: var(--ok); }
.pls-toast--bad { background: var(--bad); }
.pls-toast--warn { background: var(--wait); }

.pls-auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; max-width: 420px; margin: 0 auto; }
.pls-auth__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.pls-auth__brand img { height: 44px; width: auto; max-width: 160px; object-fit: contain; }
.pls-auth__mark { width: 44px; height: 44px; border-radius: 12px; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; }

.pls-table-wrap { overflow-x: auto; }
.pls-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pls-table th, .pls-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.pls-table th { font-size: 13px; color: var(--ink-soft); font-weight: 600; background: #fafbfc; }
.pls-table td.num, .pls-table th.num { text-align: right; }

.pls-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; margin: 0; }
.pls-kv dt { color: var(--ink-soft); }
.pls-kv dd { margin: 0; text-align: right; }

.pls-split { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "side" "hist"; align-items: start; }
.pls-split__main { grid-area: main; min-width: 0; }
.pls-split__side { grid-area: side; min-width: 0; margin-bottom: 12px; }
.pls-split__hist { grid-area: hist; min-width: 0; }

.pls-pager { display: flex; justify-content: center; gap: 8px; margin: 16px 0; }

.pls-suggest { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); max-height: 320px; overflow-y: auto; }
.pls-suggest li { border-bottom: 1px solid var(--line-soft); }
.pls-suggest li:last-child { border-bottom: 0; }
.pls-suggest button { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; width: 100%; min-height: 52px; padding: 8px 12px; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.pls-suggest button:hover, .pls-suggest button:focus-visible { background: var(--navy-wash); }
.pls-suggest .pls-line__img { width: 40px; height: 40px; }
.pls-suggest--text button { grid-template-columns: 1fr auto; }

.pls-side {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 70;
    width: 260px; max-width: 82vw;
    display: flex; flex-direction: column;
    padding: 12px 10px calc(12px + env(safe-area-inset-bottom));
    padding-top: max(12px, env(safe-area-inset-top));
    background: var(--surface); border-right: 1px solid var(--line);
    transform: translateX(-100%); transition: transform .2s ease-out;
    overflow-y: auto;
}
.pls-side.is-open { transform: none; box-shadow: 0 0 40px rgba(22, 33, 58, .2); }
.pls-side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.pls-side__link {
    display: flex; align-items: center; gap: 12px;
    min-height: var(--tap); padding: 8px 12px;
    border-radius: var(--radius-s);
    color: var(--ink); text-decoration: none; font-weight: 500;
}
.pls-side__link i { width: 18px; text-align: center; color: var(--ink-faint); }
.pls-side__link:hover { background: var(--paper); }
.pls-side__link.is-active { background: var(--navy-wash); color: var(--navy); font-weight: 650; }
.pls-side__link.is-active i { color: var(--navy); }
.pls-side__count { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 11px; background: var(--wait-wash); color: var(--wait); font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.pls-side__foot { padding: 12px; overflow-wrap: anywhere; }
.pls-side-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(22, 33, 58, .4); display: none; }
.pls-side-backdrop.is-open { display: block; }
.pls-burger { margin-left: -8px; }

@media (min-width: 1024px) {
    .pls--admin .pls-side { transform: none; top: 56px; padding-top: 12px; box-shadow: none; width: 232px; }
    .pls--admin .pls-side-backdrop { display: none !important; }
    .pls--admin .pls-burger { display: none; }
    .pls--admin .pls-main { margin-left: 232px; width: auto; max-width: none; padding-left: 24px; padding-right: 24px; }
    .pls--admin .pls-main > * { max-width: 1120px; }
}

@media (prefers-reduced-motion: reduce) {
    .pls-side { transition: none; }
}

@media (min-width: 768px) {
    .pls-stats { grid-template-columns: repeat(4, 1fr); }
    .pls-grid--2 { grid-template-columns: 1fr 1fr; }
    .pls-split { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); grid-template-areas: "main side" "hist side"; column-gap: 16px; }
    .pls-split > .pls-split__side { position: sticky; top: 72px; }
    .pls-sheet-backdrop { align-items: center; }
    .pls-sheet { border-radius: var(--radius-l); }
    .pls-sheet::before { display: none; }
}

@media (min-width: 1100px) {
    .pls-grid--3 { grid-template-columns: repeat(3, 1fr); }
    .pls-bottom-nav.pls-bottom-nav--admin { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .pls-sheet { animation: none; }
}

@media print {
    .pls-topbar, .pls-bottom-nav, .pls-actions, .pls-sticky-foot { display: none !important; }
    body.pls { background: #fff; }
    .pls-main { padding: 0; }
}
