:root {
    --erp-primary: #1e3a8a;
    --erp-primary-hover: #1d4ed8;
    --erp-primary-light: #dbeafe;

    --erp-border: #cbd5e1;
    --erp-border-light: #dbe5f0;

    --erp-text: #1f2937;
    --erp-muted: #64748b;

    --erp-background: #ffffff;
    --erp-panel-background: #eff6ff;

    --erp-list-row-height: 30px;
    --erp-list-cell-padding-y: 4px;
    --erp-list-cell-padding-x: 7px;
}

/*
 * ERP画面全体
 */
.erp-page {
    width: 100%;
    color: var(--erp-text);
    font-size: 14px;
}

.erp-page-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
}

.erp-page-title {
    margin: 0;
    color: #1e3a5f;
    font-size: 22px;
    font-weight: 700;
}

.erp-page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
}

/*
 * 共通操作パネル
 */
.erp-toolbar {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 6px;

    margin-bottom: 8px;
    padding: 7px 8px;

    background: var(--erp-panel-background);
    border: 1px solid #bfdbfe;
    border-radius: 6px;
}

.erp-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.erp-field label {
    color: #334155;
    font-size: 11px;
    font-weight: 700;
}

/*
 * 通常入力欄
 */
.erp-input,
.erp-select,
.erp-textarea {
    width: 100%;
    min-height: 29px;
    padding: 2px 6px;

    border: 1px solid #94a3b8;
    border-radius: 4px;

    background: #ffffff;
    color: var(--erp-text);

    font-family: inherit;
    font-size: 14px;
}

.erp-input,
.erp-select {
    height: 29px;
}

.erp-textarea {
    min-height: 29px;
    resize: vertical;
}

.erp-input:focus,
.erp-select:focus,
.erp-textarea:focus {
    outline: 2px solid #93c5fd;
    outline-offset: 0;
    border-color: #2563eb;
}

.erp-input[readonly] {
    background: #f8fafc;
    color: #64748b;
}

/*
 * 共通ボタン
 */
.erp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 29px;
    padding: 4px 10px;

    border: 1px solid var(--erp-primary);
    border-radius: 4px;

    background: var(--erp-primary);
    color: #ffffff;

    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;

    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.erp-button:hover {
    background: var(--erp-primary-hover);
}

.erp-button-secondary {
    background: #ffffff;
    color: var(--erp-primary);
}

.erp-button-secondary:hover {
    background: var(--erp-primary-light);
}

.erp-button-danger {
    border-color: #dc2626;
    background: #ffffff;
    color: #b91c1c;
}

.erp-button-danger:hover {
    background: #fef2f2;
}

/*
 * 伝票ヘッダー
 */
.erp-slip-header {
    display: grid;
    grid-template-columns:
        minmax(120px, 0.8fr)
        minmax(135px, 0.9fr)
        minmax(260px, 2fr)
        minmax(190px, 1.4fr);
    gap: 5px 8px;

    margin-bottom: 6px;
    padding: 7px 8px;

    border: 1px solid var(--erp-border-light);
    border-radius: 5px;

    background: #ffffff;
}

.erp-slip-field {
    min-width: 0;
}

.erp-slip-field label {
    display: block;
    margin-bottom: 2px;

    color: #334155;
    font-size: 11px;
    font-weight: 700;
}

.erp-slip-note {
    grid-column: 1 / -1;
}

/*
 * 共通テーブル
 */
.erp-table-wrapper {
    overflow-x: auto;

    background: #ffffff;
    border: 1px solid var(--erp-border);
}

.erp-table {
    width: 100%;
    min-width: 1050px;

    border-collapse: collapse;
    table-layout: fixed;

    font-size: 12px;
}

.erp-table th {
    height: 27px;
    padding: 3px 4px;

    border: 1px solid var(--erp-border);

    background: #f1f5f9;
    color: #334155;

    font-size: 11px;
    line-height: 1.1;
    white-space: nowrap;
}

.erp-table td {
    height: 28px;
    padding: 2px 3px;

    border: 1px solid var(--erp-border);

    background: #ffffff;
    vertical-align: middle;

    font-size: 12px;
    line-height: 1.1;
}

.erp-table tbody tr:hover td {
    background: #f8fbff;
}

/*
 * システム共通・高密度一覧
 * マスター、履歴、集計、伝票明細などの表をコンパクト表示する。
 * 月間カレンダー等、高さ自体に意味がある表は対象外。
 */
.main-content table:not(.erp-table):not(.calendar):not(.calendar-table):not(.schedule-calendar) {
    font-size: 13px;
}

.main-content table:not(.erp-table):not(.calendar):not(.calendar-table):not(.schedule-calendar) th,
.main-content table:not(.erp-table):not(.calendar):not(.calendar-table):not(.schedule-calendar) td {
    height: var(--erp-list-row-height) !important;
    padding:
        var(--erp-list-cell-padding-y)
        var(--erp-list-cell-padding-x) !important;
    line-height: 1.25 !important;
    vertical-align: middle;
}

.main-content table:not(.erp-table):not(.calendar):not(.calendar-table):not(.schedule-calendar) th {
    font-size: 12px;
    white-space: nowrap;
}

.main-content table .button,
.main-content table button,
.main-content table .erp-button {
    min-height: 27px !important;
    padding: 3px 8px !important;
    font-size: 12px !important;
    line-height: 1 !important;
}

.main-content table input:not([type="checkbox"]):not([type="radio"]),
.main-content table select {
    min-height: 26px !important;
    height: 26px !important;
    padding: 1px 5px !important;
    font-size: 12px !important;
}

.main-content table input[type="checkbox"],
.main-content table input[type="radio"] {
    margin: 0;
    vertical-align: middle;
}

.erp-table input,
.erp-table select {
    width: 100%;
    height: 23px;
    min-height: 23px;
    padding: 1px 4px;

    border: 1px solid #94a3b8;
    border-radius: 2px;

    background: #ffffff;

    font-family: inherit;
    font-size: 11px;
}

.erp-cell-center {
    text-align: center;
}

.erp-cell-number {
    text-align: right;
}

/*
 * 画面下部操作
 */
.erp-save-area {
    position: sticky;
    bottom: 0;
    z-index: 45;

    display: flex;
    justify-content: flex-end;
    gap: 6px;

    margin-top: 7px;
    padding: 6px 7px;

    background: rgba(239, 246, 255, 0.97);
    border: 1px solid #bfdbfe;
    border-radius: 6px;
}

.erp-updated-at {
    margin-right: auto;

    color: var(--erp-muted);
    font-size: 11px;
}

/*
 * 狭い画面
 */
@media (max-width: 900px) {
    .erp-slip-header {
        grid-template-columns:
            minmax(130px, 1fr)
            minmax(180px, 2fr);
    }

    .erp-slip-note {
        grid-column: 1 / -1;
    }
}

@media (max-width: 600px) {
    .erp-page-title-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .erp-slip-header {
        grid-template-columns: 1fr;
    }

    .erp-slip-note {
        grid-column: auto;
    }
}
