:root {
    color-scheme: light;
    --bg: #f6f7f3;
    --panel: #ffffff;
    --ink: #1d2528;
    --muted: #69777a;
    --line: #dce4df;
    --primary: #0f766e;
    --primary-ink: #ffffff;
    --warn: #b45309;
    --danger: #b91c1c;
    --blue: #2563eb;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.7;
}
a { color: inherit; text-decoration: none; }
.topbar, .hero-band, .section-head, .grid, .row, .chat, .form, .form-grid {
    min-width: 0;
}
.topbar > *, .hero-band > *, .section-head > *, .grid > *, .row > *, .chat > *, .form-grid > * {
    min-width: 0;
}
.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    padding: 14px 28px;
    border-bottom: 1px solid var(--line);
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { font-weight: 800; color: var(--primary); }
.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav a, .nav button, .button, button {
    border: 1px solid var(--line);
    background: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    max-width: 100%;
    overflow-wrap: anywhere;
}
.nav form { margin: 0; }
.primary { background: var(--primary) !important; color: var(--primary-ink) !important; border-color: var(--primary) !important; }
.shell { width: min(1120px, calc(100% - 32px)); margin: 28px auto; }
.hero-band {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
    padding: 24px 0;
    border-bottom: 1px solid var(--line);
}
h1, h2 { margin: 0 0 10px; line-height: 1.3; }
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 18px;
}
.narrow { max-width: 520px; margin-inline: auto; }
.grid.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.list { display: grid; gap: 10px; }
.row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow-wrap: anywhere;
}
.muted { color: var(--muted); }
.form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label { display: grid; gap: 6px; font-weight: 700; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px;
    font: inherit;
    background: #fff;
}
input[type="file"] { max-width: 100%; min-width: 0; }
textarea { min-height: 130px; resize: vertical; }
img, video { max-width: 100%; height: auto; }
.notice, .alert, .emergency {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.notice { background: #ecfdf5; border: 1px solid #a7f3d0; }
.alert, .emergency { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }
.badge {
    display: inline-flex;
    min-width: 74px;
    justify-content: center;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 13px;
    border: 1px solid var(--line);
}
.badge.low { background: #ecfdf5; color: #065f46; }
.badge.medium { background: #eff6ff; color: var(--blue); }
.badge.high { background: #fffbeb; color: var(--warn); }
.badge.emergency { background: #fef2f2; color: var(--danger); }
.facts {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 10px 16px;
    margin: 0;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.chat { display: grid; gap: 12px; margin-bottom: 18px; }
.bubble {
    max-width: min(860px, 100%);
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.bubble.owner { margin-right: auto; border-color: #bfdbfe; }
.bubble.ai { margin-left: auto; border-color: #99f6e4; }
.bubble p { white-space: pre-wrap; margin-bottom: 8px; overflow-wrap: anywhere; word-break: break-word; }
.attachment {
    display: inline-block;
    max-width: 100%;
    color: var(--primary);
    border-bottom: 1px solid currentColor;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metrics div {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    display: grid;
}
.metrics strong { font-size: 28px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: right; padding: 12px; border-bottom: 1px solid var(--line); }
.pagination { margin-top: 16px; }

@media (max-width: 760px) {
    .topbar, .hero-band, .section-head { align-items: stretch; flex-direction: column; }
    .grid.two, .form-grid, .metrics { grid-template-columns: 1fr; }
    .facts { grid-template-columns: 1fr; }
    .shell { width: min(100% - 20px, 1120px); }
    .row { align-items: stretch; flex-direction: column; }
    .nav a, .nav button, .button, button {
        align-items: center;
        display: inline-flex;
        justify-content: center;
        min-height: 44px;
    }
}
