:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --card-2: #f8fbff;
    --text: #172033;
    --muted: #667085;
    --line: #d7e0ee;
    --brand: #1f6feb;
    --brand-hover: #175fd0;
    --danger: #b42318;
    --danger-hover: #911d13;
    --shadow: 0 14px 40px rgba(15, 32, 64, 0.08);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 5% 0%, #eaf2ff 0, transparent 35%),
        radial-gradient(circle at 95% 100%, #e7f4ff 0, transparent 30%), var(--bg);
}

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

a:hover {
    text-decoration: underline;
}

.top-nav {
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-spacer {
    visibility: hidden;
    pointer-events: none;
}

.top-nav-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.9rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.nav-right form {
    margin: 0;
}

.brand {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.2px;
    color: var(--text);
}

.nav-link {
    font-weight: 600;
}

.is-hidden {
    display: none !important;
}

.page {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.content-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.page-title {
    margin: 0 0 1.1rem;
    font-size: clamp(1.45rem, 2vw, 1.9rem);
}

.toolbar {
    margin: 0 0 1rem;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.toolbar:empty {
    display: none;
}

.toolbar form {
    margin: 0;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-form input[type="text"] {
    width: min(320px, 70vw);
}

.bottom-toolbar {
    margin: 1.5rem 0 0;
}

.details-card {
    background: var(--card-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1rem;
}

.plan-list {
    display: grid;
    gap: 0.75rem;
}

.plan-card {
    display: block;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    background: var(--card-2);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.plan-card-link-wrapper {
    position: relative;
    cursor: pointer;
}

.plan-card-stretched-link {
    position: absolute;
    inset: 0;
    z-index: 2;
    border-radius: 12px;
}

.plan-card-inner-link {
    position: relative;
    z-index: 3;
}

.plan-card h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.05rem;
    line-height: 1.4;
}

.plan-title-link {
    color: inherit;
    text-decoration: none;
}

.plan-title-link:hover {
    text-decoration: none;
}

.plan-card:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(31, 111, 235, 0.12);
}

.plan-name {
    margin: 0 0 0.9rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table thead th {
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid var(--line);
}

.items-table tbody td {
    padding: 0.6rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.items-table tbody tr:last-child td {
    border-bottom: none;
}

.plan-form label {
    display: inline-block;
    margin-bottom: 0.4rem;
    font-weight: 600;
}

input[type="text"] {
    width: 100%;
    border: 1px solid #c7d3e4;
    border-radius: 10px;
    padding: 0.55rem 0.65rem;
    font: inherit;
    color: var(--text);
    background: #fff;
}

input[type="password"] {
    width: 100%;
    border: 1px solid #c7d3e4;
    border-radius: 10px;
    padding: 0.55rem 0.65rem;
    font: inherit;
    color: var(--text);
    background: #fff;
}

textarea {
    width: 100%;
    border: 1px solid #c7d3e4;
    border-radius: 10px;
    padding: 0.55rem 0.65rem;
    font: inherit;
    color: var(--text);
    background: #fff;
    resize: vertical;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}

.page.auth-page {
    margin-top: 3rem;
}

.auth-card {
    max-width: 420px;
    margin: 0 auto;
}

.form-table {
    margin-top: 0.85rem;
}

.actions-col {
    width: 1%;
    white-space: nowrap;
}

.row-actions {
    display: flex;
    gap: 0.45rem;
    justify-content: flex-end;
}

.btn.drag-handle {
    cursor: grab;
}

.btn.drag-handle:active {
    cursor: grabbing;
}

.done-col {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.form-actions {
    margin-top: 0.95rem;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.execution-note-form {
    margin: 0.9rem 0;
}

.execution-note-form label {
    display: inline-block;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.execution-note-form .btn {
    margin-top: 0.5rem;
}

.btn,
input[type="submit"].btn {
    appearance: none;
    border: 1px solid #c8d5e6;
    background: #fff;
    color: var(--text);
    border-radius: 10px;
    padding: 0.5rem 0.85rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.2;
}

.btn:hover,
input[type="submit"].btn:hover {
    background: #f4f8ff;
    text-decoration: none;
}

.btn-primary,
input[type="submit"].btn-primary {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
}

.btn-primary:hover,
input[type="submit"].btn-primary:hover {
    background: var(--brand-hover);
}

.btn.is-active {
    border-color: var(--brand);
    background: #eaf2ff;
    color: #124da8;
}

.btn-danger {
    border-color: #f1c3bf;
    background: #fff5f4;
    color: var(--danger);
}

.btn-danger:hover {
    background: #ffe9e7;
    color: var(--danger-hover);
}

.btn.is-disabled,
.btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.muted {
    color: var(--muted);
}

.finished-at {
    display: block;
    height: 1.35rem;
    line-height: 1.35rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template {
    display: none;
}

#items tr.is-dragging {
    opacity: 0.55;
}

#items tr.drag-over-top {
    border-top: 2px solid var(--brand);
}

#items tr.drag-over-bottom {
    border-bottom: 2px solid var(--brand);
}

.autocomplete-cell {
    position: relative;
}

.action-search-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    margin: 0;
    padding: 0.25rem 0;
    list-style: none;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 32, 64, 0.12);
    max-height: 220px;
    overflow-y: auto;
}

.action-search-menu.is-open {
    display: block;
}

.action-search-option {
    padding: 0.45rem 0.65rem;
    cursor: pointer;
}

.action-search-option:hover,
.action-search-option.is-selected {
    background: #eaf2ff;
}

@media (max-width: 700px) {
    .page {
        margin: 1.2rem auto;
    }

    .page.auth-page {
        margin-top: 2.2rem;
    }

    .content-card {
        padding: 1rem;
    }

    .items-table,
    .items-table tbody,
    .items-table tr,
    .items-table td {
        display: block;
        width: 100%;
    }

    .items-table thead {
        display: none;
    }

    .items-table tbody td {
        border: none;
        padding: 0.4rem 0;
    }

    .items-table tbody tr {
        border-bottom: 1px solid var(--line);
        padding: 0.4rem 0;
    }
}
