* {
    box-sizing: border-box;
}

:root {
    color-scheme: light;
    --navy: #18364d;
    --navy-dark: #10293b;
    --blue: #2d6f9f;
    --blue-soft: #eaf3f9;
    --border: #dbe4ea;
    --background: #f3f6f8;
    --text: #253745;
    --muted: #667b8a;
    --success: #197344;
    --danger: #a52c2c;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--background);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP",
        "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

button,
input,
select {
    font: inherit;
}

.brand-kicker {
    margin: 0 0 5px;
    color: #6f8797;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

/* Login */
.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(24, 54, 77, .96), rgba(45, 111, 159, .90)),
        var(--navy);
}

.login-container {
    width: 100%;
    max-width: 440px;
}

.login-card {
    padding: 36px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .24);
}

.login-header h1 {
    margin: 0;
    color: var(--navy);
    font-size: 28px;
}

.login-header p:last-child {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

.login-form {
    display: grid;
    gap: 10px;
    margin-top: 28px;
}

.login-form label {
    margin-top: 8px;
    color: #405666;
    font-size: 14px;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    padding: 13px 14px;
    color: var(--text);
    background: #fff;
    border: 1px solid #bac9d3;
    border-radius: 8px;
    outline: none;
}

.login-form input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(45, 111, 159, .15);
}

.primary-button {
    margin-top: 16px;
    padding: 13px 18px;
    color: #fff;
    background: var(--blue);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
}

.primary-button:hover {
    background: #245e88;
}

.login-footer {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.login-footer a {
    color: var(--blue);
    font-size: 13px;
}

.alert {
    margin-top: 22px;
    padding: 12px 14px;
    border-radius: 8px;
    line-height: 1.6;
}

.alert-error {
    color: var(--danger);
    background: #fff0f0;
    border: 1px solid #efc4c4;
}

/* Admin */
.admin-body {
    min-width: 320px;
}

.topbar {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 12px 24px;
    color: #fff;
    background: var(--navy);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .15);
}

.topbar .brand-kicker {
    color: #a9c2d3;
}

.brand-title {
    font-size: 19px;
    font-weight: 800;
}

.account-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.account-text {
    display: grid;
    gap: 2px;
    text-align: right;
}

.account-text span {
    color: #bcd0de;
    font-size: 12px;
}

.logout-button {
    padding: 8px 13px;
    color: #fff;
    background: transparent;
    border: 1px solid #8eaaba;
    border-radius: 6px;
    cursor: pointer;
}

.logout-button:hover {
    background: rgba(255, 255, 255, .1);
}

.admin-layout {
    display: grid;
    min-height: calc(100vh - 72px);
    grid-template-columns: 230px minmax(0, 1fr);
}

.sidebar {
    padding: 22px 14px;
    background: var(--navy-dark);
}

.sidebar a {
    display: block;
    margin-bottom: 5px;
    padding: 12px 15px;
    color: #d4e1e9;
    border-radius: 7px;
    text-decoration: none;
    font-weight: 650;
}

.sidebar a:hover,
.sidebar a.active {
    color: #fff;
    background: var(--blue);
}

.admin-main {
    width: 100%;
    padding: 34px 38px 60px;
}

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

.section-label {
    margin: 0 0 7px;
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .12em;
}

.page-heading h1 {
    margin: 0;
    color: var(--navy);
    font-size: 30px;
}

.page-heading p:last-child {
    max-width: 900px;
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.8;
}

.content-card,
.next-card {
    padding: 26px 28px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(28, 52, 70, .06);
}

.content-card {
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

.status-icon {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    color: var(--success);
    background: #e8f7ef;
    border-radius: 50%;
    font-size: 22px;
    font-weight: 900;
}

.content-card h2,
.next-card h2 {
    margin: 0;
    color: var(--navy);
    font-size: 19px;
}

.content-card p,
.next-card p {
    margin: 9px 0 0;
    color: var(--muted);
    line-height: 1.8;
}

.next-card {
    margin-top: 20px;
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        padding: 14px 16px;
    }

    .account-text {
        display: none;
    }

    .admin-layout {
        display: block;
    }

    .sidebar {
        display: flex;
        overflow-x: auto;
        gap: 5px;
        padding: 10px;
    }

    .sidebar a {
        flex: 0 0 auto;
        margin: 0;
        white-space: nowrap;
    }

    .admin-main {
        padding: 26px 16px 50px;
    }

    .login-card {
        padding: 28px 22px;
    }
}

/* Application management */
.page-heading-actions {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.secondary-button {
    display: inline-block;
    flex: 0 0 auto;
    padding: 11px 16px;
    color: var(--blue);
    background: #fff;
    border: 1px solid var(--blue);
    border-radius: 8px;
    text-decoration: none;
    font-weight: 800;
}

.secondary-button:hover {
    color: #fff;
    background: var(--blue);
}

.alert-success {
    color: var(--success);
    background: #eaf8f0;
    border: 1px solid #b9dfc9;
}

.panel-card {
    margin-top: 20px;
    padding: 24px 26px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(28, 52, 70, .06);
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.panel-header h2 {
    margin: 0;
    color: var(--navy);
    font-size: 19px;
}

.panel-header p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

.upload-form {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    margin-top: 20px;
}

.file-field {
    display: grid;
    flex: 1 1 auto;
    gap: 7px;
}

.file-field label {
    color: #405666;
    font-size: 14px;
    font-weight: 800;
}

.file-field input[type="file"] {
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid #bac9d3;
    border-radius: 8px;
}

.compact-button {
    margin-top: 0;
    white-space: nowrap;
}

.format-note {
    display: grid;
    gap: 7px;
    margin-top: 18px;
    padding: 14px 16px;
    color: #526977;
    background: #f6f9fb;
    border: 1px solid #e0e8ed;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
}

.format-note code {
    color: #20384b;
    font-family: Consolas, "Courier New", monospace;
}

.table-panel {
    padding-right: 0;
    padding-left: 0;
}

.table-panel .panel-header {
    padding: 0 26px 18px;
}

.table-scroll {
    overflow-x: auto;
    border-top: 1px solid var(--border);
}

.data-table {
    width: 100%;
    min-width: 930px;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid #e6ecef;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: #405666;
    background: #f7f9fa;
    font-size: 13px;
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: #fafcfd;
}

.number-cell,
.date-cell {
    white-space: nowrap;
}

.number-cell {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

.badge {
    display: inline-block;
    min-width: 48px;
    padding: 4px 9px;
    border-radius: 999px;
    text-align: center;
    font-size: 12px;
    font-weight: 800;
}

.badge-enabled {
    color: var(--success);
    background: #e8f7ef;
}

.badge-disabled {
    color: #6b747a;
    background: #edf0f2;
}

.future-action {
    color: #8998a2;
    font-size: 12px;
    white-space: nowrap;
}

.empty-state {
    display: grid;
    gap: 7px;
    padding: 42px 26px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    text-align: center;
}

.empty-state strong {
    color: #405666;
}

@media (max-width: 760px) {
    .page-heading-actions,
    .upload-form {
        align-items: stretch;
        flex-direction: column;
    }

    .secondary-button,
    .compact-button {
        width: 100%;
        text-align: center;
    }

    .panel-card {
        padding: 20px 16px;
    }

    .table-panel {
        padding-right: 0;
        padding-left: 0;
    }

    .table-panel .panel-header {
        padding-right: 16px;
        padding-left: 16px;
    }
}

/* Application decode key and authentication reset */
.application-table {
    min-width: 1240px;
}

.key-note-card {
    padding-bottom: 20px;
}

.warning-note {
    margin-top: 16px;
    padding: 13px 15px;
    color: #6e5317;
    background: #fff8e5;
    border: 1px solid #edd394;
    border-radius: 8px;
    line-height: 1.7;
}

.table-action-form {
    margin: 0;
}

.table-action-button {
    display: inline-block;
    padding: 7px 10px;
    color: var(--blue);
    background: #fff;
    border: 1px solid #8db2cc;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}

.table-action-button:hover {
    color: #fff;
    background: var(--blue);
    border-color: var(--blue);
}

.danger-action {
    color: var(--danger);
    border-color: #d9a1a1;
}

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

.action-meta {
    display: block;
    margin-top: 6px;
    color: #738591;
    font-size: 11px;
    line-height: 1.5;
    white-space: nowrap;
}

.narrow-main {
    max-width: 900px;
}

.confirmation-card {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 20px;
}

.confirmation-card h2 {
    margin: 0;
    color: var(--navy);
    font-size: 21px;
}

.danger-icon {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    color: #fff;
    background: var(--danger);
    border-radius: 50%;
    font-size: 26px;
    font-weight: 900;
}

.confirmation-list {
    margin: 22px 0 0;
    border-top: 1px solid var(--border);
}

.confirmation-list > div {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    border-bottom: 1px solid var(--border);
}

.confirmation-list dt,
.confirmation-list dd {
    margin: 0;
    padding: 13px 15px;
}

.confirmation-list dt {
    color: #405666;
    background: #f7f9fa;
    font-weight: 800;
}

.confirmation-list dd {
    font-variant-numeric: tabular-nums;
}

.danger-note {
    color: #872727;
    background: #fff0f0;
    border-color: #e7b6b6;
}

.confirmation-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 22px;
}

.confirmation-actions form {
    margin: 0;
}

.danger-button {
    padding: 11px 16px;
    color: #fff;
    background: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
}

.danger-button:hover {
    background: #842323;
}

@media (max-width: 760px) {
    .confirmation-card {
        grid-template-columns: 1fr;
    }

    .confirmation-list > div {
        grid-template-columns: 1fr;
    }

    .confirmation-list dt {
        padding-bottom: 6px;
    }

    .confirmation-list dd {
        padding-top: 6px;
    }

    .confirmation-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .confirmation-actions .secondary-button,
    .confirmation-actions form,
    .confirmation-actions .danger-button {
        width: 100%;
        text-align: center;
    }
}

/* Organization management */
.search-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
    align-items: end;
    gap: 14px;
    margin-top: 20px;
}

.text-field {
    display: grid;
    gap: 7px;
}

.text-field label {
    color: #405666;
    font-size: 14px;
    font-weight: 800;
}

.text-field input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid #bac9d3;
    border-radius: 8px;
}

.text-field input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(45, 111, 159, .15);
    outline: none;
}

.search-actions {
    display: flex;
    align-items: center;
    gap: 9px;
}

.compact-link {
    padding-top: 10px;
    padding-bottom: 10px;
}

.selected-filter-clear-button {
    justify-self: start;
}

.organization-table {
    min-width: 1160px;
}

.code-cell {
    font-family: Consolas, "Courier New", monospace;
    white-space: nowrap;
}

.table-link {
    color: var(--blue);
    font-weight: 800;
    text-decoration: none;
}

.table-link:hover {
    text-decoration: underline;
}

.muted-text {
    color: #8998a2;
}

.list-warning {
    margin: 0 26px 18px;
}

.narrow-detail-main {
    width: 100%;
    max-width: 1040px;
}

.detail-list {
    margin: 0;
    border-top: 1px solid var(--border);
}

.detail-list > div {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    border-bottom: 1px solid var(--border);
}

.detail-list dt,
.detail-list dd {
    margin: 0;
    padding: 14px 16px;
}

.detail-list dt {
    color: #405666;
    background: #f7f9fa;
    font-weight: 800;
}

.pre-wrap {
    white-space: pre-wrap;
}

.primary-link-button {
    display: inline-block;
    padding: 11px 16px;
    color: #fff;
    background: var(--blue);
    border: 1px solid var(--blue);
    border-radius: 8px;
    text-decoration: none;
    font-weight: 800;
}

.status-change-icon {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    color: #fff;
    background: var(--blue);
    border-radius: 50%;
    font-size: 26px;
    font-weight: 900;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.summary-grid > div {
    display: grid;
    gap: 6px;
    padding: 15px 16px;
    background: #f7f9fa;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.summary-grid span {
    color: var(--muted);
    font-size: 12px;
}

.summary-grid strong {
    color: var(--navy);
    overflow-wrap: anywhere;
}

.license-preview-table {
    min-width: 1250px;
}

@media (max-width: 900px) {
    .search-form,
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .search-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .search-actions .primary-button,
    .search-actions .secondary-button {
        width: 100%;
        text-align: center;
    }

    .detail-list > div {
        grid-template-columns: 1fr;
    }

    .detail-list dt {
        padding-bottom: 6px;
    }

    .detail-list dd {
        padding-top: 6px;
    }
}

/* Serial management */
.serial-search-form {
    grid-template-columns: minmax(260px, 1fr) auto;
}

.serial-table {
    min-width: 1640px;
}

.detail-action-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

@media (max-width: 900px) {
    .serial-search-form {
        grid-template-columns: 1fr;
    }

    .detail-action-grid {
        align-items: stretch;
        flex-direction: column;
    }

    .detail-action-grid .table-action-button {
        width: 100%;
        text-align: center;
    }
}

/* Maintenance management */
.maintenance-main {
    max-width: 1180px;
}

.maintenance-current {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 18px;
    margin-bottom: 22px;
}

.maintenance-current.maintenance-off {
    border-left: 6px solid #23804b;
}

.maintenance-current.maintenance-on {
    border-left: 6px solid #b63c32;
}

.maintenance-state-icon {
    display: grid;
    width: 56px;
    height: 56px;
    place-items: center;
    color: #fff;
    background: #23804b;
    border-radius: 50%;
    font-size: 28px;
    font-weight: 900;
}

.maintenance-on .maintenance-state-icon {
    background: #b63c32;
}

.maintenance-state-label {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.maintenance-current h2 {
    margin: 0 0 8px;
    color: var(--navy);
}

.maintenance-current p {
    margin-top: 0;
}

.maintenance-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin: 14px 0 0;
}

.maintenance-meta > div {
    display: flex;
    gap: 8px;
}

.maintenance-meta dt {
    color: var(--muted);
    font-weight: 700;
}

.maintenance-meta dd {
    margin: 0;
    color: var(--text);
    font-weight: 800;
}

.maintenance-form {
    display: grid;
    gap: 24px;
}

.mode-fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

.mode-fieldset legend {
    margin-bottom: 10px;
    color: #405666;
    font-size: 14px;
    font-weight: 800;
}

.mode-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.mode-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    padding: 18px;
    background: #f7fbf8;
    border: 2px solid #c6ddd0;
    border-radius: 10px;
    cursor: pointer;
}

.mode-option.danger-option {
    background: #fff8f7;
    border-color: #e8c7c3;
}

.mode-option:has(input:checked) {
    border-color: #23804b;
    box-shadow: 0 0 0 3px rgba(35, 128, 75, .12);
}

.mode-option.danger-option:has(input:checked) {
    border-color: #b63c32;
    box-shadow: 0 0 0 3px rgba(182, 60, 50, .12);
}

.mode-option input {
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
}

.mode-option-body {
    display: grid;
    gap: 5px;
}

.mode-option-body strong {
    color: var(--navy);
    font-size: 18px;
}

.mode-option-body small {
    color: var(--muted);
    line-height: 1.6;
}

.textarea-field {
    display: grid;
    gap: 7px;
}

.textarea-field label {
    color: #405666;
    font-size: 14px;
    font-weight: 800;
}

.textarea-field textarea {
    width: 100%;
    padding: 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid #bac9d3;
    border-radius: 8px;
    resize: vertical;
    font: inherit;
    line-height: 1.7;
}

.textarea-field textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(45, 111, 159, .15);
    outline: none;
}

.textarea-field > span {
    color: var(--muted);
    font-size: 13px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 760px) {
    .maintenance-current,
    .mode-options {
        grid-template-columns: 1fr;
    }

    .maintenance-state-icon {
        width: 48px;
        height: 48px;
    }

    .form-actions .primary-button {
        width: 100%;
    }
}

/* License search filters and detail modal */
.license-filter-form {
    display: grid;
    grid-template-columns: minmax(260px, 2fr) repeat(4, minmax(150px, 1fr));
    align-items: end;
    gap: 14px;
    margin-top: 20px;
}

.license-filter-keyword {
    min-width: 0;
}

.select-field {
    display: grid;
    gap: 7px;
}

.select-field label,
.license-filter-form .text-field label {
    color: #405666;
    font-size: 14px;
    font-weight: 800;
}

.select-field select,
.license-filter-form .text-field input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid #bac9d3;
    border-radius: 8px;
    outline: none;
}

.select-field select:focus,
.license-filter-form .text-field input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(45, 111, 159, .15);
}

.license-filter-actions {
    display: flex;
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 2px;
}

.selected-organization-note {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.filter-download-note {
    margin-top: 14px;
    padding: 11px 14px;
    color: #315f7d;
    background: var(--blue-soft);
    border: 1px solid #c8ddea;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
}

.license-modal {
    width: min(1120px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    padding: 0;
    overflow: hidden;
    color: var(--text);
    background: #fff;
    border: 0;
    border-radius: 14px;
    box-shadow: 0 24px 80px rgba(10, 35, 52, .32);
}

.license-modal::backdrop {
    background: rgba(10, 27, 39, .58);
    backdrop-filter: blur(2px);
}

.license-modal-shell {
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.license-modal-loading {
    padding: 50px 30px;
    color: var(--muted);
    text-align: center;
}

.license-modal-header {
    position: sticky;
    z-index: 2;
    top: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 24px 28px 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.license-modal-header h2 {
    margin: 0;
    color: var(--navy);
    font-size: 24px;
}

.license-modal-subtitle {
    margin: 7px 0 0;
    color: var(--muted);
    font-family: Consolas, "Courier New", monospace;
}

.modal-close-button {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    color: #526977;
    background: #f4f7f9;
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    font-size: 25px;
    line-height: 1;
}

.modal-close-button:hover {
    color: #fff;
    background: var(--navy);
}

.license-modal-body {
    display: grid;
    gap: 20px;
    padding: 24px 28px;
}

.modal-section {
    padding: 20px;
    background: #fbfcfd;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.modal-section h3 {
    margin: 0 0 16px;
    color: var(--navy);
    font-size: 17px;
}

.modal-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin: 0;
}

.modal-detail-grid > div,
.modal-detail-list > div {
    display: grid;
    grid-template-columns: 145px minmax(0, 1fr);
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid #e5ebef;
}

.modal-detail-grid > div:nth-last-child(-n + 2) {
    border-bottom: 0;
}

.modal-detail-grid .modal-detail-wide {
    grid-column: 1 / -1;
}

.modal-detail-grid dt,
.modal-detail-list dt {
    color: #607684;
    font-size: 13px;
    font-weight: 800;
}

.modal-detail-grid dd,
.modal-detail-list dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.modal-two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.modal-detail-list {
    margin: 0;
}

.modal-detail-list > div:last-child {
    border-bottom: 0;
}

.modal-section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.modal-section-heading span {
    color: var(--muted);
    font-size: 12px;
}

.modal-event-scroll {
    overflow-x: auto;
}

.modal-event-table {
    width: 100%;
    min-width: 780px;
    border-collapse: collapse;
}

.modal-event-table th,
.modal-event-table td {
    padding: 10px 11px;
    border-bottom: 1px solid #e5ebef;
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
    white-space: nowrap;
}

.modal-event-table th {
    color: #526977;
    background: #f2f6f8;
}

.event-success {
    color: var(--success);
    font-weight: 800;
}

.event-failure {
    color: var(--danger);
    font-weight: 800;
}

.modal-empty-history {
    padding: 20px;
    color: var(--muted);
    text-align: center;
}

.license-modal-footer {
    position: sticky;
    z-index: 2;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 28px;
    background: #fff;
    border-top: 1px solid var(--border);
}

.modal-action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.modal-footer-close {
    flex: 0 0 auto;
    padding-top: 8px;
    padding-bottom: 8px;
    cursor: pointer;
}

body:has(.license-modal[open]) {
    overflow: hidden;
}

@media (max-width: 1180px) {
    .license-filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .license-filter-keyword {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .license-filter-form,
    .modal-two-column,
    .modal-detail-grid {
        grid-template-columns: 1fr;
    }

    .license-filter-keyword,
    .modal-detail-grid .modal-detail-wide {
        grid-column: auto;
    }

    .license-filter-actions,
    .selected-organization-note,
    .license-modal-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .selected-organization-note {
        display: flex;
    }

    .license-filter-actions .secondary-button,
    .license-filter-actions .primary-button,
    .selected-filter-clear-button,
    .modal-footer-close {
        width: 100%;
        text-align: center;
    }

    .license-modal {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
    }

    .license-modal-shell {
        max-height: calc(100vh - 16px);
    }

    .license-modal-header,
    .license-modal-body,
    .license-modal-footer {
        padding-right: 18px;
        padding-left: 18px;
    }

    .modal-detail-grid > div,
    .modal-detail-list > div {
        grid-template-columns: 1fr;
        gap: 5px;
    }
}

/* Organization search filters and detail modal */
.organization-filter-form {
    display: grid;
    grid-template-columns: minmax(300px, 2fr) repeat(2, minmax(180px, 1fr));
    align-items: end;
    gap: 14px;
    margin-top: 20px;
}

.organization-filter-keyword {
    min-width: 0;
}

.organization-filter-actions {
    display: flex;
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 2px;
}

.organization-search-table {
    min-width: 1630px;
}

.organization-search-table strong {
    color: var(--navy);
}

.organization-modal-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.organization-modal-summary > div {
    display: grid;
    gap: 7px;
    padding: 14px 15px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.organization-modal-summary span {
    color: var(--muted);
    font-size: 12px;
}

.organization-modal-summary strong {
    color: var(--navy);
    overflow-wrap: anywhere;
}

.organization-license-modal-table {
    min-width: 1220px;
}

@media (max-width: 1180px) {
    .organization-filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .organization-filter-keyword {
        grid-column: 1 / -1;
    }

    .organization-modal-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .organization-filter-form,
    .organization-modal-summary {
        grid-template-columns: 1fr;
    }

    .organization-filter-keyword {
        grid-column: auto;
    }

    .organization-filter-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .organization-filter-actions .secondary-button,
    .organization-filter-actions .primary-button {
        width: 100%;
        text-align: center;
    }
}

/* Application search filters and detail modal */
.application-filter-form {
    display: grid;
    grid-template-columns: minmax(300px, 2fr) repeat(3, minmax(170px, 1fr));
    align-items: end;
    gap: 14px;
    margin-top: 20px;
}

.application-filter-keyword {
    min-width: 0;
}

.application-filter-actions {
    display: flex;
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 2px;
}

.application-search-table {
    min-width: 1470px;
}

.application-search-table strong {
    color: var(--navy);
}

.application-key-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.application-key-summary > div {
    display: grid;
    gap: 7px;
    padding: 14px 15px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.application-key-summary span {
    color: var(--muted);
    font-size: 12px;
}

.application-key-summary strong {
    color: var(--navy);
    overflow-wrap: anywhere;
}

.application-license-modal-table {
    min-width: 1220px;
}

.application-modal .modal-action-group form {
    margin: 0;
}

@media (max-width: 1180px) {
    .application-filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .application-filter-keyword {
        grid-column: 1 / -1;
    }

    .application-key-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .application-filter-form,
    .application-key-summary {
        grid-template-columns: 1fr;
    }

    .application-filter-keyword {
        grid-column: auto;
    }

    .application-filter-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .application-filter-actions .secondary-button,
    .application-filter-actions .primary-button {
        width: 100%;
        text-align: center;
    }
}

/* Phase 11.1a: PC modal full-width layout without horizontal scrolling */
@media (min-width: 761px) {
    .license-modal {
        width: min(1600px, calc(100vw - 24px));
        max-width: none;
        box-sizing: border-box;
    }

    .license-modal-shell {
        overflow-x: hidden;
    }

    .modal-event-scroll {
        width: 100%;
        max-width: 100%;
        overflow-x: visible;
    }

    .modal-event-table,
    .organization-license-modal-table,
    .application-license-modal-table {
        width: 100%;
        min-width: 0;
        table-layout: fixed;
    }

    .modal-event-table th,
    .modal-event-table td {
        min-width: 0;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
        line-height: 1.45;
    }

    .modal-event-table .code-cell,
    .modal-event-table .number-cell,
    .modal-event-table .action-meta {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .license-modal-header > div,
    .license-modal-body,
    .modal-section,
    .modal-section-heading,
    .license-modal-footer,
    .modal-action-group {
        min-width: 0;
        max-width: 100%;
    }
}

/* Phase 11.2: authentication history search */
.license-event-filter-form {
    display: grid;
    grid-template-columns: minmax(280px, 2fr) repeat(3, minmax(155px, 1fr)) repeat(2, minmax(150px, .9fr));
    align-items: end;
    gap: 14px;
    margin-top: 20px;
}

.license-event-filter-keyword {
    min-width: 0;
}

.license-event-filter-form .text-field label {
    color: #405666;
    font-size: 14px;
    font-weight: 800;
}

.license-event-filter-form .text-field input {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid #bac9d3;
    border-radius: 8px;
    outline: none;
}

.license-event-filter-form .text-field input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(45, 111, 159, .15);
}

.license-event-filter-actions {
    display: flex;
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 2px;
}

.license-event-history-table {
    min-width: 0;
    table-layout: fixed;
}

.license-event-history-table th:nth-child(1) { width: 135px; }
.license-event-history-table th:nth-child(2) { width: 112px; }
.license-event-history-table th:nth-child(3) { width: 190px; }
.license-event-history-table th:nth-child(4) { width: 180px; }
.license-event-history-table th:nth-child(5) { width: 145px; }
.license-event-history-table th:nth-child(6) { width: 95px; }
.license-event-history-table th:nth-child(7) { width: 180px; }
.license-event-history-table th:nth-child(8) { width: 125px; }

.license-event-history-table td {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.45;
}

.event-type-label {
    display: block;
    margin-bottom: 4px;
    color: #405666;
    font-size: 12px;
    font-weight: 800;
}

@media (max-width: 1180px) {
    .license-event-filter-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .license-event-filter-keyword {
        grid-column: span 2;
    }
}

@media (max-width: 760px) {
    .license-event-filter-form {
        grid-template-columns: 1fr;
    }

    .license-event-filter-keyword {
        grid-column: auto;
    }

    .license-event-filter-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .license-event-filter-actions .secondary-button,
    .license-event-filter-actions .primary-button {
        width: 100%;
        text-align: center;
    }

    .license-event-table-scroll {
        overflow-x: auto;
    }

    .license-event-history-table {
        min-width: 1050px;
        table-layout: auto;
    }
}

/* License individual edit */
.license-edit-main {
    width: 100%;
    max-width: 1120px;
}

.license-edit-form {
    display: grid;
    gap: 22px;
}

.license-edit-readonly {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    align-items: center;
    gap: 6px 18px;
    padding: 16px 18px;
    background: #f7f9fa;
    border: 1px solid var(--border);
    border-radius: 9px;
}

.license-edit-readonly > span {
    color: #405666;
    font-weight: 800;
}

.license-edit-readonly > strong {
    color: var(--navy);
    font-size: 17px;
}

.license-edit-readonly > small {
    grid-column: 2;
    color: var(--muted);
}

.license-edit-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.license-edit-wide-field {
    grid-column: 1 / -1;
}

.license-edit-warning {
    align-items: start;
}

.license-edit-actions {
    align-items: center;
    gap: 12px;
}

@media (max-width: 760px) {
    .license-edit-grid {
        grid-template-columns: 1fr;
    }

    .license-edit-wide-field {
        grid-column: auto;
    }

    .license-edit-readonly {
        grid-template-columns: 1fr;
    }

    .license-edit-readonly > small {
        grid-column: auto;
    }

    .license-edit-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .license-edit-actions .secondary-button,
    .license-edit-actions .primary-button {
        width: 100%;
        text-align: center;
    }
}

/* Phase 12.5: operation log management */
.audit-log-filter-form {
    display: grid;
    grid-template-columns: minmax(280px, 2fr) repeat(3, minmax(145px, 1fr));
    align-items: end;
    gap: 14px;
    margin-top: 20px;
}

.audit-log-filter-keyword {
    min-width: 0;
    grid-column: span 2;
}

.audit-log-filter-form .text-field label {
    color: #405666;
    font-size: 14px;
    font-weight: 800;
}

.audit-log-filter-form .text-field input {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid #bac9d3;
    border-radius: 8px;
    outline: none;
}

.audit-log-filter-form .text-field input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(45, 111, 159, .15);
}

.audit-log-filter-actions {
    display: flex;
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 2px;
}

.audit-log-table-scroll {
    overflow-x: auto;
}

.audit-log-history-table {
    width: 100%;
    min-width: 1380px;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}

/* 操作概要だけが横に広がりすぎないよう、一覧全体の列幅を再配分する。 */
.audit-log-history-table th:nth-child(1) { width: 150px; }
.audit-log-history-table th:nth-child(2) { width: 140px; }
.audit-log-history-table th:nth-child(3) { width: 165px; }
.audit-log-history-table th:nth-child(4) { width: 95px; }
.audit-log-history-table th:nth-child(5) { width: 42%; }
.audit-log-history-table th:nth-child(6) {
    width: 155px;
    text-align: center;
}
.audit-log-history-table th:nth-child(7) {
    width: 95px;
    text-align: center;
}

.audit-log-history-table th,
.audit-log-history-table td {
    padding: 11px 12px;
}

.audit-log-history-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #eef3f6;
    border-bottom: 1px solid #cfdbe2;
    font-size: 12px;
    letter-spacing: .02em;
}

.audit-log-history-table td {
    min-width: 0;
    color: #314857;
    vertical-align: top;
    line-height: 1.45;
}

.audit-log-history-table tbody tr:nth-child(even) {
    background: #f8fafb;
}

.audit-log-history-table tbody tr:hover {
    background: #edf5fa;
}

.audit-log-history-table tbody tr:last-child td {
    border-bottom: 0;
}

.audit-log-date-cell,
.audit-log-ip-cell {
    font-variant-numeric: tabular-nums;
}

.audit-log-date-cell {
    color: #405666;
    font-size: 12px;
    white-space: nowrap;
    word-break: normal;
}

.audit-log-admin-cell strong,
.audit-log-action-cell strong {
    display: block;
    color: #20384b;
    line-height: 1.35;
}

.audit-log-admin-cell strong {
    white-space: nowrap;
}

.audit-log-action-cell strong {
    font-size: 13px;
}

.audit-log-subtext {
    display: block;
    margin-top: 3px;
    color: #778a96;
    font-size: 11px;
    line-height: 1.3;
    white-space: nowrap;
}

.audit-log-target-label {
    display: inline-block;
    min-width: 48px;
    padding: 3px 8px;
    color: #315a76;
    background: #eaf3f8;
    border: 1px solid #d4e5ef;
    border-radius: 999px;
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.audit-log-summary-cell {
    color: #405666;
}

.audit-log-summary-cell > span {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.audit-log-history-table th:nth-child(6),
.audit-log-ip-cell {
    border-left: 1px solid #dfe7ec;
}

.audit-log-ip-cell {
    padding-right: 18px !important;
    padding-left: 18px !important;
    color: #526977;
    text-align: center !important;
    white-space: nowrap;
}

.audit-log-detail-cell {
    padding-right: 18px !important;
    padding-left: 12px !important;
    text-align: center !important;
    vertical-align: middle !important;
}

.audit-log-detail-cell .compact-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    min-width: 60px;
    padding: 7px 8px;
}

.audit-log-pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 14px;
    padding: 18px 26px 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.audit-log-pagination > div:last-child {
    text-align: right;
}

.disabled-link {
    color: #91a0aa;
    background: #f5f7f8;
    border-color: #d8e0e5;
    pointer-events: none;
}

.audit-log-modal .license-modal-shell {
    max-width: 1500px;
}

.audit-log-overview-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.audit-log-change-scroll {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.audit-log-change-table {
    min-width: 0;
    table-layout: fixed;
}

.audit-log-change-table th:nth-child(1) { width: 24%; }
.audit-log-change-table th:nth-child(2),
.audit-log-change-table th:nth-child(3) { width: 38%; }

.audit-log-change-table th,
.audit-log-change-table td {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.audit-log-change-table tbody th {
    color: #405666;
    background: #f7f9fa;
}

.audit-log-privacy-note {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.audit-log-additional-list dd,
.audit-log-user-agent {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.audit-log-user-agent {
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
}

@media (max-width: 1180px) {
    .audit-log-filter-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .audit-log-filter-keyword {
        grid-column: span 2;
    }
}

@media (max-width: 760px) {
    .audit-log-filter-form {
        grid-template-columns: 1fr;
    }

    .audit-log-filter-keyword {
        grid-column: auto;
    }

    .audit-log-filter-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .audit-log-filter-actions .secondary-button,
    .audit-log-filter-actions .primary-button {
        width: 100%;
        text-align: center;
    }

    .audit-log-pagination {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .audit-log-pagination > div,
    .audit-log-pagination > div:last-child {
        text-align: center;
    }

    .audit-log-overview-grid {
        grid-template-columns: 1fr;
    }
}

/* Phase 12.6: 個別新規登録・安全な削除 */
.page-heading-button-group {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 760px) {
    .page-heading-button-group {
        width: 100%;
        justify-content: flex-start;
    }
}
