* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    margin: 0;
    background: #f5f6f8;
    color: #1f2937;
    line-height: 1.5;
}
.wrap { max-width: 960px; margin: 2rem auto; padding: 0 1rem; }
.wrap.narrow { max-width: 420px; }
h1 { margin: 0 0 .25rem; font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
.lead { color: #6b7280; margin: 0 0 1.5rem; }
.muted { color: #6b7280; }
.req { color: #dc2626; }

.topbar { background: #111827; color: #fff; padding: .75rem 0; }
.topbar-inner { max-width: 960px; margin: 0 auto; padding: 0 1rem; display: flex; align-items: center; gap: 1rem; }
.topbar nav { margin-left: auto; display: flex; gap: .25rem; }
.topbar a { color: #e5e7eb; text-decoration: none; padding: .4rem .75rem; border-radius: 6px; font-size: .9rem; }
.topbar a:hover { background: #1f2937; }
.topbar a.active { background: #374151; color: #fff; }
.topbar a.muted { color: #9ca3af; }

fieldset {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin: 0 0 1rem;
}
legend { padding: 0 .5rem; font-weight: 600; color: #374151; }
fieldset.readonly .kv { display: grid; grid-template-columns: 220px 1fr; gap: .5rem 1rem; padding: .4rem 0; border-top: 1px solid #f3f4f6; }
fieldset.readonly .kv:first-of-type { border-top: 0; }
fieldset.readonly .k { color: #6b7280; font-size: .9rem; }
fieldset.readonly .v { color: #111827; word-break: break-word; }

label {
    display: block;
    margin: .5rem 0 .75rem;
    font-weight: 500;
    color: #374151;
    font-size: .93rem;
}
label.checkbox-label { display: flex; align-items: center; gap: .5rem; margin-top: 1.65rem; }
input[type=text], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=time], input[type=password],
select, textarea {
    width: 100%;
    margin-top: .25rem;
    padding: .55rem .65rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    color: #111827;
}
textarea { resize: vertical; min-height: 68px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #3b82f6; outline-offset: -1px; border-color: #3b82f6; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > label { flex: 1 1 160px; }

.btn {
    display: inline-block;
    background: #2563eb;
    color: #fff;
    border: 0;
    padding: .6rem 1.1rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}
.btn:hover { background: #1d4ed8; }
.btn.small { padding: .35rem .7rem; font-size: .88rem; }
.btn.tiny { padding: .2rem .45rem; font-size: .8rem; }
.btn.muted { background: #6b7280; }
.btn.muted:hover { background: #4b5563; }
.btn.danger { background: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
form.inline, .inline { display: inline; }
.inline-form { background: #fff; border: 1px solid #e5e7eb; padding: .6rem .8rem; border-radius: 8px; display: inline-flex; gap: .5rem; align-items: center; margin: .5rem 0 1rem; }
.inline-form label { margin: 0; display: flex; align-items: center; gap: .4rem; }
.inline-form select { width: auto; }

.alert {
    padding: .8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}
.alert.ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert.err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert ul { margin: .4rem 0 0 1rem; padding: 0; }


table.grid { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 0 #e5e7eb; }
table.grid th, table.grid td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid #f3f4f6; font-size: .92rem; vertical-align: top; }
table.grid th { background: #f9fafb; color: #374151; font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .02em; }
table.grid tbody tr:hover { background: #fafbfc; }
table.grid .actions { white-space: nowrap; }
table.grid .actions form, table.grid .actions a { margin-right: .25rem; }


.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 500; background: #e5e7eb; color: #374151; }
.status-jauns { background: #dbeafe; color: #1e40af; }
.status-apstiprin-ts { background: #e0e7ff; color: #3730a3; }
.status-darb { background: #fef3c7; color: #92400e; }
.status-pabeigts { background: #d1fae5; color: #065f46; }
.status-atcelts { background: #fee2e2; color: #991b1b; }

.filter { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filter input, .filter select { width: auto; margin: 0; }
.filter input[type=text] { min-width: 220px; }

.two-col { display: grid; grid-template-columns: 1fr 1.3fr; gap: 2rem; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; font-size: .85em; }

.admin-corner {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #111827;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1.1rem;
    opacity: .35;
    transition: opacity .15s, transform .15s;
    z-index: 1000;
}
.admin-corner:hover { opacity: 1; transform: rotate(45deg); }
