/* ============================================
   ベーススタイル（Mantine風デザイン）
   ============================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-primary:      #228be6;
    --color-primary-dark: #1971c2;
    --color-primary-bg:   #e7f5ff;
    --color-success:      #2f9e44;
    --color-warning:      #f08c00;
    --color-danger:       #e03131;
    --color-text:         #212529;
    --color-text-muted:   #868e96;
    --color-border:       #dee2e6;
    --color-bg:           #f8f9fa;
    --color-white:        #ffffff;
    --color-sidebar-bg:   #1e1e2d;
    --color-sidebar-text: #a0a0b0;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);

    --sidebar-width: 240px;
    --header-height: 60px;
    --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
}

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

/* ============================================
   レイアウト
   ============================================ */

.layout {
    display: flex;
    min-height: 100vh;
}

/* --- サイドバー --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-logo {
    padding: 20px 16px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-section-label {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.3);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--color-sidebar-text);
    cursor: pointer;
    border-radius: var(--radius-sm);
    margin: 2px 8px;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    font-size: 14px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
}

.nav-item.active {
    background: var(--color-primary);
    color: #fff;
}

.nav-item svg { flex-shrink: 0; }

/* --- メインコンテンツ --- */
.main-wrap {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* --- ヘッダー --- */
.header {
    height: var(--header-height);
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-title { font-size: 16px; font-weight: 600; }

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--color-text-muted);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

/* --- ページコンテンツ --- */
.content { padding: 24px; flex: 1; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title { font-size: 20px; font-weight: 700; }

/* ============================================
   カード
   ============================================ */

.card {
    background: var(--color-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.card-body { padding: 20px; }
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    font-size: 15px;
}

/* stat card */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--color-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    padding: 20px;
}

.stat-label { font-size: 13px; color: var(--color-text-muted); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--color-text); }
.stat-sub   { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

/* ============================================
   テーブル
   ============================================ */

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    background: var(--color-bg);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f3f5;
    vertical-align: middle;
}

tbody tr:hover { background: #f8f9fa; }
tbody tr:last-child td { border-bottom: none; }

/* ============================================
   ボタン
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    line-height: 1;
    white-space: nowrap;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary-bg); }

.btn-danger  { background: var(--color-danger);  color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { opacity: 0.88; }

.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }

/* ============================================
   フォーム
   ============================================ */

.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--color-text);
}

.form-label .required { color: var(--color-danger); margin-left: 2px; }

.form-control {
    display: block;
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(34,139,230,0.15);
}

.form-control::placeholder { color: #adb5bd; }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--color-danger); margin-top: 4px; }

/* ============================================
   バッジ
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
}

.badge-primary { background: var(--color-primary-bg); color: var(--color-primary); }
.badge-success { background: #ebfbee; color: var(--color-success); }
.badge-warning { background: #fff3bf; color: var(--color-warning); }
.badge-danger  { background: #fff5f5; color: var(--color-danger); }
.badge-gray    { background: #f1f3f5; color: #495057; }

/* ============================================
   モーダル
   ============================================ */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modal-in 0.2s ease;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 16px;
}

.modal-body    { padding: 20px; overflow-y: auto; }
.modal-footer  {
    padding: 14px 20px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 20px;
    line-height: 1;
    padding: 2px;
}
.modal-close:hover { color: var(--color-text); }

/* ============================================
   通知トースト
   ============================================ */

.toast-wrap {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    background: var(--color-white);
    border-left: 4px solid var(--color-primary);
    min-width: 260px;
    animation: toast-in 0.25s ease;
    font-size: 14px;
}

.toast.success { border-left-color: var(--color-success); }
.toast.error   { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ============================================
   ログイン画面
   ============================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1e2d 0%, #2c2c44 100%);
    padding: 16px;
}

.login-box {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: var(--color-primary);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.login-logo h1 { font-size: 20px; font-weight: 700; }
.login-logo p  { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }

.login-error {
    background: #fff5f5;
    border: 1px solid #ffc9c9;
    color: var(--color-danger);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ============================================
   レスポンシブ
   ============================================ */

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--color-text);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-wrap {
        margin-left: 0;
    }
    .hamburger { display: flex; }
    .stat-grid {
        grid-template-columns: 1fr 1fr;
    }
    .content { padding: 16px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
}

/* ============================================
   ユーティリティ
   ============================================ */

.text-muted  { color: var(--color-text-muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.w-full { width: 100%; }


/* ロールバッジ・スマホ補助 */
.hidden-sp {}
.role-badge {
    font-size: 11px;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.7);
    padding: 2px 6px;
    border-radius: 4px;
}
@media (max-width: 480px) { .hidden-sp { display: none; } }
