:root {
    --bg: #f5f7f8;
    --surface: #ffffff;
    --surface-soft: #eef4f3;
    --text: #162023;
    --muted: #657174;
    --line: #d8e0e1;
    --line-strong: #aebabb;
    --accent: #167f7a;
    --accent-dark: #0c5f5b;
    --danger: #ba3f45;
    --warning: #b56a1e;
    --shadow: 0 16px 40px rgba(22, 32, 35, 0.08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
}

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

button {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    border-radius: 6px;
    min-height: 38px;
    padding: 0 14px;
    cursor: pointer;
}

button:hover,
.file-button:hover {
    border-color: var(--accent);
}

button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

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

button.danger {
    color: var(--danger);
}

button:disabled,
.file-button.is-disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

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

.app-shell.sidebar-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
    background: #182527;
    color: white;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
    transition: padding 180ms ease;
}

.app-shell.sidebar-collapsed .sidebar {
    padding-left: 0;
    padding-right: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: #c9e8dd;
    color: #123332;
    font-weight: 800;
    font-size: 1.2rem;
}

.brand h1,
.brand p,
.panel h2,
.view-title h2,
.view-title p {
    margin: 0;
}

.brand h1 {
    font-size: 1.25rem;
}

.brand p {
    color: #bdd0d2;
    font-size: 0.88rem;
}

.panel {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 14px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.panel h2 {
    font-size: 0.86rem;
    color: #d8e7e8;
    text-transform: uppercase;
    letter-spacing: 0;
}

.field-label {
    display: block;
    margin-bottom: 6px;
    color: #d3e0e1;
    font-size: 0.85rem;
}

.sidebar input,
.sidebar select {
    width: 100%;
    height: 40px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.12);
    color: white;
    padding: 0 10px;
}

.week-actions {
    display: grid;
    grid-template-columns: 34px 34px 1fr;
    gap: 8px;
    margin-top: 10px;
}

.week-actions button:not(.icon-button) {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border-color: rgba(255, 255, 255, 0.18);
    padding: 0 10px;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
}

.panel .icon-button {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border-color: rgba(255, 255, 255, 0.18);
}

.interpreter-list,
.coverage-list {
    display: grid;
    gap: 8px;
}

.interpreter-row,
.coverage-row {
    display: grid;
    grid-template-columns: 14px 1fr auto;
    align-items: center;
    gap: 9px;
    color: #f4fbfb;
    font-size: 0.93rem;
}

.swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.45);
}

.interpreter-row button {
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    color: white;
    background: transparent;
}

.coverage-row strong {
    color: white;
    font-size: 0.9rem;
}

.panel-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.file-button {
    display: grid;
    place-items: center;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
    color: var(--text);
    cursor: pointer;
}

#importFile {
    display: none;
}

.workspace {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 24px;
    gap: 18px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sidebar-toggle {
    flex: 0 0 auto;
    background: var(--surface);
}

.view-title h2 {
    font-size: 1.7rem;
}

.view-title p {
    color: var(--muted);
    margin-top: 4px;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    min-width: 230px;
    padding: 0 11px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.search-field input {
    width: 100%;
    border: 0;
    outline: 0;
}

.toolbar-actions select {
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
    padding: 0 10px;
}

#lockButton {
    min-width: 92px;
    font-weight: 800;
}

#undoButton {
    min-width: 78px;
}

#lockButton.is-unlocked {
    background: #f8e7e8;
    border-color: #dfaeb2;
    color: var(--danger);
}

.lock-banner {
    border: 1px solid #e3c06f;
    border-radius: 8px;
    background: #fff5d6;
    color: #6c4b00;
    padding: 10px 12px;
    font-weight: 800;
}

.lock-banner.unlocked {
    border-color: #a9d9c4;
    background: #eaf8f1;
    color: #176041;
}

.sync-status {
    margin-top: -8px;
    color: var(--muted);
    font-size: 0.84rem;
    min-height: 18px;
}

.sync-status.error {
    color: var(--danger);
    font-weight: 800;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.stats article {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 8px;
    padding: 14px 16px;
}

.stats strong {
    display: block;
    font-size: 1.55rem;
}

.stats span {
    color: var(--muted);
    font-size: 0.88rem;
}

.schedule-wrap {
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.schedule {
    display: grid;
    grid-template-columns: 66px repeat(5, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    position: relative;
}

.time-header,
.day-header,
.time-cell,
.day-cell {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.time-header,
.day-header {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #fafdff;
    min-height: 44px;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.time-header {
    left: 0;
    z-index: 5;
}

.time-cell {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fafdff;
    min-height: 46px;
    padding: 5px 6px;
    text-align: right;
    color: var(--muted);
    font-size: 0.86rem;
    font-variant-numeric: tabular-nums;
}

.day-cell {
    min-height: 46px;
    position: relative;
    background-image: linear-gradient(to bottom, transparent calc(100% - 1px), rgba(216, 224, 225, 0.55) calc(100% - 1px));
}

.day-cell.drop-target {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: #ebf6f4;
}

.current-time-line {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 6;
    height: 2px;
    background: var(--danger);
    pointer-events: none;
}

.current-time-line::before {
    content: "";
    position: absolute;
    left: -5px;
    top: -4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
}

.current-time-label {
    position: absolute;
    right: 4px;
    top: -18px;
    padding: 1px 5px;
    border-radius: 5px;
    background: var(--danger);
    color: white;
    font-size: 0.68rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.meeting-card {
    position: absolute;
    left: 8px;
    right: 8px;
    z-index: 3;
    border-left: 5px solid var(--accent);
    border-radius: 6px;
    padding: 7px 7px;
    overflow: hidden;
    color: #142023;
    background: #dcefed;
    box-shadow: 0 8px 18px rgba(22, 32, 35, 0.13);
    cursor: grab;
}

.meeting-card:active {
    cursor: grabbing;
}

.meeting-card.cancelled {
    opacity: 0.52;
    text-decoration: line-through;
}

.meeting-card.tentative {
    background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.24) 8px, transparent 8px, transparent 16px);
}

.meeting-card.conflict {
    outline: 2px solid var(--danger);
}

.meeting-card h3 {
    margin: 0 0 5px;
    font-size: 0.8rem;
    line-height: 1.18;
}

.meeting-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 9px;
    color: rgba(20, 32, 35, 0.72);
    font-size: 0.7rem;
    line-height: 1.2;
}

.meeting-meta strong {
    color: rgba(20, 32, 35, 0.86);
}

.context-menu {
    position: fixed;
    z-index: 20;
    width: 230px;
    max-height: min(440px, calc(100vh - 20px));
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: 0 18px 48px rgba(14, 22, 24, 0.22);
    padding: 6px;
}

.context-menu-section {
    padding: 6px 0;
}

.context-menu-section + .context-menu-section {
    border-top: 1px solid var(--line);
}

.context-menu-title {
    padding: 5px 8px 7px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.context-menu button {
    display: grid;
    grid-template-columns: 14px 1fr auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 34px;
    border: 0;
    border-radius: 5px;
    padding: 0 8px;
    text-align: left;
    background: transparent;
}

.context-menu button:hover,
.context-menu button:focus-visible {
    background: var(--surface-soft);
    outline: 0;
}

.context-menu button.is-current {
    font-weight: 800;
}

.context-menu .menu-check {
    color: var(--accent);
    font-weight: 900;
}

.context-menu .menu-empty {
    color: transparent;
}

.context-menu .menu-action {
    grid-template-columns: 1fr auto;
}

.context-menu .danger {
    color: var(--danger);
}

dialog {
    width: min(720px, calc(100vw - 28px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
    background: rgba(14, 22, 24, 0.42);
}

dialog form {
    padding: 20px;
}

.dialog-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.dialog-heading h2 {
    margin: 0;
    font-size: 1.25rem;
}

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

dialog label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
}

dialog input,
dialog select,
dialog textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    background: white;
    padding: 9px 10px;
}

dialog textarea {
    resize: vertical;
}

.full {
    grid-column: 1 / -1;
}

.form-error {
    min-height: 21px;
    margin: 12px 0 0;
    color: var(--danger);
    font-weight: 700;
}

.dialog-actions {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
}

.hidden {
    display: none !important;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .app-shell.sidebar-collapsed .sidebar {
        display: none;
    }

    .sidebar {
        position: static;
    }

    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-actions {
        justify-content: stretch;
    }

    .toolbar-actions > *,
    .search-field {
        flex: 1 1 170px;
    }

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

@media (max-width: 560px) {
    .workspace,
    .sidebar {
        padding: 14px;
    }

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

    .dialog-actions {
        grid-template-columns: 1fr;
    }

    .dialog-actions span {
        display: none;
    }
}
