/*
 * 檔案名稱：assets/css/app.css
 * 修改日期：2026/07/18 08:30（UTC+8）
 * 檔案用途：廟務高手網頁版前後台共用樣式
 * 修改說明：保留既有版面，新增民國年日期快速輸入、日期選擇器與手機版日曆樣式
 */

:root {
    --gold-900: #5c4300;
    --gold-800: #765800;
    --gold-700: #977300;
    --gold-600: #b58c0a;
    --gold-500: #d2aa24;
    --gold-300: #f2d874;
    --gold-200: #faeaa8;
    --gold-100: #fff7d4;
    --cream: #fffdf5;
    --paper: #ffffff;
    --ink: #262214;
    --muted: #746d5b;
    --line: #e2dac0;
    --success: #2f7d4b;
    --success-soft: #e9f6ee;
    --danger: #b63c35;
    --danger-soft: #fff0ef;
    --warning: #a86600;
    --warning-soft: #fff4d9;
    --info: #2e668f;
    --info-soft: #eaf4fb;
    --sidebar-width: 256px;
    --sidebar-collapsed-width: 74px;
    --topbar-height: 72px;
    --shadow-sm: 0 2px 10px rgba(60, 43, 0, 0.08);
    --shadow-md: 0 12px 36px rgba(60, 43, 0, 0.16);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    color: var(--ink);
    background: #f4f1e8;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: #f4f1e8;
    line-height: 1.55;
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    cursor: pointer;
}

button:disabled,
.button.disabled {
    cursor: not-allowed;
    opacity: 0.55;
    pointer-events: none;
}

code,
pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.button-primary {
    color: #fff;
    background: linear-gradient(180deg, var(--gold-600), var(--gold-800));
    border-color: var(--gold-800);
}

.button-secondary {
    color: var(--gold-900);
    background: #fff;
    border-color: #cfc5a7;
}

.button-warning {
    color: #fff;
    background: linear-gradient(180deg, #cf8400, #9c5d00);
    border-color: #8d5400;
}

.button-danger {
    color: #fff;
    background: var(--danger);
    border-color: #95312b;
}

.button-small {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 0.86rem;
}

.button-large {
    min-height: 48px;
    padding: 12px 24px;
}

.full-width {
    width: 100%;
}

.panel {
    padding: 22px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.panel + .panel {
    margin-top: 18px;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.panel-heading h2 {
    margin: 0;
    color: var(--gold-900);
    font-size: 1.2rem;
}

.panel-heading p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.compact-heading {
    margin-bottom: 12px;
}

.message-box {
    padding: 13px 16px;
    margin-bottom: 16px;
    border: 1px solid;
    border-radius: var(--radius-sm);
}

.message-box ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.message-error {
    color: #842923;
    background: var(--danger-soft);
    border-color: #e7aaa6;
}

.message-success {
    color: #215f39;
    background: var(--success-soft);
    border-color: #a7d7b7;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.field > span {
    color: #4d4635;
    font-weight: 700;
}

.field small,
.check-field small {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 400;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #cfc7af;
    border-radius: 7px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
    min-height: 110px;
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--gold-600);
    box-shadow: 0 0 0 3px rgba(181, 140, 10, 0.18);
}

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

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

.check-field {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid #ddd4ba;
    border-radius: 8px;
    background: #fffdf6;
}

.check-field input {
    width: 19px;
    height: 19px;
    margin: 2px 0 0;
    accent-color: var(--gold-700);
    flex: 0 0 auto;
}

.check-field > span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 22px;
}

.align-right {
    justify-content: flex-end;
}

.section-divider {
    height: 1px;
    margin: 26px 0;
    border: 0;
    background: var(--line);
}

.password-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 6px;
}

.password-wrap .icon-button:nth-last-child(1):first-of-type {
    grid-column: auto;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
    padding: 6px;
    color: var(--gold-900);
    background: var(--gold-100);
    border: 1px solid #cfc3a0;
    border-radius: 7px;
    font-size: 1.05rem;
}

.icon-button:hover {
    background: var(--gold-200);
}

/* 安裝 */
.install-page {
    padding: 28px 16px;
    background:
        radial-gradient(circle at top left, rgba(255, 239, 167, 0.9), transparent 34%),
        linear-gradient(135deg, #f7f1dd, #ece5ce);
}

.install-shell {
    width: min(980px, 100%);
    margin: 0 auto;
}

.install-brand {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 22px 26px;
    margin-bottom: 18px;
    color: #fff;
    background: linear-gradient(120deg, #7e5e00, #c59a18 58%, #8b6800);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 74px;
    height: 74px;
    border-radius: 50%;
    color: #fff6c7;
    background: rgba(75, 45, 0, 0.55);
    border: 2px solid rgba(255, 240, 165, 0.65);
    font-family: serif;
    font-size: 2.2rem;
    font-weight: 800;
    flex: 0 0 auto;
}

.brand-mark.small {
    width: 42px;
    height: 42px;
    font-size: 1.25rem;
}

.brand-company {
    color: #ffed9b;
    font-weight: 700;
}

.install-brand h1 {
    margin: 2px 0;
    font-size: clamp(1.5rem, 4vw, 2.35rem);
}

.install-brand p {
    margin: 0;
    color: #fff3c0;
}

.install-form h2,
.install-result h2 {
    margin: 4px 0 18px;
    color: var(--gold-900);
    font-size: 1.2rem;
}

.install-form h2:not(:first-of-type) {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.requirement-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.requirement-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 700;
}

.requirement-item.passed {
    color: #255f39;
    background: var(--success-soft);
}

.requirement-item.failed {
    color: #8f2e28;
    background: var(--danger-soft);
}

.install-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 4px;
    color: var(--muted);
    font-size: 0.85rem;
}

.success-panel {
    border-color: #9fcfac;
    background: linear-gradient(180deg, #fff, #f2fbf4);
}

/* 登入 */
.login-page {
    display: grid;
    place-items: center;
    padding: 18px;
    background:
        radial-gradient(circle at 16% 16%, rgba(255, 232, 111, 0.45), transparent 26%),
        linear-gradient(135deg, #684d00, #b1890c 46%, #5d4300);
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
    width: min(920px, 100%);
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(255, 240, 170, 0.8);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 70px rgba(32, 21, 0, 0.38);
}

.login-visual {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 640px;
    padding: 46px;
    color: #fff6c4;
    overflow: hidden;
    background:
        linear-gradient(0deg, rgba(57, 31, 0, 0.95), rgba(150, 105, 0, 0.45)),
        repeating-linear-gradient(135deg, #a97d00 0 28px, #be9316 28px 56px);
}

.login-visual::before,
.login-visual::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border-style: solid;
}

.login-visual::before {
    bottom: 145px;
    border-width: 0 180px 105px;
    border-color: transparent transparent #8d220f;
    filter: drop-shadow(0 10px 3px rgba(0, 0, 0, 0.25));
}

.login-visual::after {
    bottom: 82px;
    width: 220px;
    height: 100px;
    background: #bc2d14;
    border: 10px solid #5f160c;
    border-bottom: 0;
}

.temple-sun {
    position: absolute;
    top: 76px;
    right: 54px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: rgba(255, 226, 98, 0.5);
    box-shadow: 0 0 70px rgba(255, 225, 90, 0.6);
}

.temple-roof,
.temple-subtitle {
    position: relative;
    z-index: 2;
}

.temple-roof {
    font-family: serif;
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-shadow: 0 3px 0 #6c3900;
}

.temple-subtitle {
    margin-top: 4px;
    letter-spacing: 0.24em;
}

.login-card {
    padding: 48px 52px 36px;
    background: linear-gradient(180deg, #fffdf7, #fff8dd);
}

.login-header {
    margin-bottom: 28px;
}

.login-header p {
    margin: 0;
    color: var(--gold-700);
    font-weight: 800;
}

.login-header h1 {
    margin: 5px 0 2px;
    color: var(--gold-900);
    font-family: serif;
    font-size: clamp(1.8rem, 5vw, 2.7rem);
}

.login-header span {
    color: var(--muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.captcha-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 170px;
    align-items: end;
    gap: 12px;
}

.captcha-refresh {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    font-size: 0.76rem;
}

.captcha-refresh img {
    width: 160px;
    height: 52px;
    border: 1px solid #c9b66c;
    border-radius: 7px;
}

.login-submit {
    width: 100%;
    margin-top: 4px;
}

.login-footer {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-top: 22px;
    margin-top: 26px;
    color: var(--muted);
    border-top: 1px solid #ded2a9;
    font-size: 0.86rem;
}

.login-footer strong {
    color: var(--gold-900);
}

/* 後台架構 */
.admin-page {
    width: 100%;
    overflow: hidden;
}

.admin-layout {
    position: relative;
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: #f4f1e8;
}

.sidebar {
    position: relative;
    z-index: 30;
    display: flex;
    flex: 0 0 var(--sidebar-width);
    flex-direction: column;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    color: #fff9dc;
    background: linear-gradient(180deg, #614700, #876500 46%, #4c3700);
    box-shadow: 4px 0 18px rgba(58, 41, 0, 0.16);
    overflow: hidden;
    transition:
        flex-basis 0.22s ease,
        width 0.22s ease,
        min-width 0.22s ease,
        max-width 0.22s ease;
}

.admin-layout.sidebar-collapsed .sidebar {
    flex-basis: var(--sidebar-collapsed-width);
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
    max-width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: var(--topbar-height);
    padding: 13px 14px;
    border-bottom: 1px solid rgba(255, 242, 178, 0.22);
    flex: 0 0 auto;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    white-space: nowrap;
    transition: opacity 0.16s ease;
}

.sidebar-brand-text strong {
    font-family: serif;
    font-size: 1.35rem;
}

.sidebar-brand-text span {
    overflow: hidden;
    color: #f3df95;
    font-size: 0.78rem;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 9px 24px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 239, 160, 0.35) transparent;
}

.nav-group + .nav-group {
    margin-top: 15px;
    padding-top: 13px;
    border-top: 1px solid rgba(255, 242, 178, 0.14);
}

.nav-group h2 {
    margin: 0 9px 6px;
    color: #ddc46c;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    white-space: nowrap;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 43px;
    padding: 7px 10px;
    margin: 3px 0;
    border-radius: 8px;
    color: #fff7d3;
    white-space: nowrap;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.nav-item:hover {
    background: rgba(255, 238, 153, 0.14);
    transform: translateX(2px);
}

.nav-item.active {
    color: #493300;
    background: linear-gradient(180deg, #ffe991, #eac957);
    box-shadow: inset 0 0 0 1px rgba(255, 250, 213, 0.75), var(--shadow-sm);
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 31px;
    height: 31px;
    border: 1px solid rgba(255, 247, 211, 0.28);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 900;
    flex: 0 0 auto;
}

.nav-item.active .nav-icon {
    border-color: rgba(73, 51, 0, 0.24);
    background: rgba(255, 255, 255, 0.35);
}

.nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.15s ease;
}

.sidebar-footer {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 2px;
    padding: 12px 16px;
    color: #d8c37c;
    border-top: 1px solid rgba(255, 242, 178, 0.18);
    font-size: 0.72rem;
    white-space: nowrap;
}

.sidebar-collapse {
    position: fixed;
    z-index: 45;
    top: 50%;
    left: calc(var(--sidebar-width) - 13px);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 27px;
    height: 54px;
    padding: 0;
    color: #fff;
    background: var(--gold-800);
    border: 2px solid #fff7d2;
    border-radius: 0 9px 9px 0;
    box-shadow: var(--shadow-sm);
    transform: translateY(-50%);
    transition: left 0.22s ease, transform 0.22s ease;
}

.admin-layout.sidebar-collapsed .sidebar-collapse {
    left: calc(var(--sidebar-collapsed-width) - 13px);
    transform: translateY(-50%) rotate(180deg);
}

.admin-layout.sidebar-collapsed .sidebar-brand-text,
.admin-layout.sidebar-collapsed .nav-label,
.admin-layout.sidebar-collapsed .nav-group h2,
.admin-layout.sidebar-collapsed .sidebar-footer {
    opacity: 0;
    pointer-events: none;
}

.admin-layout.sidebar-collapsed .nav-item {
    justify-content: center;
    padding-inline: 5px;
}

.admin-layout.sidebar-collapsed .nav-item:hover {
    transform: none;
}

.admin-main {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    width: 100%;
    min-width: 0;
    min-height: var(--topbar-height);
    padding: 10px 24px;
    background: rgba(255, 253, 245, 0.98);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.topbar-left,
.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.topbar-left > div {
    min-width: 0;
}

.topbar h1 {
    margin: 0;
    overflow: hidden;
    color: var(--gold-900);
    font-size: 1.35rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar p {
    margin: 1px 0 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-meta span {
    color: var(--muted);
    font-size: 0.76rem;
}

.mobile-menu-button,
.mobile-sidebar-overlay {
    display: none;
}

.content-area {
    width: 100%;
    min-width: 0;
    padding: 22px;
}

.content-area > * {
    min-width: 0;
}

.records-panel,
.records-table-wrap {
    min-width: 0;
    max-width: 100%;
}

/* 儀表板 */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    padding: 19px;
    background: linear-gradient(150deg, #fff, #fff9e2);
    border: 1px solid #e2d4a2;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    color: #fff;
    background: linear-gradient(145deg, var(--gold-500), var(--gold-800));
    border-radius: 14px;
    font-weight: 900;
    flex: 0 0 auto;
}

.stat-card div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-card strong {
    color: var(--gold-900);
    font-size: 1.65rem;
    line-height: 1.1;
}

.stat-card span:last-child {
    color: var(--muted);
    font-size: 0.85rem;
}

.dashboard-two-column {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.8fr);
    gap: 18px;
    margin-bottom: 18px;
}

.dashboard-two-column .panel + .panel {
    margin-top: 0;
}

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

.finance-number {
    display: flex;
    flex-direction: column;
    padding: 13px;
    border-radius: 9px;
}

.finance-number span {
    font-size: 0.8rem;
}

.finance-number strong {
    margin-top: 3px;
    font-size: 1.25rem;
}

.finance-number.income {
    color: #23603a;
    background: var(--success-soft);
}

.finance-number.expense {
    color: #8f302b;
    background: var(--danger-soft);
}

.finance-number.balance {
    color: #5c4300;
    background: var(--gold-100);
}

.mini-chart {
    display: grid;
    grid-template-columns: repeat(12, minmax(20px, 1fr));
    gap: 8px;
    height: 190px;
    padding-top: 8px;
    border-bottom: 1px solid var(--line);
}

.month-bar {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 6px;
    min-width: 0;
}

.bar-pair {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    height: 100%;
}

.bar {
    display: block;
    width: 42%;
    min-height: 2px;
    border-radius: 4px 4px 0 0;
}

.income-bar {
    background: #4d9c68;
}

.expense-bar {
    background: #d16c65;
}

.month-bar > span {
    color: var(--muted);
    font-size: 0.68rem;
    text-align: center;
}

.status-list {
    margin: 0 0 18px;
}

.status-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 11px 0;
    border-bottom: 1px dashed var(--line);
}

.status-list dt {
    color: var(--muted);
}

.status-list dd {
    margin: 0;
    font-weight: 700;
    text-align: right;
}

/* 表格 */
.table-wrap {
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 9px;
}

.data-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    background: #fff;
}

.data-table th,
.data-table td {
    padding: 11px 12px;
    border-bottom: 1px solid #eee9d9;
    vertical-align: middle;
    text-align: left;
}

.data-table th {
    position: sticky;
    z-index: 1;
    top: 0;
    color: #51420f;
    background: #f7efd1;
    font-size: 0.83rem;
    white-space: nowrap;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.clickable-table tbody tr[data-row-id] {
    cursor: pointer;
    transition: background-color 0.12s ease;
}

.clickable-table tbody tr[data-row-id]:hover {
    background: #fff8dc;
}

.data-table td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.72rem;
}

.empty-cell {
    padding: 30px !important;
    color: var(--muted);
    text-align: center !important;
}

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

.actions-cell {
    width: 1%;
    white-space: nowrap;
    text-align: right !important;
}

.actions-cell .button + .button,
.actions-cell .inline-form + .button {
    margin-left: 4px;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
    white-space: nowrap;
}

.badge-success {
    color: #245f39;
    background: var(--success-soft);
}

.badge-danger {
    color: #8c2d27;
    background: var(--danger-soft);
}

.badge-warning {
    color: #764700;
    background: var(--warning-soft);
}

.badge-info {
    color: #225a80;
    background: var(--info-soft);
}

.hash-text {
    max-width: 310px;
    overflow-wrap: anywhere;
}

.error-detail {
    max-width: 320px;
    color: var(--danger) !important;
    white-space: normal;
}

/* 列表工具列與分頁 */
.records-toolbar {
    align-items: center;
}

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

.search-box {
    display: flex;
    min-width: min(360px, 100%);
}

.search-box input {
    min-width: 0;
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid #cfc7af;
    border-right: 0;
    border-radius: 8px 0 0 8px;
    outline: none;
}

.search-box .button {
    border-radius: 0 8px 8px 0;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-top: 16px;
    color: var(--muted);
    font-size: 0.86rem;
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: 9px;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(33, 24, 3, 0.6);
    backdrop-filter: blur(3px);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-card {
    display: flex;
    flex-direction: column;
    width: min(860px, 100%);
    max-height: calc(100vh - 40px);
    overflow: hidden;
    background: #fff;
    border: 1px solid #e5d69f;
    border-radius: var(--radius-md);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    background: linear-gradient(180deg, #fff9df, #f7edc7);
    border-bottom: 1px solid #ded1a6;
}

.modal-header h2 {
    margin: 0;
    color: var(--gold-900);
    font-size: 1.25rem;
}

.modal-header p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    color: #604700;
    background: #fff;
    border: 1px solid #cdbf92;
    border-radius: 50%;
    font-size: 1.55rem;
    line-height: 1;
}

.modal-form {
    min-height: 0;
    overflow-y: auto;
}

.modal-form > .form-grid {
    padding: 20px;
}

.modal-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    background: #fffdf7;
    border-top: 1px solid var(--line);
}

body.modal-open {
    overflow: hidden;
}

/* 帳號與權限 */
.users-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.users-page .panel + .panel {
    margin-top: 0;
}

.role-permission-editor {
    display: grid;
    grid-template-columns: minmax(180px, 250px) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.role-select-field {
    position: sticky;
    top: calc(var(--topbar-height) + 18px);
    padding: 16px;
    background: #fff9e4;
    border: 1px solid #e0d19b;
    border-radius: 10px;
}

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

.permission-group {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.permission-group h3 {
    margin: 0 0 10px;
    color: var(--gold-900);
    font-size: 1rem;
}

.permission-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.permission-list .check-field {
    min-height: 0;
    padding: 8px 9px;
}

.permission-reserved {
    opacity: 0.62;
    background: #f3f1eb;
}

/* 備份 */
.backup-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.backup-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.backup-card.featured {
    border-color: #e2b56a;
    background: linear-gradient(180deg, #fff, #fff7e4);
}

.backup-card .button {
    grid-column: 1 / -1;
}

.backup-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    color: #fff;
    background: linear-gradient(145deg, var(--gold-500), var(--gold-800));
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 900;
}

.backup-card h2 {
    margin: 0;
    color: var(--gold-900);
    font-size: 1.15rem;
}

.backup-card p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.security-note {
    border-color: #d9c170;
    background: linear-gradient(180deg, #fffdf4, #fff8dd);
}

.security-note h2 {
    margin: 0 0 8px;
    color: var(--gold-900);
    font-size: 1.1rem;
}

.security-note p {
    margin: 7px 0;
    color: #5f5743;
}

.security-note code {
    padding: 2px 5px;
    background: #f0e3b6;
    border-radius: 4px;
}

/* 更新 */
.update-overview {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 22px;
    margin-bottom: 18px;
}

.version-display {
    display: flex;
    flex-direction: column;
    min-width: 150px;
    padding: 18px;
    color: #fff;
    background: linear-gradient(145deg, var(--gold-500), var(--gold-900));
    border-radius: 13px;
}

.version-display span {
    font-size: 0.8rem;
}

.version-display strong {
    font-size: 1.8rem;
}

.update-overview h2 {
    margin: 0;
    color: var(--gold-900);
}

.update-overview p {
    margin: 5px 0 0;
    color: var(--muted);
}

.update-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.update-dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    padding: 28px;
    color: #59440b;
    background: #fffaf0;
    border: 2px dashed #c9ad53;
    border-radius: var(--radius-md);
    text-align: center;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.update-dropzone.dragover {
    background: #fff1bd;
    border-color: var(--gold-800);
    transform: scale(1.005);
}

.update-dropzone input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.dropzone-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    margin-bottom: 12px;
    color: #fff;
    background: var(--gold-700);
    border-radius: 50%;
    font-size: 2rem;
}

.update-dropzone strong {
    font-size: 1.25rem;
}

.update-dropzone > span:not(.dropzone-icon) {
    color: var(--muted);
}

.update-dropzone small {
    margin-top: 12px;
    padding: 5px 10px;
    color: var(--gold-900);
    background: #fff;
    border: 1px solid #ddc979;
    border-radius: 999px;
}

.update-progress {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.update-progress[hidden] {
    display: none;
}

.progress-track {
    height: 13px;
    overflow: hidden;
    background: #e8e2d3;
    border-radius: 999px;
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--gold-500), var(--gold-800));
    transition: width 0.18s ease;
}

.code-block {
    padding: 14px;
    overflow-x: auto;
    color: #f7e9a7;
    background: #332800;
    border-radius: 8px;
}

/* 篩選、報表、設定 */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.report-filter-grid {
    grid-template-columns: minmax(180px, 260px) minmax(180px, 260px) minmax(260px, 1fr);
}

.report-header {
    margin: 0 0 18px;
    text-align: center;
}

.report-header h2 {
    margin: 0;
    color: var(--gold-900);
}

.report-header p {
    margin: 4px 0 0;
    color: var(--muted);
}

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

.report-grid .panel + .panel {
    margin-top: 0;
}

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

.system-info-grid div {
    display: flex;
    flex-direction: column;
    padding: 13px;
    background: #fff9e4;
    border: 1px solid #e5d8aa;
    border-radius: 8px;
}

.system-info-grid span {
    color: var(--muted);
    font-size: 0.78rem;
}

.system-info-grid strong {
    margin-top: 3px;
    overflow-wrap: anywhere;
}

/* 權限頁與簡單頁 */
.simple-page {
    display: grid;
    place-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #efe9d4, #faf6e8);
}

.simple-card {
    width: min(520px, 100%);
    padding: 36px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.simple-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    margin: 0 auto 15px;
    color: #fff;
    background: var(--danger);
    border-radius: 50%;
    font-size: 2rem;
    font-weight: 900;
}

.simple-card h1 {
    margin: 0;
    color: var(--gold-900);
}

.simple-card p {
    margin: 10px 0 22px;
    color: var(--muted);
}

/* SweetAlert2 配色 */
.swal2-popup {
    border: 1px solid #decf9f;
    border-radius: var(--radius-md) !important;
    font-family: inherit !important;
}

.swal2-title {
    color: var(--gold-900) !important;
}

.swal2-confirm {
    background: var(--gold-800) !important;
}

.swal2-cancel {
    color: var(--gold-900) !important;
    background: #eee8d7 !important;
}

/* 響應式 */
@media (max-width: 1180px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

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

    .system-info-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .admin-layout,
    .admin-layout.sidebar-collapsed {
        display: block;
    }

    .sidebar,
    .admin-layout.sidebar-collapsed .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        flex-basis: auto;
        width: min(310px, 88vw);
        min-width: 0;
        max-width: none;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    .admin-layout.mobile-menu-open .sidebar {
        transform: translateX(0);
    }

    .admin-layout.sidebar-collapsed .sidebar-brand-text,
    .admin-layout.sidebar-collapsed .nav-label,
    .admin-layout.sidebar-collapsed .nav-group h2,
    .admin-layout.sidebar-collapsed .sidebar-footer {
        opacity: 1;
        pointer-events: auto;
    }

    .admin-layout.sidebar-collapsed .nav-item {
        justify-content: flex-start;
        padding-inline: 10px;
    }

    .sidebar-collapse {
        display: none;
    }

    .mobile-menu-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        color: var(--gold-900);
        background: var(--gold-100);
        border: 1px solid #d4c591;
        border-radius: 8px;
        font-size: 1.25rem;
    }

    .mobile-sidebar-overlay {
        position: fixed;
        z-index: 25;
        inset: 0;
        width: 100%;
        height: 100%;
        padding: 0;
        background: rgba(25, 18, 0, 0.55);
        border: 0;
    }

    .admin-layout.mobile-menu-open .mobile-sidebar-overlay {
        display: block;
    }

    .admin-main {
        width: 100%;
        height: 100vh;
        height: 100dvh;
    }

    .topbar {
        padding-inline: 16px;
    }

    .content-area {
        padding: 16px;
    }

    .dashboard-two-column {
        grid-template-columns: 1fr;
    }

    .role-permission-editor {
        grid-template-columns: 1fr;
    }

    .role-select-field {
        position: static;
    }

    .backup-cards {
        grid-template-columns: 1fr;
    }

    .login-shell {
        grid-template-columns: 1fr;
        max-width: 580px;
    }

    .login-visual {
        display: none;
    }
}

@media (max-width: 680px) {
    .panel {
        padding: 16px;
        border-radius: 10px;
    }

    .panel-heading,
    .records-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-actions {
        align-items: stretch;
        justify-content: stretch;
    }

    .search-box {
        width: 100%;
        min-width: 0;
    }

    .toolbar-actions > .button {
        width: 100%;
    }

    .form-grid,
    .filter-grid,
    .report-filter-grid,
    .permission-grid,
    .system-info-grid {
        grid-template-columns: 1fr;
    }

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

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

    .mini-chart {
        gap: 3px;
    }

    .month-bar > span {
        writing-mode: vertical-rl;
        height: 30px;
    }

    .topbar-user .user-meta {
        display: none;
    }

    .topbar h1 {
        font-size: 1.1rem;
    }

    .content-area {
        padding: 12px;
    }

    .modal-backdrop {
        align-items: end;
        padding: 0;
    }

    .modal-card {
        width: 100%;
        max-height: 94vh;
        border-radius: 16px 16px 0 0;
    }

    .modal-form > .form-grid {
        padding: 16px;
    }

    .modal-actions {
        padding: 12px 16px;
    }

    .modal-actions .button {
        flex: 1;
    }

    .pagination-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .pagination-buttons {
        justify-content: space-between;
    }

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

    .version-display {
        min-width: 0;
    }

    .install-page {
        padding: 10px;
    }

    .install-brand {
        padding: 18px;
        border-radius: 14px;
    }

    .brand-mark:not(.small) {
        width: 56px;
        height: 56px;
        font-size: 1.6rem;
    }

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

    .install-footer {
        flex-direction: column;
    }

    .login-page {
        padding: 0;
        background: #fff8dd;
    }

    .login-shell {
        min-height: 100vh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .login-card {
        padding: 36px 20px 24px;
    }

    .captcha-row {
        grid-template-columns: 1fr;
    }

    .captcha-refresh {
        align-items: flex-start;
    }

    .backup-card {
        grid-template-columns: 1fr;
    }

    .backup-icon {
        width: 48px;
        height: 48px;
    }
}

@media (max-width: 440px) {
    .dashboard-grid,
    .finance-summary {
        grid-template-columns: 1fr;
    }

    .topbar {
        gap: 8px;
    }

    .topbar-left {
        gap: 9px;
    }

    .topbar-user .button {
        min-height: 36px;
        padding-inline: 11px;
    }

    .password-wrap {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .password-wrap .icon-button:nth-of-type(n + 2) {
        grid-row: 2;
    }
}

@media print {
    body,
    html {
        background: #fff !important;
    }

    .sidebar,
    .sidebar-collapse,
    .topbar,
    .no-print,
    .button,
    .mobile-sidebar-overlay {
        display: none !important;
    }

    .admin-layout,
    .admin-layout.sidebar-collapsed {
        display: block;
    }

    .admin-main {
        height: auto;
        overflow: visible;
    }

    .content-area {
        padding: 0;
    }

    .panel,
    .stat-card {
        break-inside: avoid;
        box-shadow: none;
    }

    .table-wrap {
        overflow: visible;
    }

    .data-table {
        min-width: 0;
    }
}

/* 系統檢查 */
.diagnostic-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.diagnostic-summary-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 22px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.diagnostic-summary-card strong {
    font-size: 2rem;
    line-height: 1;
}

.diagnostic-summary-card span {
    font-weight: 800;
}

.diagnostic-passed {
    color: #245f39;
    background: var(--success-soft);
    border-color: #a7d7b7;
}

.diagnostic-warning {
    color: #764700;
    background: var(--warning-soft);
    border-color: #e4c67d;
}

.diagnostic-failed {
    color: #8c2d27;
    background: var(--danger-soft);
    border-color: #e7aaa6;
}

.diagnostic-table td:last-child {
    min-width: 320px;
    white-space: normal;
}

@media (max-width: 680px) {
    .diagnostic-summary {
        grid-template-columns: 1fr;
    }

    .diagnostic-table td:last-child {
        min-width: 260px;
    }
}

/* 民國三碼國曆／農曆雙向換算 */
.calendar-pair {
    display: grid;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background: #fffdf6;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.calendar-input-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.calendar-prefix {
    color: var(--gold-900);
    font-size: 0.82rem;
    font-weight: 800;
    text-align: center;
}

.calendar-input-row input[type="text"] {
    width: 100%;
    min-width: 0;
}

.calendar-leap-check {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 38px;
    padding: 0 8px;
    white-space: nowrap;
    background: var(--gold-100);
    border: 1px solid var(--gold-300);
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 800;
}

.calendar-leap-check input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.calendar-status {
    min-height: 1.2em;
    color: var(--muted);
    font-size: 0.75rem;
}

.calendar-status[data-type="success"] {
    color: #245f39;
}

.calendar-status[data-type="error"] {
    color: #9b2f28;
}

.compact-calendar-pair {
    padding: 7px;
}

/* 信眾資料頁內嵌櫃台模式 */
.embedded-service-page {
    overflow: auto;
    background: #f4f1e8;
}

.embedded-service-page .admin-layout,
.embedded-service-page .admin-layout.sidebar-collapsed {
    display: block;
    min-height: 0;
}

.embedded-service-page .sidebar,
.embedded-service-page .sidebar-collapse,
.embedded-service-page .mobile-sidebar-overlay,
.embedded-service-page .topbar {
    display: none !important;
}

.embedded-service-page .admin-main {
    width: 100%;
    min-width: 0;
    min-height: 0;
}

.embedded-service-page .content-area {
    width: 100%;
    padding: 10px;
}

.embedded-service-page .content-area > * {
    max-width: none;
}

@media (max-width: 520px) {
    .calendar-input-row {
        grid-template-columns: 42px minmax(0, 1fr);
    }

    .calendar-leap-check {
        grid-column: 2;
        justify-self: start;
    }
}

/* 2.1.0：畫面日期統一顯示民國三碼國曆與農曆 */
.dual-date-display {
    display: inline-grid;
    gap: 2px;
    min-width: 106px;
    line-height: 1.35;
}

.dual-date-solar {
    color: var(--ink);
    font-weight: 700;
    white-space: nowrap;
}

.dual-date-lunar {
    color: var(--muted);
    font-size: 0.74rem;
    white-space: nowrap;
}

/* 2.2.0：民國年日期快速輸入與日期選擇器 */
.roc-date-input {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.roc-calendar-trigger {
    display: inline-grid;
    place-items: center;
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    color: var(--gold-900);
    background: var(--gold-100);
    border: 1px solid var(--gold-300);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.15rem;
    font-weight: 900;
    line-height: 1;
}

.roc-calendar-trigger:hover,
.roc-calendar-trigger:focus-visible {
    color: #fff;
    background: var(--gold-700);
    border-color: var(--gold-700);
    outline: none;
}

body.roc-calendar-open {
    overflow: hidden;
}

.roc-calendar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2800;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(30, 27, 20, 0.58);
}

.roc-calendar-backdrop[hidden] {
    display: none;
}

.roc-calendar-dialog {
    width: min(430px, 100%);
    max-height: min(720px, calc(100vh - 36px));
    overflow: auto;
    background: #fff;
    border: 1px solid var(--gold-300);
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.roc-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    color: #fff;
    background: linear-gradient(135deg, var(--gold-900), var(--gold-700));
}

.roc-calendar-header > div {
    display: grid;
    gap: 3px;
}

.roc-calendar-header strong {
    font-size: 1.05rem;
}

.roc-calendar-header small {
    color: rgba(255, 255, 255, 0.82);
}

.roc-calendar-close {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.4rem;
}

.roc-calendar-controls {
    display: grid;
    grid-template-columns: 40px minmax(110px, 1fr) minmax(90px, 0.8fr) 40px;
    gap: 8px;
    padding: 14px 16px 10px;
}

.roc-calendar-controls > button {
    min-height: 42px;
    color: var(--gold-900);
    background: var(--gold-100);
    border: 1px solid var(--gold-300);
    border-radius: 9px;
    cursor: pointer;
    font-size: 1.45rem;
    font-weight: 900;
}

.roc-calendar-controls label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    min-height: 42px;
    padding: 5px 8px;
    background: #fffdf6;
    border: 1px solid var(--line);
    border-radius: 9px;
}

.roc-calendar-controls label span {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    white-space: nowrap;
}

.roc-calendar-controls input,
.roc-calendar-controls select {
    width: 100%;
    min-width: 0;
    height: 30px;
    padding: 2px 5px;
    border: 0;
    background: transparent;
    font-weight: 800;
}

.roc-calendar-weekdays,
.roc-calendar-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
    padding-inline: 16px;
}

.roc-calendar-weekdays {
    padding-top: 5px;
    padding-bottom: 7px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-align: center;
}

.roc-calendar-days {
    padding-bottom: 15px;
}

.roc-calendar-day {
    aspect-ratio: 1;
    min-width: 0;
    padding: 0;
    color: var(--ink);
    background: #fff;
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

.roc-calendar-day:hover,
.roc-calendar-day:focus-visible {
    background: var(--gold-100);
    border-color: var(--gold-400);
    outline: none;
}

.roc-calendar-day.outside-month {
    color: #a8a59d;
    background: #faf9f5;
}

.roc-calendar-day.today {
    border-color: var(--gold-600);
}

.roc-calendar-day.selected {
    color: #fff;
    background: var(--gold-800);
    border-color: var(--gold-800);
}

.roc-calendar-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 13px 16px 16px;
    border-top: 1px solid var(--line);
}

@media (max-width: 520px) {
    .calendar-input-row:has(.roc-calendar-trigger) {
        grid-template-columns: 42px minmax(0, 1fr) auto;
    }

    .roc-calendar-backdrop {
        align-items: end;
        padding: 0;
    }

    .roc-calendar-dialog {
        width: 100%;
        max-height: 92vh;
        border-radius: 18px 18px 0 0;
    }

    .roc-calendar-controls {
        grid-template-columns: 38px minmax(0, 1fr) minmax(0, 0.8fr) 38px;
        padding-inline: 12px;
    }

    .roc-calendar-controls label {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .roc-calendar-weekdays,
    .roc-calendar-days {
        padding-inline: 12px;
    }
}
