:root {
    --bg: #eef2f6;
    --panel: #ffffff;
    --ink: #1f2a37;
    --muted: #6b7280;
    --line: #d7dee8;
    --accent: #215a8f;
    --accent-soft: #e8f1f8;
    --danger: #9b2c2c;
    --danger-bg: #fde8e8;
    --ok: #276749;
    --ok-bg: #e6ffed;
    --shadow: 0 10px 30px rgba(31, 42, 55, 0.08);
    --radius: 10px;
    --sidebar-width: 240px;
    --font: "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(33, 90, 143, 0.08), transparent 40%),
        linear-gradient(180deg, #f7fafc 0%, var(--bg) 100%);
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #18324f;
    color: #f8fafc;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-brand {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.25rem 0.5rem;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 0.35rem; }

.nav-link {
    color: #dbe7f3;
    padding: 0.7rem 0.8rem;
    border-radius: 8px;
    text-decoration: none;
}

.nav-link:hover,
.nav-link.is-active {
    background: rgba(255, 255, 255, 0.12);
    text-decoration: none;
}

.sidebar-foot {
    margin-top: auto;
    padding: 0.75rem 0.5rem;
    border-top: 1px solid rgba(255,255,255,0.12);
}

.sidebar-user { font-weight: 600; margin-top: 0.25rem; }

.main-area { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(255,255,255,0.85);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(6px);
}

.topbar-title { font-size: 1.1rem; font-weight: 700; }
.topbar-user { display: flex; gap: 0.75rem; align-items: center; }

.content {
    padding: 1.5rem;
    max-width: 1100px;
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.auth-card {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem;
}

.brand {
    margin: 0 0 0.25rem;
    font-size: 1.4rem;
    color: var(--accent);
}

.auth-title {
    margin: 0 0 1.25rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.form-stack { display: flex; flex-direction: column; gap: 1rem; }

.field label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    background: #fff;
}

.field input:focus {
    outline: 2px solid rgba(33, 90, 143, 0.25);
    border-color: var(--accent);
}

.help {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.7rem 1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
}

.btn:hover { filter: brightness(1.05); text-decoration: none; }

.btn-ghost {
    background: transparent;
    color: var(--accent);
    border-color: var(--line);
}

.btn-block { width: 100%; }

.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--ok-bg); color: var(--ok); }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card h2 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.menu-item {
    display: block;
    padding: 1.1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--ink);
    text-decoration: none;
}

.menu-item:hover {
    border-color: var(--accent);
    text-decoration: none;
}

.menu-item strong { display: block; margin-bottom: 0.35rem; }
.menu-item span { color: var(--muted); font-size: 0.9rem; }

.def-list { display: grid; gap: 0.5rem; margin: 0; }
.def-item {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 0.75rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--line);
}
.def-item dt { margin: 0; color: var(--muted); font-weight: 600; }
.def-item dd { margin: 0; word-break: break-all; }

.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table th,
.data-table td {
    border-bottom: 1px solid var(--line);
    padding: 0.55rem 0.45rem;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}
.data-table th { color: var(--muted); font-weight: 700; }

.muted { color: var(--muted); }
.error-list { margin: 0 0 1rem; padding-left: 1.2rem; color: var(--danger); }

.search-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.75rem;
    align-items: end;
}

@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: sticky; top: 0; z-index: 2; }
    .def-item { grid-template-columns: 1fr; gap: 0.2rem; }
    .search-grid { grid-template-columns: 1fr; }
}
