* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: #1d2433; background: #f3f5f8; }
a { color: #1f5fbf; }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 24px; margin: 8px 0 16px; }
h1 small { font-size: 14px; color: #6b7385; font-weight: normal; }
h2 { font-size: 19px; margin: 32px 0 12px; }
code { background: #eef1f6; padding: 1px 4px; border-radius: 3px; font-size: 13px; }

.topbar { background: #1d2a44; color: #fff; display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 52px; }
.topbar .brand { color: #fff; font-weight: 600; text-decoration: none; font-size: 17px; }
.topbar nav a { color: #c9d3e6; text-decoration: none; margin-right: 18px; }
.topbar nav a.active, .topbar nav a:hover { color: #fff; }

.flash { background: #e3f4e6; border: 1px solid #a9d8b1; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.warn { background: #fff6d6; border: 1px solid #f0d77a; padding: 8px 12px; border-radius: 6px; }
.muted { color: #6b7385; }
.crumbs { color: #6b7385; margin: 0 0 4px; font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 6px; background: #fff; border: 1px solid #dde2ea; border-radius: 8px;
        padding: 16px; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.card:hover { border-color: #1f5fbf; box-shadow: 0 2px 8px rgba(31,95,191,.12); }
.card span { color: #4a5263; font-size: 14px; }
.card small { color: #8a91a1; }

table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #dde2ea; border-radius: 8px; overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #edf0f4; }
table.list th { background: #f7f8fb; font-weight: 600; font-size: 13px; color: #4a5263; }
td.actions a { margin-right: 12px; white-space: nowrap; }

.inline-search { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.inline-search input { flex: 1; min-width: 200px; }

input, select, textarea, button, .btn { font: inherit; }
input[type=text], input[type=date], input[type=search], input[type=number], input:not([type]), select, textarea {
    width: 100%; padding: 7px 9px; border: 1px solid #c5ccd8; border-radius: 6px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9ec0f2; border-color: #1f5fbf; }
button, .btn { display: inline-block; padding: 8px 14px; border: 1px solid #c5ccd8; background: #fff; border-radius: 6px;
               cursor: pointer; text-decoration: none; color: #1d2433; }
button.primary, .btn.primary { background: #1f5fbf; border-color: #1f5fbf; color: #fff; }
button.danger { color: #b3261e; border-color: #e3b4b0; }
.buttons { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }

.fill-form fieldset.group { background: #fff; border: 1px solid #dde2ea; border-radius: 8px; padding: 14px 16px 16px; margin: 0 0 16px; }
.fill-form legend { font-weight: 600; padding: 0 6px; }
.fill-form .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; }
.fill-form .field.wide { grid-column: 1 / -1; }
.fill-form .field label { display: block; font-size: 13px; color: #4a5263; margin-bottom: 3px; }
.fill-form .field small { color: #8a91a1; font-size: 12px; }
.fill-form .req { color: #b3261e; }
.client-pick { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; background: #f4f7fc; border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; }
.client-pick label { font-size: 13px; color: #4a5263; }
.client-pick select { min-width: 280px; margin-top: 3px; }
label.check { display: flex; gap: 6px; align-items: center; }
textarea.code { font: 13px/1.4 ui-monospace, Consolas, monospace; }
details.help { margin-bottom: 8px; font-size: 14px; }
.table-wrap { overflow-x: auto; }
.fields-table { border-collapse: collapse; font-size: 13px; }
.fields-table th { text-align: left; padding: 4px; white-space: nowrap; color: #4a5263; font-weight: 600; }
.fields-table td { padding: 2px; }
.fields-table input, .fields-table select, .fields-table textarea { width: auto; padding: 4px 6px; font-size: 13px; }

/* Dokumento peržiūra kaip A4 lapas */
.toolbar { margin-bottom: 16px; }
.page { background: #fff; width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto; padding: 12mm 12mm 12mm 16mm;
        box-shadow: 0 2px 12px rgba(0,0,0,.12); }
.missing { background: #ffe86b; }

@media print {
    body { background: #fff; }
    .no-print, .topbar, .toolbar { display: none !important; }
    main { max-width: none; padding: 0; margin: 0; }
    .page { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
}
