:root {
    --bg: #f5f7f8;
    --panel: #ffffff;
    --ink: #1d252c;
    --muted: #66727f;
    --line: #dbe1e6;
    --primary: #0f766e;
    --primary-dark: #0b5f59;
    --danger: #b42318;
    --success: #087443;
    --warning: #a15c07;
    --blue: #1d4ed8;
    --shadow: 0 18px 50px rgba(25, 35, 45, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
}

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

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 18px;
}

.auth-shell {
    width: min(460px, 100%);
}

.install-shell {
    width: min(760px, 100%);
}

.auth-card,
.info-panel,
.table-wrap,
.toolbar,
.detail-header {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.auth-card {
    padding: 32px;
}

.brand-block {
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: 28px;
    line-height: 1.2;
}

h2 {
    margin-bottom: 8px;
    font-size: 24px;
}

h3 {
    margin-bottom: 16px;
    font-size: 17px;
}

.brand-block p,
.detail-header p {
    color: var(--muted);
}

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

.login-form {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 7px;
}

.field span {
    color: #35424e;
    font-size: 13px;
    font-weight: 700;
}

.field.inline {
    align-items: center;
    grid-template-columns: auto minmax(150px, 1fr);
}

.field.compact {
    max-width: 180px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cdd5dc;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    padding: 9px 11px;
}

textarea {
    min-height: 180px;
    resize: vertical;
}

.button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 8px 14px;
    white-space: nowrap;
}

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

.button.primary:hover {
    background: var(--primary-dark);
}

.button.ghost {
    background: transparent;
}

.button.full {
    width: 100%;
    grid-column: 1 / -1;
}

.button.small {
    min-height: 32px;
    padding: 5px 10px;
}

.notice {
    margin-bottom: 16px;
    border-radius: 6px;
    padding: 12px 14px;
    font-weight: 700;
}

.notice.success {
    background: #e8f7ef;
    color: var(--success);
}

.notice.danger {
    background: #fff0ed;
    color: var(--danger);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    padding: 18px 28px;
}

.app-header h1 {
    margin: 0;
    font-size: 24px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

.page {
    width: min(1280px, calc(100% - 36px));
    margin: 28px auto 56px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    display: grid;
    gap: 10px;
    min-height: 94px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 16px;
}

.stat-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stat-card strong {
    font-size: 28px;
}

.link-card:hover {
    border-color: var(--primary);
}

.toolbar {
    margin-bottom: 16px;
    padding: 16px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 13px 14px;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f8fafb;
    color: #4a5560;
    font-size: 12px;
    letter-spacing: 0;
}

td small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.subject-cell {
    max-width: 300px;
    color: var(--muted);
}

.empty-cell {
    height: 160px;
    color: var(--muted);
    text-align: center;
}

.status-select {
    min-width: 118px;
    min-height: 36px;
    padding: 6px 8px;
    font-size: 13px;
    font-weight: 700;
}

.badge,
.status-select {
    border-radius: 999px;
}

.badge {
    display: inline-flex;
    margin-bottom: 12px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
}

.status-new {
    background: #fff7ed;
    color: var(--warning);
}

.status-phone_unconfirmed {
    background: #fff1f2;
    color: #be123c;
}

.status-confirmed {
    background: #eff6ff;
    color: var(--blue);
}

.status-in_progress {
    background: #f3e8ff;
    color: #6d28d9;
}

.status-completed {
    background: #e8f7ef;
    color: var(--success);
}

.status-canceled {
    background: #fff0ed;
    color: var(--danger);
}

.detail-page {
    display: grid;
    gap: 16px;
}

.create-page {
    width: min(980px, calc(100% - 36px));
}

.create-form {
    display: grid;
    gap: 22px;
}

.form-section {
    display: grid;
    gap: 14px;
}

.form-section h2 {
    margin: 0;
    font-size: 18px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.calendar-page {
    display: grid;
    gap: 16px;
}

.calendar-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.calendar-toolbar h2 {
    margin: 0 auto 0 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.calendar-weekday {
    background: #f8fafb;
    border-bottom: 1px solid var(--line);
    color: #4a5560;
    font-size: 13px;
    font-weight: 700;
    padding: 12px;
    text-align: center;
}

.calendar-day {
    min-height: 156px;
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    padding: 10px;
}

.calendar-day:nth-child(7n + 7) {
    border-right: 0;
}

.calendar-day.outside-month {
    background: #f8fafb;
    color: #9aa4ae;
}

.calendar-day.today {
    box-shadow: inset 0 0 0 2px var(--primary);
}

.calendar-date {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 800;
}

.calendar-date strong {
    color: var(--primary);
    font-size: 12px;
}

.calendar-items {
    display: grid;
    gap: 6px;
}

.calendar-item {
    display: grid;
    gap: 2px;
    border-radius: 6px;
    padding: 8px;
}

.calendar-item span,
.calendar-item em {
    font-size: 12px;
    font-style: normal;
}

.calendar-item strong {
    font-size: 13px;
}

.missing-list {
    display: grid;
    gap: 10px;
}

.missing-item {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr) 140px;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
}

.missing-item span {
    color: var(--muted);
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 22px;
}

.detail-status {
    display: flex;
    align-items: end;
    gap: 10px;
}

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

.info-panel {
    padding: 20px;
}

dl {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    gap: 10px 14px;
    margin: 0;
}

dt {
    color: var(--muted);
    font-weight: 700;
}

dd {
    margin: 0;
}

pre {
    max-height: 540px;
    overflow: auto;
    margin: 0;
    border-radius: 6px;
    background: #f8fafb;
    padding: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 860px) {
    .app-header,
    .detail-header {
        align-items: flex-start;
        flex-direction: column;
    }

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

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

    .filters,
    .detail-status {
        align-items: stretch;
        flex-direction: column;
    }

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

    .calendar-weekday {
        display: none;
    }

    .calendar-day {
        min-height: auto;
        border-right: 0;
    }

    .calendar-toolbar {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .missing-item {
        grid-template-columns: 1fr;
    }
}
