@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700;900&display=swap");

:root {
    --brand: #005798;
    --brand-strong: #004a82;
    --brand-soft: #e7f2fb;
    --surface: #ffffff;
    --surface-muted: #f2f2f2;
    --surface-subtle: #f8fafc;
    --text: #212121;
    --muted: #5d5d5d;
    --subtle: #808080;
    --border: #d7d7d7;
    --border-soft: #e6e6e6;
    --success: #65a468;
    --warning: #d0a830;
    --danger: #cf5353;
    --danger-strong: #b94343;
    --shadow: 0 12px 30px rgba(33, 33, 33, 0.08);
    --shadow-soft: 0 4px 14px rgba(33, 33, 33, 0.06);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--surface-muted);
    color: var(--text);
    font-family: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

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

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 18px;
    font-size: 28px;
    line-height: 1.25;
    font-weight: 900;
}

h2 {
    margin-bottom: 14px;
    font-size: 18px;
    line-height: 1.35;
}

.app-page {
    padding: 28px;
}

.page-wrap {
    width: min(100%, 1120px);
    margin: 0 auto;
}

.narrow-wrap {
    width: min(100%, 760px);
    margin: 0 auto;
}

.panel,
.create-form,
main.panel {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 20px;
}

.panel {
    margin-bottom: 18px;
}

.toolbar,
.form-row,
.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.toolbar {
    justify-content: space-between;
    margin-bottom: 16px;
}

.toolbar h1 {
    margin-bottom: 0;
}

.form-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-grid textarea,
.form-grid button {
    grid-column: 1 / -1;
}

label {
    display: block;
    color: var(--muted);
    font-weight: 500;
}

input,
select,
textarea {
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    padding: 8px 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(0, 87, 152, 0.14);
    outline: none;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

input[type="checkbox"] {
    min-height: 0;
    width: 16px;
    height: 16px;
    margin: 0 8px 0 0;
    accent-color: var(--brand);
    vertical-align: middle;
}

button,
a.button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 6px;
    background: var(--brand);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    line-height: 1;
    padding: 9px 14px;
    text-decoration: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

button:hover,
a.button:hover {
    background: var(--brand-strong);
    box-shadow: 0 6px 16px rgba(0, 87, 152, 0.18);
    transform: translateY(-1px);
}

button:active,
a.button:active {
    transform: translateY(0);
}

button:disabled,
button:disabled:hover {
    background: var(--subtle);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.back,
.cancel-btn {
    background: var(--muted);
}

.back:hover,
.cancel-btn:hover {
    background: #484848;
}

.danger,
.delete-btn {
    background: var(--danger);
}

.danger:hover,
.delete-btn:hover {
    background: var(--danger-strong);
}

.save-btn,
.create-form button[type="submit"] {
    background: var(--success);
}

.save-btn:hover,
.create-form button[type="submit"]:hover {
    background: #568e59;
}

.edit-btn {
    background: var(--brand);
}

.inline,
form.inline {
    display: inline-flex;
}

.table-card {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

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

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

th,
td {
    border-bottom: 1px solid var(--border-soft);
    padding: 11px 12px;
    text-align: left;
    vertical-align: middle;
}

th {
    background: var(--surface-subtle);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

td {
    color: var(--text);
}

tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: #f7fbfe;
}

.error {
    color: var(--danger-strong);
    font-weight: 700;
}

.hint,
.meta {
    color: var(--muted);
    font-size: 14px;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(77, 152, 209, 0.18), transparent 32rem),
        linear-gradient(135deg, #f8fbfd 0%, #eef3f6 100%);
}

.login-card {
    width: min(100%, 380px);
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}

.login-brand {
    margin-bottom: 18px;
}

.login-brand span {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 13px;
    font-weight: 700;
    padding: 5px 10px;
}

.login-card label {
    margin-top: 14px;
}

.login-card input {
    width: 100%;
    margin-top: 6px;
}

.login-card button {
    width: 100%;
    margin-top: 20px;
}

.google-login-form {
    margin-top: 10px;
}

.google-login {
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text);
}

.google-login:hover {
    background: var(--surface-subtle);
}

.dashboard-page {
    background: var(--surface-muted);
}

.app-header {
    background: var(--brand);
    color: #ffffff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12);
}

.app-header-inner {
    display: flex;
    width: min(100%, 1120px);
    min-height: 68px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 auto;
    padding: 0 28px;
}

.app-header strong {
    display: block;
    font-size: 20px;
}

.app-header .meta {
    color: rgba(255, 255, 255, 0.78);
}

.logout {
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
}

.dashboard-main {
    width: min(100%, 1120px);
    margin: 0 auto;
    padding: 28px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.card {
    min-height: 108px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 18px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.card:hover {
    border-color: rgba(0, 87, 152, 0.28);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.card a,
.disabled {
    display: inline-block;
    margin-bottom: 8px;
    font-size: 17px;
    font-weight: 900;
    text-decoration: none;
}

.disabled {
    color: var(--subtle);
}

.config-form {
    display: grid;
    gap: 14px;
}

.config-form label {
    margin: 0;
}

.config-form input[type="number"] {
    display: block;
    width: 160px;
    margin-top: 6px;
}

.check-label {
    display: flex;
    align-items: center;
    color: var(--text);
}

.permission-panel {
    width: 100%;
    margin-top: 8px;
}

.permission-panel h2 {
    margin-bottom: 8px;
    font-size: 15px;
}

.permission-grid {
    display: grid;
    gap: 8px;
    margin: 8px 0 14px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.permission-grid.compact {
    margin-bottom: 8px;
}

.permission-grid .check-label,
.create-form .permission-grid .check-label {
    min-height: 36px;
    margin: 0;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--surface-subtle);
    padding: 8px 10px;
}

.create-form .permission-grid input[type="checkbox"],
.permission-grid input[type="checkbox"] {
    width: 16px;
    margin-bottom: 0;
}

.permission-grid-table {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.permission-row {
    display: grid;
    min-height: 42px;
    align-items: center;
    gap: 8px;
    grid-template-columns: minmax(92px, 1fr) auto auto;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--surface-subtle);
    padding: 8px 10px;
}

.permission-row .check-label {
    min-height: 0;
    border: 0;
    background: transparent;
    padding: 0;
}

.permission-row.is-disabled {
    color: var(--subtle);
    opacity: 0.62;
}

.permission-name {
    font-weight: 700;
}

.create-form {
    width: min(100%, 560px);
    margin-top: 22px;
}

.create-form label {
    margin-bottom: 6px;
}

.create-form input {
    width: 100%;
    margin-bottom: 12px;
}

.inline-input {
    width: 128px;
    min-height: 34px;
    padding: 5px 8px;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.row-actions button {
    min-height: 32px;
    padding: 7px 10px;
    font-size: 14px;
}

.icon-button {
    min-height: 28px;
    width: 30px;
    margin-left: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 3px;
}

.icon-button:hover {
    background: var(--surface-subtle);
    box-shadow: none;
    transform: none;
}

.masked-value {
    display: inline-block;
    min-width: 42px;
}

.multiline {
    max-width: 360px;
    white-space: pre-wrap;
}

.empty-state {
    margin: 0;
    color: var(--muted);
}

@media (max-width: 720px) {
    .app-page {
        padding: 18px;
    }

    .app-header-inner,
    .dashboard-main {
        padding-left: 18px;
        padding-right: 18px;
    }

    h1 {
        font-size: 24px;
    }

    .form-row {
        align-items: stretch;
        flex-direction: column;
    }

    .form-row input,
    .form-row select,
    .form-row textarea,
    .form-row button,
    .form-row a.button {
        width: 100%;
    }

    .toolbar {
        align-items: flex-start;
        flex-direction: column;
    }
}
