/* ---------- Tokens ---------- */
:root {
    --color-bg: #f8f7fc;
    --color-surface: #ffffff;
    --color-border: #e8e3f5;
    --color-text: #1f1a33;
    --color-text-muted: #6f6785;
    --color-primary: #7c3aed;
    --color-primary-dark: #6425d0;
    --color-primary-light: #f1ebfe;
    --color-accent: #f97316;
    --color-success-bg: #e6f9ef;
    --color-success-text: #0e9d5c;
    --color-warning-bg: #fef3e2;
    --color-warning-text: #b45309;
    --color-error-bg: #fde7f0;
    --color-error-text: #d6336c;
    --color-muted-bg: #f1eef8;
    --color-muted-text: #6f6785;
    --sidebar-width: 232px;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 2px 10px rgba(124, 58, 237, 0.08), 0 1px 2px rgba(31, 26, 51, 0.04);
    --shadow-lg: 0 16px 36px rgba(124, 58, 237, 0.18);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Reset ---------- */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3, dl, p {
    margin: 0;
}

table {
    border-collapse: collapse;
}

/* ---------- Guest / Login ---------- */
.guest-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 15%, rgba(124, 58, 237, 0.16), transparent 45%),
        radial-gradient(circle at 85% 10%, rgba(249, 115, 22, 0.12), transparent 42%),
        radial-gradient(circle at 50% 100%, rgba(124, 58, 237, 0.08), transparent 50%),
        var(--color-bg);
}

.guest-wrap {
    width: 100%;
    max-width: 400px;
}

.guest-wrap-wide {
    max-width: 900px;
}

.auth-card {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
    overflow: hidden;
}

.auth-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--color-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 18px;
}

.auth-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.auth-subtitle {
    color: var(--color-text-muted);
    margin-top: 4px;
    margin-bottom: 24px;
}

/* ---------- Login split panel ---------- */
.login-split {
    display: flex;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-branding {
    flex: 1;
    min-width: 0;
    background: linear-gradient(160deg, var(--color-primary) 0%, #4c1d95 130%);
    color: #fff;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
    position: relative;
    overflow: hidden;
}

.login-branding::after {
    content: "";
    position: absolute;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: rgba(249, 115, 22, 0.28);
    right: -130px;
    bottom: -150px;
}

.login-branding-icon {
    font-size: 40px;
    line-height: 1;
}

.login-branding h2 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.3;
    position: relative;
}

.login-branding p {
    font-size: 14px;
    line-height: 1.6;
    opacity: 0.85;
    position: relative;
}

.login-branding-list {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 13px;
    position: relative;
}

.login-branding-list li {
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-branding-list li span:first-child {
    font-size: 16px;
}

.login-form-panel {
    flex: 1;
    min-width: 0;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.input-icon-wrap {
    position: relative;
}

.input-icon-wrap input[type="text"],
.input-icon-wrap input[type="password"],
.input-icon-wrap input[type="email"] {
    padding-left: 40px;
}

.input-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    pointer-events: none;
}

@media (max-width: 760px) {
    .login-branding {
        display: none;
    }

    .login-form-panel {
        padding: 36px 28px;
    }
}

/* ---------- App Shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: #1a1330;
    color: #c9c1de;
    padding: 22px 0;
}

.app-brand {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.01em;
    color: #fff;
    padding: 0 20px 22px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-nav {
    display: flex;
    flex-direction: column;
    padding: 0 10px;
}

.app-nav a {
    color: #c9c1de;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
}

.app-nav a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    text-decoration: none;
}

.app-nav a.active {
    background: linear-gradient(135deg, var(--color-primary), #9b5cf6);
    color: #fff;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
}

.app-nav-heading {
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    color: #756c92;
    padding: 18px 12px 6px;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 16px 28px;
}

.app-topbar-title {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
    flex: 1;
}

.app-topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--color-text-muted);
    font-size: 14px;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

.app-content {
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ---------- Cards / Stats ---------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.card-narrow {
    max-width: 560px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 14px;
}

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

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 22px;
    height: 22px;
}

.stat-card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.stat-label {
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 500;
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--color-primary-dark);
}

/* ---------- Forms ---------- */
.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-check-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.form-check {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    color: var(--color-text);
}

.auth-inline-link {
    font-size: 13px;
    font-weight: 600;
}

.auth-footer-link {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--color-text-muted);
}

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="number"],
select,
textarea {
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    padding: 10px 13px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

textarea {
    resize: vertical;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), #9457f0);
    color: #fff;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
}

.btn-ghost {
    background: none;
    border: none;
    color: var(--color-text-muted);
}

.btn-ghost:hover {
    color: var(--color-text);
}

.btn-block {
    width: 100%;
}

.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 0;
    font-family: inherit;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-link-danger {
    color: var(--color-error-text);
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ---------- Tables ---------- */
.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    font-size: 14px;
}

.table th,
.table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.table th {
    color: var(--color-text-muted);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table tbody tr {
    transition: background 0.1s ease;
}

.table tbody tr:hover {
    background: var(--color-primary-light);
}

.table-actions {
    display: flex;
    gap: 12px;
}

.table-actions form {
    display: inline;
}

.empty-state {
    color: var(--color-text-muted);
    padding: 12px 0;
}

/* ---------- Detail list ---------- */
.detail-list {
    display: grid;
    grid-template-columns: 140px 1fr;
    row-gap: 12px;
}

.detail-list dt {
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 500;
}

.detail-list dd {
    margin: 0;
}

/* ---------- Badges / Alerts ---------- */
.badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.badge-error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

.badge-muted {
    background: var(--color-muted-bg);
    color: var(--color-muted-text);
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.alert-error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

.alert-error ul {
    margin: 0;
    padding-left: 18px;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding-top: 8px;
}

.page-link {
    font-size: 13px;
    font-weight: 600;
}

.page-link.disabled {
    color: var(--color-text-muted);
    pointer-events: none;
}

.pagination-info {
    font-size: 13px;
    color: var(--color-text-muted);
}

/* ---------- Error pages ---------- */
.error-card {
    text-align: center;
}

.error-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 18px;
}

.error-code-label {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
}

/* ---------- Events ---------- */
.event-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.event-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    color: inherit;
    position: relative;
    transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.event-card:hover {
    text-decoration: none;
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary);
    transform: translateY(-3px);
}

.event-card-date {
    flex-shrink: 0;
    width: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-light);
    border-radius: var(--radius-sm);
    padding: 8px 0;
    line-height: 1.1;
}

.event-card-date-month {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-primary);
}

.event-card-date-day {
    font-size: 22px;
    font-weight: 800;
    color: var(--color-primary-dark);
}

.event-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    min-width: 0;
}

.event-card-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0;
}

.event-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 0;
    max-width: 100%;
}

.event-card-meta-icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: var(--color-text-muted);
}

.event-card-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-show-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.event-description {
    margin: 16px 0;
    line-height: 1.6;
}

.event-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
    margin-top: 8px;
}

/* ---------- Calendar ---------- */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.calendar-header h2 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.calendar-weekdays {
    margin-bottom: 6px;
}

.calendar-weekday {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.calendar-cell {
    min-height: 84px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--color-surface);
}

.calendar-cell-blank {
    border-color: transparent;
    background: none;
}

.calendar-cell-today {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
    background: var(--color-primary-light);
}

.calendar-date {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-muted);
}

.calendar-cell-today .calendar-date {
    color: var(--color-primary);
}

.calendar-chips {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.chip {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    cursor: pointer;
    transition: filter 0.1s ease, transform 0.1s ease;
}

.chip:hover {
    text-decoration: none;
    filter: brightness(0.95);
    transform: translateY(-1px);
}

.chip-scheduled {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.chip-cancelled {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

@media (max-width: 860px) {
    .calendar-cell {
        min-height: 56px;
    }

    .calendar-weekday {
        font-size: 9px;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .app-shell.nav-open .app-sidebar {
        transform: translateX(0);
    }

    .nav-toggle {
        display: block;
    }

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