* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scrollbar-gutter: stable;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 17px;
    line-height: 1.7;
    color: #1a1a1a;
    background: #fff;
    padding: 3rem 1.5rem;
    max-width: 680px;
    margin: 0 auto;
}

.wrap {
    max-width: 100%;
}

.header {
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: #666;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.form {
    background: #f5f5f5;
    border: 1px solid #eee;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-radius: 8px;
}

.form-row {
    margin-bottom: 1rem;
}

.form-row:last-of-type {
    margin-bottom: 1.25rem;
}

.form label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.35rem;
}

.form-hint {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.35rem;
}

.form-hint a {
    color: #1a1a1a;
    text-decoration: underline;
}

.form-hint a:hover {
    color: #333;
}

.form input {
    width: 100%;
    max-width: 220px;
    padding: 0.5rem 0.65rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 8px;
}

.form input:focus {
    outline: none;
    border-color: #1a1a1a;
}

.input-with-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    max-width: max-content;
}

.input-with-btn input {
    max-width: 220px;
}

.btn-search {
    padding: 0 0.6rem;
    font-size: 1.1rem;
    line-height: 1;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    color: #666;
    align-self: stretch;
    border-radius: 8px;
}

.btn-search:hover {
    background: #eee;
    border-color: #999;
    color: #1a1a1a;
}

.form select {
    width: 100%;
    max-width: 220px;
    padding: 0.5rem 0.65rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    border-radius: 8px;
}

.form select:focus {
    outline: none;
    border-color: #1a1a1a;
}

.btn {
    padding: 0.4rem 0.85rem;
    font-size: 0.9rem;
    font-family: inherit;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    color: #1a1a1a;
    border-radius: 8px;
}

.btn:hover {
    background: #eee;
    border-color: #999;
}

.btn:disabled,
.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #fff;
}

.btn-primary:hover {
    background: #333;
    border-color: #333;
    color: #fff;
}

.btn-primary:disabled {
    background: #666;
    border-color: #666;
}

.error {
    padding: 0.75rem 1rem;
    background: #fef2f2;
    color: #b91c1c;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
}

.slots-container {
    position: relative;
    min-height: 120px;
}

.loading-state[hidden] {
    display: none !important;
}

.loading-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: #666;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.8);
    z-index: 1;
}

.loading-state .loading-spinner {
    width: 48px;
    height: 48px;
    display: block;
}

.slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
    min-height: 120px;
}

.slots-empty {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.95rem;
}

.slot {
    padding: 0.6rem 0.75rem;
    text-align: center;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
}

.slot time {
    display: block;
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}

.slot .count {
    font-size: 0.8rem;
    color: #666;
}

.slot.available {
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.slot.available .count {
    color: #047857;
    font-weight: 500;
}

.slots.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* SRO search dialog */
.sro-dialog {
    border: none;
    border-radius: 8px;
    padding: 0;
    width: 90vw;
    max-width: 500px;
    max-height: 80vh;
    font-family: inherit;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    margin: auto;
}

.sro-dialog[open] {
    display: flex;
    flex-direction: column;
}

.sro-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

.sro-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eee;
}

.sro-dialog-title {
    font-weight: 600;
    font-size: 1rem;
}

.sro-dialog-desc {
    padding: 0.5rem 1.25rem;
    font-size: 0.8rem;
    color: #888;
    line-height: 1.4;
}

.sro-dialog-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0 0.25rem;
}

.sro-dialog-close:hover {
    color: #1a1a1a;
}

.sro-search-input {
    display: block;
    width: 100%;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-family: inherit;
    border: none;
    border-bottom: 1px solid #eee;
    outline: none;
}

.sro-search-status {
    padding: 0.5rem 1.25rem;
    font-size: 0.8rem;
    color: #666;
}

.sro-quick-picks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.sro-quick-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    font-family: inherit;
    border: 1px solid #a7f3d0;
    background: #ecfdf5;
    color: #047857;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
}

.sro-quick-btn:hover {
    background: #d1fae5;
    border-color: #6ee7b7;
}

.sro-search-results {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.sro-result {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.6rem 1.25rem;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
}

.sro-result:hover {
    background: #f5f5f5;
}

.sro-result-village {
    font-weight: 500;
    font-size: 0.95rem;
}

.sro-result-meta {
    font-size: 0.8rem;
    color: #666;
}

.sro-result-code {
    font-size: 0.8rem;
    color: #047857;
    font-weight: 500;
}

@media (max-width: 500px) {
    body {
        font-size: 16px;
        padding: 2rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .sro-dialog {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        margin: 0;
        position: fixed;
        top: 0;
        left: 0;
    }

    .sro-search-input {
        font-size: 16px;
    }

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