:root {
    --bg: #f8f9fd;
    --panel: #ffffff;
    --line: #e7eaf3;
    --text: #101426;
    --muted: #6e7590;
    --violet: #5b35f2;
    --violet-soft: #f0ebff;
    --green: #13b45b;
    --blue: #1577ff;
    --red: #ff2948;
    --orange: #ff8a00;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--violet); text-decoration: none; }
button, input, select, textarea { font: inherit; }
.link-button {
    border: 0;
    background: transparent;
    padding: 0;
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
    text-align: left;
}
.link-button:hover { color: var(--violet); }

.app-shell { display: grid; grid-template-columns: 276px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    background: rgba(255, 255, 255, .92);
    border-right: 1px solid var(--line);
    padding: 32px 16px;
    display: flex;
    flex-direction: column;
    gap: 44px;
}
.brand { display: flex; align-items: center; gap: 14px; font-size: 25px; letter-spacing: 0; }
.brand-mark {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    background: var(--violet);
    color: white;
    font-weight: 800;
}
.sidebar-nav { display: grid; gap: 10px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 18px;
    height: 62px;
    padding: 0 20px;
    border-radius: 8px;
    color: var(--text);
    font-size: 18px;
}
.nav-item.active { color: var(--violet); background: var(--violet-soft); }
.nav-icon { width: 28px; text-align: center; font-size: 26px; }
.user-block { margin-top: auto; display: grid; grid-template-columns: 44px 1fr 34px; align-items: center; gap: 12px; }
.user-block span { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }
.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d7ebff, #f3d4e6);
    display: grid;
    place-items: center;
    font-weight: 800;
}
.icon-btn { border: 0; background: transparent; cursor: pointer; color: var(--text); font-size: 18px; }

.content { padding: 30px 34px 44px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 22px; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; }
h2 { font-size: 22px; margin-bottom: 24px; }
h3 { font-size: 22px; margin-bottom: 18px; }
.page-head p { color: var(--muted); margin: 8px 0 0; }

.primary-btn {
    border: 0;
    border-radius: 8px;
    background: var(--violet);
    color: white;
    min-height: 44px;
    padding: 0 20px;
    cursor: pointer;
    font-weight: 700;
}
.outline-btn {
    border: 1px solid var(--line);
    background: white;
    min-height: 36px;
    border-radius: 6px;
    padding: 0 16px;
    cursor: pointer;
    color: #30354d;
    font-weight: 700;
}
.outline-btn.violet { color: var(--violet); border-color: #d9d0ff; }
.outline-btn.green { color: var(--green); border-color: #bdebd0; }
.secondary-btn {
    border: 1px solid #d9d0ff;
    border-radius: 8px;
    background: white;
    color: var(--violet);
    min-height: 44px;
    padding: 0 20px;
    cursor: pointer;
    font-weight: 700;
}

.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.message { padding: 12px 14px; border-radius: 8px; background: #eef8f2; color: #08743a; }
.message.error { background: #fff0f2; color: #c31431; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; }
.stat-card {
    min-height: 118px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 24px;
    color: var(--text);
}
.stat-card:hover, .stat-card.active-stat { border-color: #cfc3ff; box-shadow: 0 10px 32px rgba(91, 53, 242, .08); }
.stat-card strong { display: block; font-size: 26px; line-height: 1; }
.stat-card b { display: block; margin-top: 8px; font-size: 15px; }
.stat-card small { display: block; margin-top: 10px; color: var(--muted); }
.stat-icon { font-size: 36px; width: 42px; text-align: center; }
.accent-orange strong, .accent-orange .stat-icon { color: var(--orange); }
.accent-red strong, .accent-red .stat-icon { color: var(--red); }
.accent-blue strong, .accent-blue .stat-icon { color: var(--blue); }
.accent-green strong, .accent-green .stat-icon { color: var(--green); }

.table-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px 20px;
    overflow: hidden;
}
.compact-card { margin-top: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.section-head h2 { margin-bottom: 0; }
.date-switcher { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.switch-btn {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--text);
    padding: 8px 14px;
    font-weight: 800;
}
.date-switcher input { min-height: 38px; width: 150px; }
.plan-table { border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.table-row {
    display: grid;
    grid-template-columns: 110px 210px 170px 160px minmax(180px, 1fr) 150px 130px 300px;
    min-width: 1410px;
    align-items: center;
    min-height: 70px;
    border-bottom: 1px solid var(--line);
    padding: 0 24px;
    gap: 20px;
}
.table-row:last-child { border-bottom: 0; }
.table-head { min-height: 52px; color: var(--muted); font-size: 14px; }
.time-cell { display: flex; align-items: center; gap: 18px; font-weight: 700; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.red { background: var(--red); }
.dot.blue { background: var(--blue); }
.dot.orange { background: var(--orange); }
.dot.violet { background: var(--violet); }
.contact-cell { display: flex; align-items: center; gap: 16px; }
.contact-cell small { color: var(--muted); display: block; margin-top: 6px; }
.action-icon { width: 28px; color: #5f6987; font-size: 24px; text-align: center; }
.badge { display: inline-flex; align-items: center; min-height: 34px; border-radius: 6px; padding: 0 14px; font-weight: 800; font-size: 13px; }
.badge.danger, .badge.urgent { background: #ffecef; color: var(--red); }
.badge.meeting { background: #eaf3ff; color: var(--blue); }
.badge.today { background: #fff4e5; color: #c76a00; }
.badge.priority-urgent { background: #ffecef; color: var(--red); }
.badge.priority-normal { background: #eef8f2; color: var(--green); }
.row-actions { display: flex; gap: 12px; }
.empty-state { padding: 34px; color: var(--muted); }

.modal {
    width: min(620px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 26px;
    box-shadow: 0 24px 80px rgba(16, 20, 38, .18);
}
.modal.wide { width: min(820px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(16, 20, 38, .28); }
.modal-close {
    float: right;
    border: 0;
    background: #f4f5fa;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 22px;
}
.details-grid { display: grid; grid-template-columns: 170px 1fr; gap: 12px 18px; }
.details-grid span { color: var(--muted); }
.history-list { padding-left: 18px; color: #30354d; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }
.completed-list { display: grid; gap: 10px; }
.completed-item {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 16px;
}
.completed-item span { display: block; color: var(--muted); margin-top: 5px; }
.completed-item time { color: var(--green); font-weight: 800; }
.filters-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 200px 200px 190px auto;
    align-items: end;
    gap: 14px;
    margin-bottom: 18px;
}
.checkbox-label {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 9px;
}
.checkbox-label input { width: 18px; min-height: 18px; }
.contacts-table { border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.contacts-row {
    display: grid;
    grid-template-columns: 230px 210px 170px 180px 160px minmax(220px, 1fr);
    min-width: 1180px;
    align-items: center;
    gap: 18px;
    min-height: 66px;
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
}
.contacts-row:last-child { border-bottom: 0; }
.contacts-head { min-height: 50px; color: var(--muted); font-size: 14px; }
.contacts-row small { display: block; color: var(--muted); margin-top: 5px; }
.danger-text { color: var(--red); font-weight: 800; }
.muted-text { color: var(--muted); line-height: 1.5; margin: 0; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-stack { display: grid; gap: 16px; }
.full { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: #30354d; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    min-height: 42px;
    padding: 9px 12px;
    color: var(--text);
}
textarea { min-height: 88px; resize: vertical; }
.form-divider { color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; font-weight: 800; }
.form-alert {
    border: 1px solid #ffc5cf;
    background: #fff1f3;
    color: #b3132b;
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 700;
}
.form-alert.near-submit { margin-top: 2px; }
.form-alert .errorlist { margin: 0; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-panel {
    width: min(440px, 100%);
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 30px;
}
.auth-panel .brand { margin-bottom: 28px; }
.auth-panel h1 { margin-bottom: 22px; }
.muted-link { color: var(--muted); margin: 18px 0 0; }
.errorlist { color: var(--red); margin: 4px 0 0; padding-left: 18px; }

@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 92px minmax(0, 1fr); }
    .sidebar { padding: 24px 12px; align-items: center; }
    .brand strong, .nav-item:not(.active), .nav-item.active { font-size: 0; }
    .nav-item { justify-content: center; padding: 0; width: 62px; }
    .nav-icon { font-size: 24px; }
    .user-block { grid-template-columns: 44px; }
    .user-block div:not(.avatar), .user-block form { display: none; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .app-shell { display: block; }
    .sidebar { min-height: auto; flex-direction: row; justify-content: space-between; border-right: 0; border-bottom: 1px solid var(--line); }
    .content { padding: 22px 14px; }
    .page-head { align-items: flex-start; flex-direction: column; }
    .header-actions { justify-content: flex-start; width: 100%; }
    .stats-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .filters-row { grid-template-columns: 1fr; }
}
