
:root {
    --brand-orange: #f47721;
    --brand-orange-hover: #df6415;
    --brand-orange-light: #fff1e6;

    --brand-black: #242424;
    --brand-gray: #666666;

    --background: #f5f4f2;
    --surface: #ffffff;
    --surface-muted: #faf9f7;

    --text-primary: #242424;
    --text-secondary: #666666;

    --border-color: #e5e3e0;
    --danger: #c93434;

    --radius: 10px;
    --shadow: 0 3px 14px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text-primary);
    font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN",
        "Meiryo", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

a {
    color: var(--brand-orange-hover);
}

/* Header */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 36px;
    background: var(--brand-black);
    color: #ffffff;
    border-bottom: 3px solid var(--brand-orange);
}

.header h1 {
    margin: 0;
    color: #ffffff;
    font-size: 25px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.header h1::before {
    content: "";
    display: inline-block;
    width: 5px;
    height: 24px;
    margin-right: 12px;
    background: var(--brand-orange);
    vertical-align: -4px;
}

.header nav {
    display: flex;
    align-items: center;
    gap: 24px;
}

.header nav a {
    color: #d2d2d2;
    text-decoration: none;
    font-weight: 600;
    padding: 8px 0;
    border-bottom: 2px solid transparent;
}

.header nav a:hover,
.header nav a[aria-current="page"] {
    color: #ffffff;
    border-bottom-color: var(--brand-orange);
}

#logout-button {
    padding: 9px 16px;
    background: transparent;
    border: 1px solid #777777;
    border-radius: 6px;
    color: #ffffff;
}

#logout-button:hover {
    background: #404040;
}

/* Main Layout */

.container {
    width: min(1160px, 94%);
    margin: 36px auto;
}

.page-heading {
    margin-bottom: 26px;
}

.page-heading h2,
.section-header h2 {
    color: var(--brand-black);
}

.page-heading h2 {
    font-size: 27px;
    margin: 0 0 8px;
}

.page-heading p {
    color: var(--text-secondary);
}

/* Sections */

.content-section {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 26px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.section-header h2 {
    margin: 0;
    font-size: 21px;
    font-weight: 700;
}

/* Summary Cards */

.summary,
.work-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}

.summary-item {
    position: relative;
    overflow: hidden;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.summary-item::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--brand-orange);
}

.summary-item p {
    margin: 0 0 10px;
    color: var(--text-secondary);
    font-size: 13px;
}

.summary-item strong {
    color: var(--brand-black);
    font-size: 28px;
    font-weight: 800;
}

/* Primary Buttons */

#add-button,
#add-grant-button,
#add-usage-button,
#search-button,
#save-button,
#grant-save-button,
#usage-save-button {
    padding: 10px 18px;
    background: var(--brand-orange);
    color: #ffffff;
    border: 1px solid var(--brand-orange);
    border-radius: 6px;
    font-weight: 700;
}

#add-button:hover,
#add-grant-button:hover,
#add-usage-button:hover,
#search-button:hover,
#save-button:hover,
#grant-save-button:hover,
#usage-save-button:hover {
    background: var(--brand-orange-hover);
    border-color: var(--brand-orange-hover);
}

/* Tables */

.table-wrapper {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #f1efec;
    color: var(--brand-black);
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

tbody tr:hover {
    background: var(--brand-orange-light);
}

tbody tr:last-child td {
    border-bottom: none;
}

.action-cell {
    display: flex;
    gap: 8px;
}

.edit-button,
.delete-button {
    padding: 6px 12px;
    border-radius: 5px;
    background: #ffffff;
}

.edit-button {
    color: var(--brand-black);
    border: 1px solid #c9c9c9;
}

.edit-button:hover {
    background: #eeeeee;
}

.delete-button {
    color: var(--danger);
    border: 1px solid #e6b0b0;
}

.delete-button:hover {
    background: #fff0f0;
}

/* Filters and Forms */

.month-filter {
    margin-bottom: 22px;
}

.month-filter-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

input,
select,
textarea {
    border: 1px solid #d5d3d0;
    border-radius: 6px;
    background: #ffffff;
    color: var(--text-primary);
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(244, 119, 33, 0.25);
    border-color: var(--brand-orange);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 12px;
}

.form-group label {
    font-weight: 600;
}

/* Modals */

dialog {
    width: min(480px, 92%);
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    background: #ffffff;
    border: none;
    border-top: 5px solid var(--brand-orange);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
}

dialog::backdrop {
    background: rgba(15, 15, 15, 0.6);
}

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

.modal-header h2 {
    margin: 0;
    color: var(--brand-black);
    font-size: 21px;
}

#close-button,
#grant-close-button,
#usage-close-button {
    border: none;
    background: transparent;
    color: var(--brand-gray);
    font-size: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

#cancel-button,
#grant-cancel-button,
#usage-cancel-button {
    padding: 10px 18px;
    background: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 6px;
    color: var(--brand-black);
}

#cancel-button:hover,
#grant-cancel-button:hover,
#usage-cancel-button:hover {
    background: #f0f0f0;
}

/* Messages */

#list-message,
#form-message,
#page-message,
#grant-form-message,
#usage-form-message {
    color: var(--danger);
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 28px;
}

/* Responsive */

@media (max-width: 700px) {
    .header {
        flex-wrap: wrap;
        gap: 12px;
        padding: 16px;
    }

    .header nav {
        order: 3;
        width: 100%;
        gap: 18px;
    }

    .container {
        margin: 22px auto;
    }

    .summary,
    .work-summary {
        grid-template-columns: 1fr;
    }

    .content-section {
        padding: 16px;
    }

    .section-header h2 {
        font-size: 18px;
    }

    th,
    td {
        padding: 10px;
    }

    dialog {
        padding: 20px;
    }
}

/* Common Form Layout */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
}

dialog form {
    margin: 0;
}

.modal-header button:hover {
    color: var(--brand-orange);
}

/* Focus and Interaction */

button:focus-visible,
a:focus-visible {
    outline: 3px solid var(--brand-orange);
    outline-offset: 3px;
}

#list-message:empty,
#form-message:empty {
    display: none;
}