/* ============================================================
   Mail Triage — デザインシステム（ビルド不要・素のCSS）
   ============================================================ */

:root {
    --bg: #f5f6fb;
    --bg-grad: radial-gradient(1200px 600px at 100% -10%, #eef0ff 0%, transparent 55%),
               radial-gradient(900px 500px at -10% 0%, #eafff6 0%, transparent 50%);
    --surface: #ffffff;
    --surface-2: #fafbfe;
    --border: #e7e9f2;
    --border-strong: #d7dae8;
    --text: #1c2230;
    --muted: #6b7280;
    --muted-2: #9aa1ad;
    --primary: #5b54e6;
    --primary-600: #4a43d6;
    --primary-soft: #eeedfd;
    --ring: rgba(91, 84, 230, .35);
    --shadow-sm: 0 1px 2px rgba(20, 24, 40, .06);
    --shadow: 0 6px 20px -8px rgba(30, 35, 70, .18), 0 2px 6px -2px rgba(30, 35, 70, .08);
    --shadow-lg: 0 24px 60px -20px rgba(30, 35, 70, .35);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 20px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Inter", system-ui, -apple-system, "Hiragino Kaku Gothic ProN",
                 "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
    color: var(--text);
    background-color: var(--bg);
    background-image: var(--bg-grad);
    background-attachment: fixed;
    line-height: 1.6;
    font-feature-settings: "palt";
    -webkit-font-smoothing: antialiased;
}

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

/* ---------- ヘッダー ---------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, .8);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.app-header__inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 18px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: .2px;
    color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand__mark {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, #6f67ff, #4a43d6);
    color: #fff; font-size: 16px;
    box-shadow: 0 4px 12px -3px var(--ring);
}
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
    padding: 7px 13px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted);
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.is-active { background: var(--primary-soft); color: var(--primary-600); }
.app-header__spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 12px; }
.userbox__name { font-size: 13px; color: var(--muted); }
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary-600);
    font-weight: 700; font-size: 13px;
}

/* ---------- レイアウト ---------- */
.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}
.page-head { margin-bottom: 22px; }
.page-head h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.01em;
    display: flex; align-items: center; gap: 10px;
}
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- カード ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card--pad { padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card__title {
    display: flex; align-items: center; gap: 7px;
    font-size: 13px; font-weight: 600; color: var(--muted);
    letter-spacing: .02em;
    margin: 0 0 10px;
}
.card__title svg { color: var(--muted-2); }

/* ---------- 統計 ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat-card__label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-card__value {
    font-size: 28px; font-weight: 700; letter-spacing: -.02em;
    margin-top: 4px; line-height: 1.1;
}
.stat-card__icon {
    position: absolute; right: 14px; top: 14px;
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center; font-size: 17px;
    background: var(--primary-soft);
}
.stat-card--reply .stat-card__icon { background: #fff0e8; }
.stat-card--dry .stat-card__icon { background: #eef6ff; }

/* ---------- ボタン ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    padding: 9px 15px;
    font-size: 13.5px; font-weight: 600;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn--primary {
    background: linear-gradient(135deg, #6f67ff, var(--primary));
    border-color: transparent; color: #fff;
    box-shadow: 0 6px 16px -6px var(--ring);
}
.btn--primary:hover { background: linear-gradient(135deg, #645cf3, var(--primary-600)); border-color: transparent; }
.btn--sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- セグメント（フィルタ） ---------- */
.segmented {
    display: inline-flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 16px;
}
.seg {
    padding: 7px 14px;
    font-size: 13px; font-weight: 500;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: all .15s;
}
.seg:hover { color: var(--text); border-color: var(--muted-2); }
.seg.is-active {
    background: var(--text); color: #fff; border-color: var(--text);
}

/* ---------- バッジ ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px;
    font-size: 11.5px; font-weight: 600;
    border-radius: 999px;
    background: #eef0f5; color: #4b5563;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge--green  { background: #e7f7ee; color: #1a7f48; }
.badge--blue   { background: #e8f1ff; color: #1f5fc7; }
.badge--amber  { background: #fff3e0; color: #b3640a; }
.badge--violet { background: #f0ecfe; color: #6b46d9; }
.badge--rose   { background: #ffe9ee; color: #c2185b; }
.badge--gray   { background: #eef0f5; color: #5b6472; }
.badge--dot::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; opacity: .85;
}

/* ---------- テーブル ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}
table.data th, table.data td {
    padding: 11px 14px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}
table.data thead th {
    background: var(--surface-2);
    font-size: 11.5px; font-weight: 600; color: var(--muted);
    letter-spacing: .03em;
    position: sticky; top: 62px;
}
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-strong { font-weight: 600; color: var(--text); }
.cell-muted { color: var(--muted); }
.check-yes { color: #1a7f48; font-weight: 700; display: inline-flex; align-items: center; }

/* ---------- フォーム ---------- */
.field { margin-bottom: 14px; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input, .textarea, .select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}
.textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
.input-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.input-row .input, .input-row .select { width: auto; flex: 1; min-width: 160px; }

/* ---------- アラート ---------- */
.alert {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    background: var(--primary-soft);
    border: 1px solid #d9d6fb;
    color: #44409e;
    margin-bottom: 16px;
}
.alert--error { background: #fdecec; border-color: #f6c9c9; color: #b3261e; }

/* ---------- 空状態 ---------- */
.empty {
    text-align: center;
    padding: 44px 20px;
    color: var(--muted);
}
.empty__icon { font-size: 34px; opacity: .5; }
.empty code { background: #eef0f5; padding: 2px 7px; border-radius: 6px; font-size: 12.5px; }

/* ---------- ページネーション ---------- */
.pager { margin-top: 18px; }
.pager nav { font-size: 13px; }

/* ---------- スレッドカード（受信トレイ） ---------- */
.thread {
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    margin-top: 14px;
}
.thread__meta { font-size: 12px; color: var(--muted-2); display: flex; gap: 8px; align-items: center; }
.thread__subject { font-weight: 600; font-size: 15px; margin: 4px 0 2px; }
.thread__snippet { font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.thread__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

.muted { color: var(--muted); }

/* ---------- スピナー ---------- */
.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -2px;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- アイコン ---------- */
.brand__mark svg { width: 18px; height: 18px; }
.stat-card__icon svg { width: 18px; height: 18px; color: var(--primary-600); }
.stat-card--reply .stat-card__icon svg { color: #b3640a; }
.stat-card--dry .stat-card__icon svg { color: #1f5fc7; }
.alert svg { flex-shrink: 0; }
.empty__icon svg { width: 30px; height: 30px; }
.btn svg { flex-shrink: 0; }

/* ---------- 認証画面 ---------- */
.auth-wrap {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 24px;
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 34px 32px;
}
.auth-brand {
    display: flex; flex-direction: column; align-items: center;
    gap: 12px; margin-bottom: 22px; text-align: center;
}
.auth-brand .brand__mark { width: 46px; height: 46px; font-size: 22px; border-radius: 14px; }
.auth-brand h1 { font-size: 19px; margin: 0; }
.auth-brand p { font-size: 13px; color: var(--muted); margin: 0; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 720px) {
    .stat-grid { grid-template-columns: 1fr; }
    .app-header__inner { padding: 0 16px; gap: 10px; }
    .nav { margin-left: 0; }
    .userbox__name { display: none; }
    .container { padding: 22px 16px 60px; }
}
