:root {
    --bg: #f2f4f8;
    --surface: #ffffff;
    --line: #dfe4ec;
    --ink: #1d2634;
    --muted: #6a7588;
    --nav-bg: #0b1834;
    --nav-soft: #102247;
    --nav-hover: #1a315d;
    --accent: #16a067;
    --warn: #d9a022;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Manrope", "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--bg);
}

button,
input,
select {
    font: inherit;
}

.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.admin-shell.is-icons-only {
    grid-template-columns: 94px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, var(--nav-bg) 0%, #09142b 100%);
    color: #d9e4ff;
    padding: 1rem 0.9rem;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #22375f;
}

.brand-card {
    margin-bottom: 0.85rem;
}

.brand-link {
    background: #f7fbff;
    border: 1px solid #d5e3f7;
    border-radius: 8px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #123b5d;
    padding: 0.35rem;
}

.brand-logo {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 108px;
    object-fit: contain;
    flex: 0 0 auto;
}

.menu-toggle {
    margin: 0.25rem 0 0.7rem;
    width: 100%;
    border: 1px solid #22385f;
    border-radius: 8px;
    background: var(--nav-soft);
    color: #dce9ff;
    padding: 0.66rem 0.78rem;
    text-align: left;
}

.menu-list {
    display: grid;
    gap: 0.34rem;
}

.menu-item {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #d9e4ff;
    text-decoration: none;
    text-align: left;
    padding: 0.66rem 0.78rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.52rem;
}

.menu-icon {
    width: 1rem;
    display: inline-grid;
    place-items: center;
    opacity: 0.9;
    font-size: 0.95rem;
}

.sidebar.is-icons-only .menu-item {
    justify-content: center;
    padding: 0.62rem 0.5rem;
}

.sidebar.is-icons-only {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

.sidebar.is-icons-only .menu-toggle {
    padding: 0.5rem 0.38rem;
    font-size: 0.83rem;
    line-height: 1.15;
    text-align: center;
}

.sidebar.is-icons-only .menu-item > span:last-child {
    display: none;
}

.sidebar.is-icons-only .menu-icon {
    width: auto;
    font-size: 1rem;
}

.menu-item:hover {
    background: var(--nav-hover);
}

.menu-item.is-active {
    background: #203a6d;
    border-color: #34548d;
}

.menu-item.is-subitem {
    margin-left: 1.15rem;
    width: calc(100% - 1.15rem);
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #c5d5f3;
}

.menu-item.is-subitem .menu-icon {
    font-size: 0.55rem;
    opacity: 0.7;
}

.menu-submenu {
    display: grid;
    gap: 0.2rem;
}

.menu-submenu[hidden] {
    display: none;
}

.sidebar.is-icons-only .menu-item.is-subitem {
    margin-left: 0;
    width: 100%;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid #22375f;
    padding-top: 0.95rem;
    color: #b7c9ec;
    font-size: 0.85rem;
}

.logout {
    display: inline-flex;
    margin-top: 0.35rem;
    color: #e7efff;
    text-decoration: none;
    background: #20345e;
    border-radius: 7px;
    padding: 0.48rem 0.7rem;
}

.content-area {
    padding: 0.95rem 1.05rem 1.25rem;
}

.content-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.content-head h1 {
    margin: 0;
    font-family: "Sora", sans-serif;
    font-size: 1.35rem;
}

.content-head p {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.93rem;
}

.help {
    border: 1px solid var(--line);
    background: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
}

.toolbar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.7rem;
    display: grid;
    grid-template-columns: 1.2fr repeat(2, 150px) repeat(2, 1fr) 130px;
    gap: 0.55rem;
    margin-bottom: 0.75rem;
}

.toolbar input,
.toolbar select,
.toolbar button {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.55rem 0.62rem;
    background: #fff;
}

.toolbar .primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.8rem;
}

.panel-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.7rem;
}

.panel-actions-with-search {
    justify-content: space-between;
    align-items: center;
    gap: 0.65rem;
}

.panel-actions-right {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    flex: 0 0 auto;
}

.list-search-toolbar {
    margin-bottom: 0.65rem;
}

.list-search-input {
    width: min(460px, 100%);
    flex: 1 1 auto;
    min-width: 220px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.52rem 0.62rem;
    background: #fff;
}

.list-search-input[aria-busy="true"] {
    background: #f5f8fd;
}

.primary-link {
    display: inline-block;
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
}

.primary-link:hover {
    background: #148d58;
    border-color: #148d58;
}

.ical-download-link {
    margin-right: 0.55rem;
}

.panel.is-hidden {
    display: none;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.stat-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.9rem;
    background: #fbfcff;
}

.stat-card h2 {
    margin: 0;
    font-size: 0.92rem;
    color: #4f5b6f;
}

.stat-card .value {
    margin: 0.45rem 0 0.2rem;
    font-family: "Sora", sans-serif;
    font-size: 2rem;
}

.stat-card small {
    color: #66758f;
}

.table-wrap {
    overflow: auto;
    max-height: calc(100vh - 260px);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 0.68rem 0.6rem;
    text-align: left;
    font-size: 0.92rem;
    vertical-align: top;
}

th {
    background: #f8faff;
    color: #526075;
    font-weight: 700;
    position: sticky;
    top: 0;
}

td button {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 0.34rem 0.56rem;
}

.action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #2d3b53;
    text-decoration: none;
    font-size: 1rem;
    cursor: pointer;
}

.action-icon:hover {
    background: #f1f5fb;
}

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

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

.action-icon-complete {
    color: #10754d;
}

.badge {
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-block;
}

.badge.ok {
    color: #10754d;
    background: #def5e8;
}

.badge.warning {
    color: #805a00;
    background: #fff3cf;
}

.badge.neutral {
    color: #21587f;
    background: #dfeeff;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.settings-grid article {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.9rem;
    background: #fbfcff;
}

.settings-grid h2 {
    margin: 0;
    font-size: 1rem;
}

.settings-grid p {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.45;
    min-height: 3.5rem;
}

.settings-grid button {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 0.48rem 0.7rem;
}

.password-box {
    grid-column: span 2;
}

.settings-single {
    grid-column: span 3;
}

.settings-form {
    display: grid;
    gap: 0.45rem;
}

.password-settings-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
}

.password-settings-item {
    display: grid;
    gap: 0.3rem;
}

.settings-form label {
    font-size: 0.86rem;
    font-weight: 700;
    color: #48566d;
}

.settings-form input {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.52rem 0.6rem;
}

.settings-form textarea,
.settings-form select {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.52rem 0.6rem;
    background: #fff;
}

.settings-form textarea {
    resize: vertical;
    min-height: 120px;
}

.settings-form button {
    justify-self: start;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 0.72rem;
    cursor: pointer;
}

.settings-form-inline {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.settings-form-table-action {
    display: block;
    margin: 0;
}

.settings-form-table-action button {
    width: auto;
    min-width: 120px;
    white-space: nowrap;
}

.email-template-table {
    min-width: 1360px;
    table-layout: fixed;
}

.email-template-table td:first-child .table-input {
    min-width: 320px;
}

.email-template-table td,
.email-type-assignment-table td {
    padding-top: 0.78rem;
    padding-bottom: 0.78rem;
}

.email-template-table th,
.email-template-table td,
.email-type-assignment-table th,
.email-type-assignment-table td {
    white-space: normal;
}

.table-input,
.table-select,
.table-textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.58rem 0.68rem;
    background: #fff;
    font: inherit;
    font-size: 0.92rem;
    color: inherit;
    box-sizing: border-box;
}

.table-input,
.table-select {
    min-height: 2.35rem;
}

.table-textarea {
    resize: vertical;
    min-height: 170px;
    line-height: 1.4;
}

.muted-inline {
    display: block;
    margin-top: 0.16rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.settings-inline-note {
    margin-top: 0.8rem;
    font-size: 0.86rem;
    color: var(--muted);
    line-height: 1.6;
}

.settings-inline-note code {
    display: inline-block;
    margin: 0.16rem 0.25rem 0.16rem 0;
    padding: 0.08rem 0.3rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f4f7fb;
    color: #263547;
    font-size: 0.82rem;
}

.settings-form .danger-button,
.settings-grid .danger-button,
.danger-button {
    border: 1px solid #c62828;
    border-radius: 8px;
    background: #d32f2f;
    color: #fff;
    padding: 0.45rem 0.7rem;
    cursor: pointer;
}

.danger-button:hover {
    background: #b71c1c;
    border-color: #b71c1c;
}

.customer-detail-card {
    margin-top: 0.8rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fbfcff;
    padding: 0.9rem;
}

.customer-detail-card h2 {
    margin: 0;
    font-size: 1rem;
}

.customer-detail-card p {
    margin: 0.4rem 0 0.7rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.customer-detail-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem 0.65rem;
}

.customer-detail-form label {
    font-size: 0.85rem;
    color: #48566d;
    font-weight: 700;
}

.customer-detail-form input {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.52rem 0.6rem;
}

.customer-detail-form select {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.52rem 0.6rem;
    background: #fff;
}

.customer-detail-form textarea {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.52rem 0.6rem;
    resize: vertical;
    min-height: 96px;
}

.field-inline-action {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: nowrap;
    width: 100%;
}

.field-inline-action select {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

.field-inline-action .secondary-button {
    flex: 0 0 auto;
    white-space: nowrap;
}

.secondary-button {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #2e3b52;
    padding: 0.52rem 0.72rem;
    cursor: pointer;
}

.secondary-button:hover {
    background: #f3f6fb;
}

.customer-detail-form button {
    grid-column: 1 / -1;
    justify-self: start;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 0.72rem;
    cursor: pointer;
}

.detail-form-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.65rem;
    flex-wrap: wrap;
}

.detail-form-actions .primary-button {
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 0.72rem;
    cursor: pointer;
}

.detail-form-actions .detail-delete-form {
    margin: 0;
}

.customer-detail-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.detail-page {
    max-width: 980px;
    margin: 0 auto;
    padding: 1rem;
}

.inline-modal {
    border: 0;
    padding: 0;
    border-radius: 12px;
    max-width: 840px;
    width: calc(100% - 2rem);
    background: transparent;
}

.inline-modal::backdrop {
    background: rgba(9, 20, 43, 0.55);
}

.inline-modal-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    padding: 0.9rem;
}

.inline-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.55rem;
}

.inline-modal-head h2 {
    margin: 0;
    font-family: "Sora", sans-serif;
    font-size: 1.12rem;
}

.inline-modal-head form {
    margin: 0;
}

.modal-form {
    gap: 0.38rem 0.6rem;
}

.modal-actions {
    grid-column: 1 / -1;
    margin-top: 0.5rem;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.75rem;
}

.detail-header h1 {
    margin: 0;
    font-family: "Sora", sans-serif;
    font-size: 1.3rem;
}

.detail-header p {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.calendar-page {
    max-width: 1120px;
}

.calendar-nav {
    display: flex;
    gap: 0.5rem;
    margin: 0.7rem 0 0.95rem;
}

.calendar-tab {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.45rem 0.7rem;
    text-decoration: none;
    color: #2a3b55;
    background: #fff;
}

.calendar-tab.is-active {
    background: #203a6d;
    border-color: #34548d;
    color: #fff;
}

.calendar-year-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem;
}

.calendar-month-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.8rem;
    text-decoration: none;
    background: #fff;
    color: #1f2b3f;
    display: grid;
    gap: 0.2rem;
}

.calendar-month-card span {
    color: var(--muted);
    font-size: 0.85rem;
}

.calendar-meta {
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.3;
}

.calendar-month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.45rem;
}

.calendar-month-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.15rem;
}

.calendar-mobile-hint {
    display: none;
    margin: 0 0 0.45rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.calendar-weekday {
    text-align: center;
    font-size: 0.82rem;
    color: #5d6b82;
    font-weight: 700;
    padding: 0.35rem 0;
}

.calendar-day-cell {
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 80px;
    padding: 0.45rem;
    text-decoration: none;
    background: #fff;
    color: #1f2b3f;
    display: grid;
    align-content: space-between;
}

.calendar-day-cell strong {
    font-family: "Sora", sans-serif;
}

.calendar-day-cell.is-muted {
    opacity: 0.55;
}

.calendar-day-panel {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.85rem;
    background: #fff;
}

.calendar-day-panel h2 {
    margin: 0 0 0.65rem;
    font-family: "Sora", sans-serif;
    font-size: 1.1rem;
}

.calendar-day-summary {
    margin: 0 0 0.65rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.calendar-slot-list {
    display: grid;
    gap: 0.4rem;
}

.calendar-slot-row {
    display: grid;
    grid-template-columns: 90px 1fr 130px;
    gap: 0.5rem;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.42rem 0.52rem;
    background: #fbfcff;
}

.slot-time {
    font-weight: 700;
    color: #33425b;
}

.slot-state {
    font-size: 0.88rem;
}

.slot-state.is-blocked {
    color: #9b2727;
}

.slot-state.is-booked {
    color: #1f4f8f;
}

.slot-state.is-open {
    color: #157749;
}

.slot-action {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.36rem 0.52rem;
    cursor: pointer;
}

.slot-action.is-block {
    background: #ffe7e7;
    border-color: #f3b1b1;
    color: #9c2020;
}

.slot-action.is-unblock {
    background: #e8f8ef;
    border-color: #a9dbbc;
    color: #125d39;
}

.slot-action.is-booked {
    background: #e6efff;
    border-color: #b7cbef;
    color: #2d4f83;
    cursor: not-allowed;
    opacity: 0.9;
}

.password-field-wrap {
    position: relative;
    display: block;
}

.password-field-wrap input {
    width: 100%;
    padding-right: 3rem;
}

.password-eye-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    width: 1.5rem;
    height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    color: #55637b;
    cursor: pointer;
    line-height: 1;
}

.password-eye-btn:hover {
    background: #eff3f9;
}

.password-eye-btn.is-active {
    color: #1f2c43;
}

.form-notice,
.form-error {
    border-radius: 8px;
    padding: 0.45rem 0.6rem;
    margin: 0.35rem 0;
    font-size: 0.86rem;
}

.form-notice {
    border: 1px solid #8fdeb3;
    background: #e7f9ef;
    color: #11613e;
}

.form-error {
    border: 1px solid #f1afaf;
    background: #ffeaea;
    color: #a33b3b;
}

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: radial-gradient(circle at top left, #15284f 0%, #0b1834 65%, #09142b 100%);
}

.login-card {
    width: min(460px, 100%);
    border: 1px solid #2a446d;
    border-radius: 12px;
    background: #ffffff;
    padding: 1.3rem 1.15rem;
}

.login-card h1 {
    margin: 0;
    font-family: "Sora", sans-serif;
    font-size: 1.45rem;
}

.login-card p {
    margin: 0.5rem 0 0.8rem;
    color: var(--muted);
}

.login-error {
    border: 1px solid #f0a8a8;
    background: #ffe8e8;
    color: #a43a3a;
    border-radius: 8px;
    padding: 0.55rem 0.65rem;
    margin: 0 0 0.75rem;
}

.login-form {
    display: grid;
    gap: 0.6rem;
}

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

.login-form input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.55rem 0.62rem;
}

.login-form button {
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    padding: 0.55rem 0.62rem;
    cursor: pointer;
}

@media (max-width: 1220px) {
    .toolbar {
        grid-template-columns: 1fr 1fr;
    }

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

    .password-box {
        grid-column: span 2;
    }

    .settings-single {
        grid-column: span 2;
    }

    .email-template-table {
        min-width: 1360px;
    }

    .email-type-assignment-table {
        min-width: 760px;
    }
}

@media (max-width: 860px) {
    .admin-shell {
        grid-template-columns: 72px minmax(0, 1fr);
        min-height: 100vh;
    }

    .sidebar {
        border-right: 1px solid #22375f;
        border-bottom: 0;
        padding: 0.75rem 0.45rem;
    }

    .menu-toggle {
        display: none;
    }

    .brand-card,
    .sidebar-footer {
        display: none;
    }

    .menu-list {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    .menu-item {
        justify-content: center;
        padding: 0.62rem 0.35rem;
    }

    .menu-item > span:last-child {
        display: none;
    }

    .menu-icon {
        width: auto;
        font-size: 1rem;
    }

    .content-area {
        padding: 0.8rem 0.7rem 1rem;
    }

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

    .password-box {
        grid-column: span 1;
    }

    .settings-single {
        grid-column: span 1;
    }

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

    .customer-detail-form {
        grid-template-columns: 1fr;
    }

    .field-inline-action {
        grid-template-columns: 1fr;
    }

    .inline-modal {
        width: calc(100% - 1rem);
    }

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

    .calendar-month-grid {
        min-width: 760px;
        grid-template-columns: repeat(7, minmax(96px, 1fr));
    }

    .calendar-day-cell {
        min-height: 70px;
    }

    .calendar-mobile-hint {
        display: block;
    }

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

    .panel-actions-with-search {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .panel-actions-right {
        width: 100%;
        justify-content: flex-end;
    }
}
