:root {
    --ink: #17262d;
    --ink-soft: #526168;
    --paper: #f3f6f5;
    --surface: #ffffff;
    --line: #d8e0df;
    --accent: #0b7f7b;
    --accent-soft: #dcefed;
    --amber: #c9892f;
    --danger: #b74d4a;
    --shadow: 0 18px 50px rgba(23, 38, 45, .09);
    --radius: 18px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    min-width: 320px;
    background: var(--paper);
    color: var(--ink);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

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

button, select { cursor: pointer; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
    outline: 3px solid rgba(11, 127, 123, .28);
    outline-offset: 2px;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 300px minmax(0, 1fr); }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 26px 22px 20px;
    background: var(--ink);
    color: #f7fbfa;
    overflow-y: auto;
}

.brand-lockup { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.brand-lockup strong { display: block; font-family: Georgia, serif; font-size: 18px; letter-spacing: -.01em; }

.eyebrow {
    margin: 0 0 3px;
    color: #789095;
    font-family: Consolas, "Courier New", monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.sidebar .eyebrow { color: #8ca4a7; }

.aperture-mark {
    position: relative;
    width: 48px;
    height: 48px;
    border: 1px solid currentColor;
    border-radius: 50%;
    color: var(--accent);
}

.aperture-mark::before, .aperture-mark::after, .aperture-mark span::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 1px;
    height: 75%;
    background: currentColor;
    transform-origin: center;
}
.aperture-mark::before { transform: translate(-50%, -50%) rotate(60deg); }
.aperture-mark::after { transform: translate(-50%, -50%) rotate(-60deg); }
.aperture-mark span::before { transform: translate(-50%, -50%); }
.aperture-mark span::after {
    content: "";
    position: absolute;
    inset: 14px;
    border: 1px solid currentColor;
    border-radius: 50%;
    background: var(--ink);
}
.aperture-mark.small { width: 38px; height: 38px; flex: 0 0 auto; }
.aperture-mark.small span::after { inset: 11px; }

.primary-button, .secondary-button, .quiet-button, .icon-button {
    border: 0;
    border-radius: 11px;
    transition: transform .15s ease, background .15s ease, color .15s ease;
}

.primary-button {
    min-height: 44px;
    padding: 10px 17px;
    background: var(--accent);
    color: white;
    font-weight: 700;
}
.primary-button:hover { background: #086d69; transform: translateY(-1px); }
.new-event-button { width: 100%; margin-bottom: 30px; text-align: left; }
.new-event-button span { margin-right: 7px; font-size: 19px; line-height: 0; }

.secondary-button {
    min-height: 42px;
    padding: 9px 15px;
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    color: #075c59;
    font-weight: 700;
}

.quiet-button { min-height: 40px; padding: 8px 14px; background: #e9eeee; color: var(--ink); font-weight: 650; }
.quiet-button:hover { background: #dfe7e6; }
.icon-button { width: 40px; height: 40px; background: #e9eeee; color: var(--ink); font-size: 18px; }
.icon-button:hover { background: #dfe7e6; }

.side-section { margin-bottom: 28px; }
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    color: #8ca4a7;
    font-family: Consolas, "Courier New", monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #62c2a3; box-shadow: 0 0 0 4px rgba(98,194,163,.12); }

.summary-stack { border-top: 1px solid rgba(255,255,255,.13); }
.summary-stack article { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 13px 0; border-bottom: 1px solid rgba(255,255,255,.13); }
.summary-stack span { color: #9db0b3; font-size: 13px; }
.summary-stack strong { font-family: Georgia, serif; font-size: 20px; font-variant-numeric: tabular-nums; }
.summary-stack .pending strong { color: #efba6f; }

.upcoming-list { display: grid; gap: 5px; }
.upcoming-item {
    position: relative;
    display: grid;
    grid-template-columns: 43px 1fr;
    gap: 10px;
    width: 100%;
    padding: 10px 9px 10px 15px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    text-align: left;
}
.upcoming-item::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 2px; background: var(--event-color, #62c2a3); }
.upcoming-item:hover { background: rgba(255,255,255,.06); }
.upcoming-date { color: #aac0c2; font-family: Consolas, "Courier New", monospace; font-size: 11px; line-height: 1.25; text-transform: uppercase; }
.upcoming-date strong { display: block; color: white; font-size: 18px; }
.upcoming-copy strong, .upcoming-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upcoming-copy strong { font-size: 13px; }
.upcoming-copy span { color: #9db0b3; font-size: 12px; }
.empty-side { color: #91a6a9; font-size: 13px; }
.logout-link { margin-top: auto; padding-top: 20px; color: #9db0b3; font-size: 13px; text-decoration: none; }
.logout-link:hover { color: white; }

.workspace { min-width: 0; padding: 38px clamp(22px, 4vw, 60px) 50px; }
.workspace-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.today-line { margin: 0 0 3px; color: var(--ink-soft); font-family: Consolas, "Courier New", monospace; font-size: 12px; text-transform: uppercase; }
.workspace-header h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(34px, 4vw, 54px); font-weight: 400; letter-spacing: -.04em; text-transform: capitalize; }
.calendar-controls { display: flex; gap: 7px; }

.toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.search-field { position: relative; flex: 1; max-width: 400px; }
.search-field span { position: absolute; left: 14px; top: 8px; color: var(--ink-soft); font-size: 20px; }
.search-field input { width: 100%; padding-left: 42px; }

input, select, textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid #ccd6d5;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    padding: 9px 11px;
}
textarea { resize: vertical; }

.calendar-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.weekday-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(105px, 1fr)); }
.weekday-row { min-width: 735px; border-bottom: 1px solid var(--line); background: #eef2f1; }
.weekday-row span { padding: 12px 13px; color: var(--ink-soft); font-family: Consolas, "Courier New", monospace; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.calendar-grid { min-width: 735px; }
.day-cell {
    position: relative;
    min-height: 128px;
    padding: 9px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #fff;
    transition: background .15s ease;
}
.day-cell:nth-child(7n) { border-right: 0; }
.day-cell:nth-last-child(-n + 7) { border-bottom: 0; }
.day-cell:hover { background: #f8fbfa; }
.day-cell.outside { background: #f7f8f8; color: #9ba7a8; }
.day-cell.today .day-number { background: var(--ink); color: white; }
.day-cell.has-events::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.day-number { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.day-add { float: right; width: 27px; height: 27px; border: 0; border-radius: 50%; background: transparent; color: #879596; opacity: 0; }
.day-cell:hover .day-add, .day-add:focus-visible { opacity: 1; }
.day-add:hover { background: var(--accent-soft); color: var(--accent); }
.day-events { display: grid; gap: 5px; margin-top: 6px; }
.event-chip {
    display: block;
    width: 100%;
    overflow: hidden;
    padding: 6px 7px;
    border: 0;
    border-left: 3px solid var(--event-color);
    border-radius: 5px;
    background: color-mix(in srgb, var(--event-color) 12%, white);
    color: var(--ink);
    font-size: 11px;
    line-height: 1.2;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.event-chip:hover { background: color-mix(in srgb, var(--event-color) 20%, white); }
.event-chip time { margin-right: 4px; color: var(--ink-soft); font-family: Consolas, "Courier New", monospace; font-size: 9px; }
.more-events { color: var(--ink-soft); font-size: 10px; text-align: center; }
.mobile-agenda { display: none; }
.mobile-upcoming-card { display: none; }

.app-dialog {
    width: min(720px, calc(100vw - 26px));
    max-height: calc(100vh - 30px);
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: 20px;
    background: white;
    color: var(--ink);
    box-shadow: 0 30px 100px rgba(15,30,36,.26);
}
.app-dialog::backdrop { background: rgba(15, 28, 34, .62); backdrop-filter: blur(4px); }
.app-dialog > form, .app-dialog > div:not(.dialog-header) { margin: 0; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 18px; padding: 25px 28px 18px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-family: Georgia, serif; font-size: 27px; font-weight: 400; letter-spacing: -.02em; }
.dialog-header .icon-button { background: transparent; font-size: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 16px; padding: 22px 28px; }
.form-grid label, .payment-form label { color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.form-grid input, .form-grid select, .form-grid textarea, .payment-form input, .payment-form select { margin-top: 5px; font-weight: 400; }
.span-2 { grid-column: span 2; }
.money-input { position: relative; }
.money-input span { position: absolute; z-index: 1; left: 11px; top: 16px; color: var(--ink-soft); font-family: Consolas, monospace; font-size: 12px; }
.money-input input { padding-left: 35px; }
.dialog-actions { display: flex; align-items: center; gap: 10px; padding: 16px 28px 22px; border-top: 1px solid var(--line); }
.action-spacer { flex: 1; }
.danger-link { border: 0; background: transparent; color: var(--danger); font-size: 13px; font-weight: 700; }
.danger-link:hover { text-decoration: underline; }
.hidden { display: none !important; }

.detail-dialog { width: min(760px, calc(100vw - 26px)); }
.detail-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.detail-summary article { min-height: 90px; padding: 17px 22px; background: white; }
.detail-summary span { display: block; margin-bottom: 4px; color: var(--ink-soft); font-size: 11px; text-transform: uppercase; }
.detail-summary strong { font-family: Georgia, serif; font-size: 19px; font-weight: 400; }
.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 26px; padding: 21px 28px; }
.detail-meta div { min-width: 0; }
.detail-meta span { display: block; margin-bottom: 3px; color: var(--ink-soft); font-family: Consolas, monospace; font-size: 10px; text-transform: uppercase; }
.detail-meta p { margin: 0; overflow-wrap: anywhere; }
.detail-meta .wide { grid-column: span 2; }
.status-badge { display: inline-block; padding: 4px 8px; border-radius: 99px; background: var(--badge-bg); color: var(--badge-color); font-size: 11px; font-weight: 700; }
.payment-section { padding: 20px 28px 24px; border-top: 1px solid var(--line); background: #f7f9f8; }
.payment-section .section-heading { color: var(--ink-soft); }
.payment-list { display: grid; gap: 7px; margin-bottom: 15px; }
.payment-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 13px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.payment-row p { margin: 0; }
.payment-row small { color: var(--ink-soft); }
.payment-row strong { font-family: Consolas, monospace; font-size: 13px; }
.payment-delete { width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--danger); }
.payment-delete:hover { background: #f9e8e7; }
.empty-payments { padding: 13px; border: 1px dashed #c7d2d1; border-radius: 10px; color: var(--ink-soft); text-align: center; }
.payment-form { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.payment-note { grid-column: span 2; }
.payment-form button { align-self: end; }

.toast {
    position: fixed;
    z-index: 100;
    right: 24px;
    bottom: 24px;
    max-width: min(360px, calc(100vw - 48px));
    padding: 12px 16px;
    border-radius: 11px;
    background: var(--ink);
    color: white;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

.login-page { min-height: 100vh; background: var(--ink); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 22px; background-image: radial-gradient(circle at 15% 20%, rgba(11,127,123,.28), transparent 35%), linear-gradient(135deg, transparent 49.8%, rgba(255,255,255,.035) 50%, transparent 50.2%); background-size: auto, 44px 44px; }
.login-card { width: min(430px, 100%); padding: 38px; border-radius: 24px; background: white; box-shadow: 0 35px 100px rgba(0,0,0,.28); }
.login-card .aperture-mark { margin-bottom: 22px; }
.login-card .aperture-mark span::after { background: white; }
.login-card h1 { margin: 0; font-family: Georgia, serif; font-size: 35px; font-weight: 400; letter-spacing: -.03em; }
.login-copy { margin: 8px 0 24px; color: var(--ink-soft); }
.login-form { display: grid; gap: 15px; }
.login-form label { color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.login-form input { margin-top: 5px; font-weight: 400; }
.login-form .primary-button { margin-top: 5px; }
.form-error { margin-bottom: 15px; padding: 10px 12px; border-radius: 9px; background: #fae8e7; color: #8b3532; font-size: 13px; }

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 240px minmax(0, 1fr); }
    .sidebar { padding-inline: 17px; }
    .upcoming-panel { display: none; }
}

@media (max-width: 900px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 14px 16px; overflow: visible; }
    .brand-lockup { margin: 0; }
    .sidebar .side-section, .sidebar .logout-link { display: none; }
    .new-event-button { position: fixed; z-index: 20; right: 18px; bottom: 18px; width: auto; margin: 0; box-shadow: 0 12px 30px rgba(4,77,74,.3); }
    .workspace { padding: 20px 14px 96px; }
    .workspace-header { align-items: center; }
    .workspace-header h1 { font-size: 34px; }
    .calendar-controls .quiet-button { display: none; }
    .mobile-upcoming-card {
        display: block;
        margin-bottom: 18px;
        padding: 18px 16px 16px;
        border: 1px solid #cad8d6;
        border-radius: 18px;
        background: #fff;
        box-shadow: 0 14px 35px rgba(23, 38, 45, .08);
    }
    .mobile-upcoming-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .mobile-upcoming-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 25px; font-weight: 400; letter-spacing: -.025em; }
    .mobile-upcoming-count { display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 9px; border-radius: 99px; background: var(--ink); color: #fff; font-family: Consolas, monospace; font-size: 12px; }
    .mobile-upcoming-help { margin: 4px 0 14px; color: var(--ink-soft); font-size: 12px; }
    .mobile-upcoming-list { display: grid; gap: 9px; }
    .mobile-upcoming-item {
        position: relative;
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr);
        gap: 12px;
        width: 100%;
        min-height: 82px;
        padding: 11px 11px 11px 14px;
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 13px;
        background: #fbfcfc;
        color: var(--ink);
        text-align: left;
    }
    .mobile-upcoming-item::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--event-color); }
    .mobile-upcoming-item:active { transform: scale(.99); background: #f1f6f5; }
    .mobile-upcoming-date { display: flex; flex-direction: column; align-items: center; justify-content: center; border-right: 1px solid var(--line); color: var(--ink-soft); line-height: 1; text-transform: uppercase; }
    .mobile-upcoming-date small { font-family: Consolas, monospace; font-size: 10px; font-weight: 700; }
    .mobile-upcoming-date strong { margin: 2px 0; color: var(--ink); font-family: Georgia, serif; font-size: 25px; font-weight: 400; }
    .mobile-upcoming-date em { font-size: 9px; font-style: normal; }
    .mobile-upcoming-copy { display: grid; align-content: center; min-width: 0; }
    .mobile-upcoming-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
    .mobile-upcoming-title > strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
    .mobile-status { flex: 0 0 auto; padding: 3px 7px; border-radius: 99px; background: var(--badge-bg); color: var(--badge-color); font-size: 9px; font-weight: 700; }
    .mobile-upcoming-service { margin-top: 4px; overflow: hidden; color: var(--ink); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
    .mobile-upcoming-meta { margin-top: 3px; overflow: hidden; color: var(--ink-soft); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
    .mobile-upcoming-empty { display: grid; gap: 3px; padding: 24px 14px; border: 1px dashed #bdccca; border-radius: 12px; color: var(--ink-soft); text-align: center; }
    .mobile-upcoming-empty strong { color: var(--ink); }
    .mobile-upcoming-more { margin: 3px 2px 0; color: var(--ink-soft); font-size: 11px; text-align: center; }
    .toolbar { align-items: stretch; }
    .toolbar select { width: 42%; }
    .calendar-card { overflow: visible; border: 0; background: transparent; box-shadow: none; }
    .weekday-row, .calendar-grid { display: none; }
    .mobile-agenda { display: grid; gap: 10px; }
    .mobile-day { display: grid; grid-template-columns: 52px 1fr; gap: 10px; }
    .mobile-date { padding-top: 6px; color: var(--ink-soft); font-family: Consolas, monospace; font-size: 10px; text-align: center; text-transform: uppercase; }
    .mobile-date strong { display: block; color: var(--ink); font-family: Georgia, serif; font-size: 25px; font-weight: 400; }
    .mobile-events { display: grid; gap: 7px; }
    .mobile-event { position: relative; width: 100%; padding: 13px 15px 13px 18px; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--ink); text-align: left; }
    .mobile-event::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--event-color); }
    .mobile-event strong, .mobile-event span { display: block; }
    .mobile-event span { margin-top: 2px; color: var(--ink-soft); font-size: 12px; }
    .mobile-empty { padding: 45px 18px; border: 1px dashed var(--line); border-radius: 14px; color: var(--ink-soft); text-align: center; }
    .app-dialog { max-height: calc(100vh - 12px); }
    .dialog-header { padding: 20px 18px 15px; }
    .form-grid { grid-template-columns: 1fr; padding: 18px; }
    .span-2 { grid-column: span 1; }
    .dialog-actions { padding: 14px 18px 18px; flex-wrap: wrap; }
    .detail-summary { grid-template-columns: 1fr; }
    .detail-summary article { min-height: auto; }
    .detail-meta { grid-template-columns: 1fr; padding: 18px; }
    .detail-meta .wide { grid-column: span 1; }
    .payment-section { padding: 18px; }
    .payment-form { grid-template-columns: 1fr; }
    .payment-note { grid-column: span 1; }
}

@media (max-width: 560px) {
    .workspace-header { margin-bottom: 16px; }
    .workspace-header h1 { font-size: 30px; }
    .today-line { font-size: 10px; }
    .toolbar { display: grid; grid-template-columns: 1fr; }
    .search-field { max-width: none; }
    .toolbar select { width: 100%; }
    .mobile-day { grid-template-columns: 43px 1fr; gap: 8px; }
    .new-event-button { right: 14px; bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

