:root {
  --bg: #f5f6f8; --card: #fff; --text: #1d2330; --muted: #6b7280; --border: #e3e6eb;
  --primary: #2f5bea; --primary-text: #fff; --danger: #c62828; --radius: 10px;
  --green: #e6f4ea; --green-t: #1e7a34; --blue: #e8eefc; --blue-t: #2448b8;
  --amber: #fdf3e1; --amber-t: #8a5a00; --grey: #eef0f3; --grey-t: #4b5563; --red: #fde8e8; --red-t: #b42318;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }

.topbar { display: flex; align-items: center; gap: 1.25rem; padding: .6rem 1.25rem; background: #151a28; color: #fff; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; }
.nav { display: flex; gap: .25rem; }
.nav a { color: #c9cfdb; padding: .35rem .7rem; border-radius: 6px; }
.nav a.active, .nav a:hover { background: #262d40; color: #fff; text-decoration: none; }
.search { flex: 1; min-width: 160px; max-width: 360px; margin-left: auto; }
.search input { width: 100%; background: #262d40; border: 1px solid #343c52; color: #fff; }
.usermenu { position: relative; }
.usermenu summary { cursor: pointer; list-style: none; color: #c9cfdb; }
.usermenu .menu { position: absolute; right: 0; top: 1.8rem; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: .4rem; min-width: 170px; z-index: 10; box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.usermenu .menu a, .usermenu .menu .linklike { display: block; padding: .4rem .6rem; color: var(--text); width: 100%; text-align: left; }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.narrow { max-width: 680px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.crumbs { margin: 0 0 .2rem; font-size: .85rem; color: var(--muted); }

.btn { display: inline-block; padding: .45rem .9rem; border-radius: 7px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; line-height: 1.3; }
.btn:hover { background: var(--grey); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-outline { color: var(--danger); }
.btn.small { padding: .25rem .6rem; font-size: .82rem; }
.btn.wide { width: 100%; margin-top: .5rem; }

input, select, textarea { font: inherit; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--text); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9c8fb; border-color: var(--primary); }
.form .field { margin-bottom: .9rem; display: flex; flex-direction: column; gap: .25rem; }
.form .field input:not([type=checkbox]), .form .field select, .form .field textarea { width: 100%; }
.form .field label { font-weight: 600; font-size: .9rem; }
.form .field.check label { font-weight: 400; display: flex; gap: .5rem; align-items: center; }
.help { color: var(--muted); }
.req { color: var(--danger); }
.error-text { color: var(--danger); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.actions { display: flex; gap: .5rem; margin-top: 1rem; }
.auth-card { max-width: 380px; margin: 8vh auto 0; }
.auth-card label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; margin-bottom: .8rem; }

.messages { margin-bottom: 1rem; display: grid; gap: .5rem; }
.msg { padding: .6rem .9rem; border-radius: 8px; background: var(--blue); color: var(--blue-t); }
.msg.success { background: var(--green); color: var(--green-t); }
.msg.error { background: var(--red); color: var(--red-t); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { display: flex; flex-direction: column; color: var(--muted); }
.stat:hover { text-decoration: none; border-color: #c8cfdb; }
.stat .num { font-size: 1.8rem; font-weight: 700; color: var(--text); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 1rem; }
.grid-detail { display: grid; grid-template-columns: 320px 1fr; gap: 1rem; align-items: start; }
.stack { display: grid; gap: 1rem; }
@media (max-width: 860px) { .grid-detail, .grid2 { grid-template-columns: minmax(0, 1fr); } }

.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.card h2 + .row, .section-head + .row, .inline-form + .row { border-top: 0; }
.row-actions { display: flex; gap: .5rem; align-items: center; flex-shrink: 0; }
.row-actions form { margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.section-head h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.notes { font-size: .92rem; }
.notes p { margin: 0 0 .5rem; }
.dl { display: grid; grid-template-columns: 110px 1fr; gap: .35rem .75rem; margin: 0; font-size: .92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { min-width: 240px; flex: 1; max-width: 380px; }
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--grey); color: var(--grey-t); white-space: nowrap; vertical-align: middle; }
.badge.red { background: var(--red); color: var(--red-t); }
.c-active, .s-live { background: var(--green); color: var(--green-t); }
.c-lead, .s-in_progress { background: var(--blue); color: var(--blue-t); }
.s-review, .s-planned { background: var(--amber); color: var(--amber-t); }
.s-maintenance { background: #f1e8fd; color: #6b2fb8; }
.tag { display: inline-block; font-size: .75rem; padding: 0 .45rem; margin: .2rem .25rem 0 0; border-radius: 4px; background: var(--grey); color: var(--grey-t); }

.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
.assets > p { grid-column: 1 / -1; margin: 0; } gap: .75rem; }
.asset { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.thumb { display: flex; align-items: center; justify-content: center; height: 110px; background: repeating-conic-gradient(#f2f3f5 0 25%, #fff 0 50%) 0 0/16px 16px; }
.thumb img { max-width: 100%; max-height: 110px; object-fit: contain; }
.thumb.placeholder { background: var(--grey); color: var(--muted); font-size: .85rem; }
.asset-body { padding: .6rem .75rem; }
.links { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .3rem; }

.inline-form { display: grid; gap: .5rem; padding-bottom: 1rem; margin-bottom: .5rem; border-bottom: 1px solid var(--border); }
.inline-form label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; font-weight: 600; }
.inline-form textarea { width: 100%; }
.inline-form .btn { justify-self: start; }
.inline-grid { display: flex; gap: .5rem; flex-wrap: wrap; }
.inline-grid .grow { flex: 1; min-width: 200px; }
.inline-grid .grow input { width: 100%; }
.inline-grid input[name=hours] { width: 90px; }
.secret { margin-top: .4rem; padding: .4rem .6rem; background: var(--amber); border-radius: 6px; font-family: ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.grid-detail > * , .stack > * { min-width: 0; }
