:root {
    --primary-600: #3460FB;
    --primary-900: #0017C1;
    --bg: #F8F8FB;
    --control: #F1F1F4;
    --text: #000;
    --label: #626264;
    --success: #197A4B;
    --error: #CE0000;
    --negative: #FE3939;
    --border: #E4E4EA;
    --shadow: 0 2px 8px rgba(0, 23, 193, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

/* ===== ログイン画面 ===== */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #EAF0FF 0%, #F8F8FB 100%);
}
.login-card {
    width: 100%;
    max-width: 360px;
    margin: 24px;
    padding: 32px 28px;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.login-title {
    margin: 0 0 24px;
    font-size: 20px;
    color: var(--primary-900);
    text-align: center;
    line-height: 1.4;
}
.login-title span { font-size: 14px; color: var(--label); font-weight: normal; }

/* ===== ヘッダ ===== */
.app-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
}
.app-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.app-title { margin: 0; font-size: 18px; color: var(--primary-900); }
.domain-tag {
    font-size: 13px;
    color: var(--label);
    background: var(--control);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: normal;
}
.app-user { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--label); font-size: 13px; }

/* ===== メイン ===== */
.app-main { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ===== タブ ===== */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}
.tab {
    background: none;
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    color: var(--label);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.tab:hover { color: var(--text); }
.tab-active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-600);
    font-weight: 600;
}
.panel.hidden { display: none; }
.panel-title { margin: 0 0 16px; font-size: 16px; }

/* ===== パネル ===== */
.panel-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

/* ===== テーブル ===== */
.table-wrap {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
th {
    background: var(--control);
    color: var(--label);
    font-weight: 600;
    font-size: 12px;
}
tr:last-child td { border-bottom: none; }
.th-actions { text-align: right; width: 280px; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 4px; }
.loading {
    text-align: center;
    color: var(--label);
    padding: 32px;
}

/* ===== ボタン ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}
.btn-primary {
    background: var(--primary-600);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-900); }
.btn-ghost {
    background: #fff;
    border-color: var(--border);
    color: var(--text);
}
.btn-ghost:hover { background: var(--control); }
.btn-danger {
    background: #fff;
    border-color: var(--negative);
    color: var(--negative);
}
.btn-danger:hover { background: var(--negative); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== フォーム ===== */
.field {
    display: block;
    margin-bottom: 16px;
}
.field > span {
    display: block;
    font-size: 12px;
    color: var(--label);
    margin-bottom: 4px;
}
.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
.field input:focus,
.field textarea:focus {
    outline: 2px solid var(--primary-600);
    outline-offset: -1px;
    border-color: var(--primary-600);
}
.field-check { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.input-with-suffix {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}
.input-with-suffix input {
    border: none !important;
    flex: 1;
    background: transparent;
}
.input-with-suffix .suffix {
    padding: 8px 12px;
    background: var(--control);
    color: var(--label);
    font-size: 13px;
    border-left: 1px solid var(--border);
    display: flex;
    align-items: center;
}

/* ===== アラート ===== */
.alert {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
}
.alert-error { background: #FFEEEE; color: var(--error); border: 1px solid #FFD0D0; }

/* ===== バッジ ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.badge-ok { background: #E4F4EC; color: var(--success); }
.badge-ng { background: #FFEEEE; color: var(--error); }

/* ===== モーダル ===== */
.modal {
    border: none;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    max-width: 480px;
    width: 90%;
}
.modal::backdrop { background: rgba(0, 0, 0, 0.4); }
.modal-form { padding: 24px 24px 20px; }
.modal-title { margin: 0 0 16px; font-size: 16px; color: var(--primary-900); }
.modal-subject {
    margin: 0 0 16px;
    padding: 8px 12px;
    background: var(--control);
    border-radius: 6px;
    font-size: 13px;
    color: var(--label);
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ===== トースト ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    z-index: 1000;
    background: #333;
    color: #fff;
    transition: opacity 0.2s, transform 0.2s;
}
.toast.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(8px); }
.toast.ok { background: var(--success); }
.toast.ng { background: var(--error); }

/* ===== レスポンシブ ===== */
@media (max-width: 720px) {
    .app-header-inner, .app-main { padding-left: 16px; padding-right: 16px; }
    .th-actions { width: auto; }
    td.actions { text-align: left; padding-top: 0; }
    .mail-table thead { display: none; }
    .mail-table tr {
        display: block;
        padding: 12px 16px;
        border-bottom: 1px solid var(--border);
    }
    .mail-table tr:last-child { border-bottom: none; }
    .mail-table td {
        display: block;
        border-bottom: none;
        padding: 2px 0;
    }
    .mail-table td::before {
        content: attr(data-label);
        font-size: 11px;
        color: var(--label);
        display: block;
    }
}
