:root {
    --page-bg: #050806;
    --surface: #0d1512;
    --surface-strong: #13231d;
    --text: #e9f4ef;
    --muted: #9bb2aa;
    --line: rgba(56, 180, 139, 0.24);
    --line-strong: rgba(56, 180, 139, 0.46);
    --accent: #38b48b;
    --accent-strong: #38b48b;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--page-bg);
}

body:not(.login-page) {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        linear-gradient(135deg, rgba(56, 180, 139, 0.16), transparent 34%),
        linear-gradient(315deg, rgba(10, 16, 14, 0.88), transparent 36%),
        var(--page-bg);
    font-family: "Segoe UI", "Yu Gothic UI", "Yu Gothic", Meiryo, Arial, sans-serif;
    letter-spacing: 0;
}

button,
input,
a {
    font: inherit;
}

.work-shell {
    width: min(100%, 1480px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.portal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    background: rgba(13, 21, 18, 0.88);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(22, 34, 51, 0.08);
    backdrop-filter: blur(12px);
}

.portal-kicker {
    margin: 0 0 5px;
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 700;
}

h1,
h2 {
    margin: 0;
    line-height: 1.18;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(26px, 3.1vw, 40px);
    font-weight: 800;
}

h2 {
    font-size: 18px;
    font-weight: 800;
}

.portal-login,
.portal-button,
#loginButton {
    min-height: 46px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.portal-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.member-session {
    min-height: 42px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.portal-secondary-action,
.portal-change-action,
.portal-logout,
.portal-work-logout {
    min-height: 42px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}

.portal-secondary-action {
    color: #06100c;
    background: var(--accent);
    border: 1px solid var(--accent);
}

.portal-change-action {
    color: #111004;
    background: #f4d35e;
    border: 1px solid #f4d35e;
}

.portal-logout {
    color: #ffd9de;
    background: rgba(183, 43, 65, 0.16);
    border: 1px solid rgba(255, 141, 158, 0.36);
}

.portal-work-logout {
    color: #04100c;
    background: var(--accent);
    border: 1px solid var(--accent);
}

.portal-secondary-action:hover,
.portal-secondary-action:focus-visible {
    background: #54c59d;
}

.portal-change-action:hover,
.portal-change-action:focus-visible {
    background: #ffe176;
}

.portal-logout:hover,
.portal-logout:focus-visible {
    background: rgba(183, 43, 65, 0.24);
}

.portal-work-logout:hover,
.portal-work-logout:focus-visible {
    background: #54c59d;
}

.portal-login {
    flex: 0 0 auto;
    min-width: 112px;
    padding: 0 18px;
    color: #ffffff;
    background: #17211d;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
}

.portal-login:hover,
.portal-login:focus-visible,
#loginButton:hover,
#loginButton:focus-visible {
    background: var(--accent-strong);
}

.portal-login:focus-visible,
.portal-button:focus-visible,
.portal-secondary-action:focus-visible,
.portal-change-action:focus-visible,
.portal-logout:focus-visible,
.portal-work-logout:focus-visible,
#loginButton:focus-visible,
.close:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(15, 143, 140, 0.24);
    outline-offset: 2px;
}

.portal-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.38fr) minmax(340px, 0.62fr);
    gap: 16px;
}

.calendar-panel,
.link-panel {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(13, 21, 18, 0.92);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel-heading {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.iframe-embed {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 620px;
    border: 0;
    background: var(--surface);
}

.link-panel {
    background: var(--surface-strong);
}

.buttons {
    min-height: 0;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-content: start;
    overflow: auto;
}

.portal-button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 52px;
    min-height: 52px;
    padding: 8px 12px 8px 18px;
    color: var(--button-text, var(--text));
    background: var(--button-bg, var(--surface));
    border-color: var(--button-border, var(--line));
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
    font-weight: 700;
    text-align: center;
    line-height: 1.16;
    white-space: normal;
    overflow-wrap: anywhere;
    overflow: hidden;
}

.portal-button::before {
    content: "";
    position: absolute;
    inset: 8px auto 8px 8px;
    width: 5px;
    border-radius: 4px;
    background: var(--button-accent, var(--accent));
}

.portal-button:hover,
.portal-button:focus-visible {
    transform: translateY(-1px);
    border-color: var(--button-accent, var(--line-strong));
    background: var(--button-hover, var(--button-bg, var(--surface)));
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.style-hk {
    --button-bg: #10221c;
    --button-border: rgba(56, 180, 139, 0.46);
    --button-accent: #38b48b;
    --button-text: #dff8ee;
    --button-hover: #153126;
}

.style-teams {
    --button-bg: #11172a;
    --button-border: #5660aa;
    --button-accent: #545edb;
    --button-text: #e3e6ff;
    --button-hover: #17203a;
}

.style-rc {
    --button-bg: #0d2230;
    --button-border: #3488a6;
    --button-accent: #168ab8;
    --button-text: #dff5ff;
    --button-hover: #113149;
}

.style-gs {
    --button-bg: #0d1f31;
    --button-border: #3c86c4;
    --button-accent: #1f83d2;
    --button-text: #dcebff;
    --button-hover: #112d48;
}

.style-pu {
    --button-bg: #2a210b;
    --button-border: #8f771f;
    --button-accent: #e2a90f;
    --button-text: #fff2bd;
    --button-hover: #362c0f;
}

.style-fu {
    --button-bg: #0e2030;
    --button-border: #4d7fae;
    --button-accent: #1d6fb8;
    --button-text: #dcecff;
    --button-hover: #122c43;
}

.style-vd {
    --button-bg: #111b25;
    --button-border: #4c6379;
    --button-accent: #6fa0cf;
    --button-text: #e2edf7;
    --button-hover: #172637;
}

.style-pm {
    --button-bg: #2b1a0a;
    --button-border: #a96724;
    --button-accent: #e58a1f;
    --button-text: #ffe4c2;
    --button-hover: #3a240d;
}

.style-nt {
    --button-bg: #15191f;
    --button-border: #4b5563;
    --button-accent: #9aa4b2;
    --button-text: #eef2f6;
    --button-hover: #1e242c;
}

.style-dc {
    --button-bg: #2b160d;
    --button-border: #a15d3b;
    --button-accent: #e36a2e;
    --button-text: #ffe1d2;
    --button-hover: #3a1f12;
}

.style-sl {
    --button-bg: #291422;
    --button-border: #9d5c84;
    --button-accent: #e1185a;
    --button-text: #ffe5f1;
    --button-hover: #381b2e;
}

.style-sl::before {
    background: linear-gradient(180deg, #33c6f0 0%, #e1185a 34%, #edb42a 67%, #2ab77e 100%);
}

.footer {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.66);
}

.modal-content {
    position: relative;
    width: min(100%, 460px);
    padding: 28px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.44);
}

.modal-header {
    padding-right: 36px;
    margin-bottom: 20px;
}

.modal-kicker {
    margin: 0 0 6px;
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 800;
}

.modal-header h2 {
    font-size: 26px;
}

.modal-header p:last-child {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.modal-body {
    display: grid;
    gap: 10px;
}

.field-label {
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
}

.close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.close:hover {
    color: var(--text);
    background: var(--surface-strong);
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    min-height: 48px;
    padding: 10px 13px;
    color: var(--text);
    background: #060b09;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 16px;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(15, 143, 140, 0.12);
}

input[readonly] {
    color: var(--muted);
    background: var(--surface-strong);
}

select:disabled,
#loginButton:disabled {
    color: var(--muted);
    background: #111a16;
    border-color: var(--line);
    box-shadow: none;
    cursor: not-allowed;
}

input.is-invalid {
    border-color: #d14c4c;
    box-shadow: 0 0 0 4px rgba(209, 76, 76, 0.12);
}

.login-error {
    display: none;
    margin: 2px 0 0;
    padding: 10px 12px;
    color: #ffd7d7;
    background: rgba(183, 43, 43, 0.18);
    border: 1px solid rgba(240, 120, 120, 0.36);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.45;
}

.login-error.is-visible {
    display: block;
}

#loginButton {
    width: 100%;
    min-height: 48px;
    margin-top: 6px;
    padding: 0 18px;
    color: #04100c;
    background: var(--accent);
    font-weight: 800;
}

#loginButton:disabled,
#loginButton:disabled:hover,
#loginButton:disabled:focus-visible {
    color: var(--muted);
    background: #111a16;
    border-color: var(--line);
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
}

.password-page {
    min-height: 100vh;
}

.login-page {
    min-height: 100vh;
}

.login-shell {
    width: min(100%, 760px);
    min-height: calc(100vh - 150px);
    margin: 0 auto;
    padding: 24px;
    display: grid;
    place-items: center;
}

.login-panel {
    width: 100%;
    padding: 28px;
    background: rgba(13, 21, 18, 0.9);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

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

.login-session {
    margin-bottom: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.login-session span {
    min-height: 32px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    color: #dff8ee;
    background: rgba(56, 180, 139, 0.14);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
}

.login-form {
    margin-top: 14px;
}

.login-destinations {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.login-destination {
    min-height: 84px;
    padding: 14px;
    display: grid;
    align-content: start;
    gap: 6px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.login-destination strong {
    font-size: 14px;
}

.login-destination span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.admin-page,
.password-shell {
    min-height: 100vh;
}

.password-shell {
    width: min(100%, 560px);
    margin: 0 auto;
    padding: 24px;
    display: grid;
    place-items: center;
}

.admin-shell {
    width: min(100%, 1220px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 24px;
}

.admin-panel,
.password-panel {
    width: 100%;
    padding: 28px;
    background: rgba(13, 21, 18, 0.94);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.admin-panel h1,
.password-panel h1 {
    margin-top: 0;
    font-size: 32px;
}

.password-lead {
    margin: 10px 0 18px;
    color: var(--muted);
    line-height: 1.65;
}

.password-notice,
.password-success {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.45;
}

.password-notice {
    color: #fff2bd;
    background: rgba(226, 169, 15, 0.16);
    border: 1px solid rgba(237, 207, 107, 0.42);
}

.password-success {
    color: #dcfff0;
    background: rgba(56, 180, 139, 0.16);
    border: 1px solid var(--line-strong);
}

.password-form {
    display: grid;
    gap: 10px;
}

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

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

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

.admin-status-card {
    min-height: 86px;
    padding: 16px;
    display: grid;
    align-content: space-between;
    background: linear-gradient(180deg, #13231d 0%, #0d1512 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.admin-status-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.admin-status-card strong {
    color: var(--text);
    font-size: 30px;
    line-height: 1;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.38fr) minmax(0, 0.62fr);
    gap: 16px;
    align-items: start;
}

.admin-card {
    min-width: 0;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.admin-card h2 {
    margin-bottom: 14px;
}

.admin-help {
    margin: -2px 0 2px;
    color: #ffb6c0;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.5;
}

.admin-card-wide {
    overflow: hidden;
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-size: 13px;
}

.admin-table th,
.admin-table td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.admin-table th {
    color: var(--muted);
    background: var(--surface-strong);
    font-weight: 800;
}

.admin-table td {
    overflow-wrap: anywhere;
}

.admin-table tr.is-disabled-user td {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
}

.admin-badge {
    min-width: 62px;
    min-height: 26px;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface-strong);
    border: 1px solid var(--line);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.admin-badge.is-active {
    color: #dff8ee;
    background: rgba(56, 180, 139, 0.14);
    border-color: var(--line-strong);
}

.admin-badge.is-master {
    color: #dcebff;
    background: rgba(31, 131, 210, 0.14);
    border-color: rgba(100, 168, 230, 0.38);
}

.admin-badge.is-warning {
    color: #fff2bd;
    background: rgba(226, 169, 15, 0.16);
    border-color: rgba(237, 207, 107, 0.42);
}

.admin-badge.is-muted {
    color: var(--muted);
}

.password-links {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    text-align: center;
}

.password-links a {
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}

.password-links a:hover,
.password-links a:focus-visible {
    text-decoration: underline;
}

@media (max-width: 980px) {
    .work-shell {
        padding: 16px;
    }

    .portal-grid {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(420px, 52vh) auto;
    }

    .iframe-embed {
        min-height: 0;
    }

    .buttons {
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 620px) {
    body {
        background: var(--page-bg);
    }

    .work-shell {
        padding: 10px;
        gap: 10px;
    }

    .portal-header {
        align-items: flex-start;
        padding: 14px;
    }

    .portal-kicker {
        font-size: 12px;
    }

    h1 {
        font-size: 26px;
    }

    .portal-login {
        min-width: 88px;
        min-height: 42px;
        padding: 0 12px;
    }

    .portal-actions {
        flex-direction: row;
        align-items: flex-end;
        justify-content: flex-end;
        gap: 8px;
    }

    .member-session,
    .portal-secondary-action,
    .portal-change-action,
    .portal-work-logout {
        min-height: 38px;
        padding: 0 10px;
    }

    .portal-grid {
        gap: 10px;
        grid-template-rows: minmax(360px, 50vh) auto;
    }

    .panel-heading {
        min-height: 48px;
        padding: 12px 14px;
    }

    h2 {
        font-size: 16px;
    }

    .buttons {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 10px;
    }

    .portal-button {
        height: 52px;
        min-height: 52px;
    }

    .modal {
        padding: 12px;
    }

    .modal-content {
        padding: 24px 18px 18px;
    }

    .modal-header h2 {
        font-size: 22px;
    }

    .password-shell {
        padding: 12px;
    }

    .login-shell {
        padding: 12px;
    }

    .login-panel {
        padding: 22px 18px;
    }

    .login-header {
        display: grid;
    }

    .login-destinations {
        grid-template-columns: 1fr;
    }

    .admin-shell {
        padding: 12px;
    }

    .admin-panel,
    .password-panel {
        padding: 22px 18px;
    }

    .admin-header {
        display: grid;
    }

    .admin-actions {
        justify-content: flex-start;
    }

    .admin-status-grid {
        grid-template-columns: 1fr;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .footer {
        padding-bottom: 4px;
    }
}
