* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f5f7fb;
    color: #172033;
}
a { color: inherit; }
code {
    background: #edf1f7;
    padding: 0.15rem 0.35rem;
    border-radius: 0.35rem;
}
pre {
    white-space: pre-wrap;
    background: #edf1f7;
    padding: 1rem;
    border-radius: 1rem;
    overflow-x: auto;
}
.topbar {
    background: linear-gradient(135deg, #182033, #31415f);
    color: white;
    padding: 2rem 1rem;
}
.topbar h1 { margin: 0.25rem 0; font-size: clamp(1.7rem, 3vw, 2.6rem); }
.topbar p { margin: 0.25rem 0 0; color: #dbe5f5; }
.topbar > div, .container, .mainnav { max-width: 1180px; margin: 0 auto; }
.mainnav {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
}
.mainnav a, .nav-user {
    text-decoration: none;
    background: white;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 999px;
    padding: 0.55rem 0.9rem;
    box-shadow: 0 6px 16px rgba(23, 32, 51, 0.06);
}
.nav-user {
    margin-left: auto;
    color: #526078;
}
.container { padding: 1.5rem 1rem 3rem; }
.back { color: #dbe5f5; text-decoration: none; }
.notice {
    padding: 1rem;
    border-radius: 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.notice.warning { background: #fff8e6; border-color: #f4d06f; }
.notice.success { background: #eaf8ef; border-color: #9ed7ad; }
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.card, .panel {
    background: white;
    border-radius: 1.2rem;
    box-shadow: 0 12px 28px rgba(23, 32, 51, 0.08);
    border: 1px solid rgba(23, 32, 51, 0.06);
}
.card { padding: 1rem; }
.card .label {
    display: block;
    color: #6b7588;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}
.card strong { font-size: 1.8rem; }
.panel { padding: 1rem; margin-bottom: 1rem; }
.panel h2 { margin-top: 0; }
.panel-head {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
}
.inline-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}
.inline-controls input { min-width: 260px; }
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 0.75rem;
    border-bottom: 1px solid #edf1f7;
    text-align: left;
    vertical-align: top;
}
th {
    color: #526078;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.button, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: #31415f;
    color: white;
    padding: 0.65rem 0.9rem;
    border-radius: 0.75rem;
    text-decoration: none;
    cursor: pointer;
}
.button:hover, button:hover { background: #182033; }
input, select {
    width: 100%;
    border: 1px solid #d5dce8;
    background: white;
    border-radius: 0.75rem;
    padding: 0.65rem 0.75rem;
}
.filters, .storage-form {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
}
.storage-form { grid-template-columns: 1fr auto; }
.filters label, .storage-form label {
    display: grid;
    gap: 0.35rem;
    color: #526078;
    font-size: 0.9rem;
}
.truncate {
    max-width: 520px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hint {
    color: #6b7588;
    font-size: 0.92rem;
    margin-top: 0.75rem;
}
canvas { max-height: 320px; }
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: linear-gradient(135deg, #182033, #31415f);
}
.login-card {
    width: min(460px, 100%);
    background: white;
    border-radius: 1.2rem;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.22);
}
.login-form {
    display: grid;
    gap: 1rem;
}
.login-form label {
    display: grid;
    gap: 0.35rem;
    color: #526078;
}
.user-box {
    border: 1px solid #edf1f7;
    border-radius: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #fbfcff;
}
.user-grid {
    display: grid;
    grid-template-columns: 90px repeat(3, minmax(160px, 1fr));
    gap: 0.75rem;
    align-items: end;
}
.user-grid label, .site-access-list label {
    display: grid;
    gap: 0.35rem;
    color: #526078;
    font-size: 0.9rem;
}
.site-access-list {
    margin-top: 1rem;
    border-top: 1px solid #edf1f7;
    padding-top: 1rem;
}
.site-access-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: #526078;
    margin-bottom: 0.75rem;
}
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.5rem 1rem;
}
.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    border: 1px solid #edf1f7;
    border-radius: 0.75rem;
    padding: 0.55rem;
}
.checkbox-grid input { width: auto; }
.muted { opacity: 0.45; }
.kv {
    display: grid;
    grid-template-columns: minmax(130px, 220px) 1fr;
    gap: 0.45rem 1rem;
}
.kv dt {
    color: #526078;
    font-weight: 700;
}
.kv dd {
    margin: 0;
    overflow-wrap: anywhere;
}
@media (max-width: 900px) {
    .user-grid { grid-template-columns: 1fr; }
    .nav-user { margin-left: 0; }
}
@media (max-width: 720px) {
    .filters, .storage-form, .panel-head, .inline-controls {
        grid-template-columns: 1fr;
        display: grid;
    }
    .inline-controls input { min-width: 0; }
}
