@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

/* -------------------- Master -------------------- */
:root {
    --surface: #f6f3ec;
    --surface-soft: #fffbf5;
    --panel: rgba(255, 252, 245, 0.88);
    --ink: #1f2328;
    --muted: #595f67;
    --line: rgba(66, 44, 6, 0.16);
    --shadow: 0 20px 48px rgba(37, 32, 20, 0.13);

    --primary: #bb7f19;
    --primary-strong: #8f5a04;
    --accent: #1f6b63;
    --danger: #b62e2e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    min-height: 100%;
}

body {
    position: relative;
    font-family: 'IBM Plex Sans', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% -10%, rgba(187, 127, 25, 0.34), transparent 28%),
        radial-gradient(circle at 92% 0%, rgba(31, 107, 99, 0.22), transparent 24%),
        linear-gradient(145deg, #f8f6f1 0%, #f0ece1 48%, #e6dfcf 100%);
    background-attachment: fixed;
    overflow-x: hidden;
    animation: pageFade 0.45s ease-out;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: linear-gradient(transparent 95%, rgba(120, 90, 40, 0.06) 100%);
    background-size: 100% 34px;
    pointer-events: none;
    z-index: -1;
}

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

input,
textarea {
    width: 100%;
    border: 1px solid rgba(56, 58, 61, 0.18);
    border-radius: 0.8rem;
    padding: 0.7rem 0.85rem;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.98rem;
    font-weight: 500;
    color: var(--ink);
    background: #fff;
    box-shadow: 0 8px 18px rgba(35, 35, 35, 0.08);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(31, 107, 99, 0.16);
    transform: translateY(-1px);
}

button {
    width: 100%;
    border: 0;
    border-radius: 0.85rem;
    padding: 0.72rem 1rem;
    font-family: 'Sora', sans-serif;
    font-size: 0.94rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    background: linear-gradient(120deg, var(--primary), var(--primary-strong));
    box-shadow: 0 12px 24px rgba(143, 90, 4, 0.28);
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease, filter 0.22s ease;
}

button:hover {
    transform: translateY(-2px);
    filter: saturate(1.06);
    box-shadow: 0 16px 28px rgba(143, 90, 4, 0.34);
}

button:active {
    transform: translateY(0);
}

h1,
h2,
.navigation .brand span {
    font-family: 'Sora', sans-serif;
}

h1 {
    font-size: clamp(1.7rem, 4vw, 2.3rem);
    line-height: 1.1;
    color: var(--primary-strong);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* -------------------- Tools -------------------- */
.padding {
    padding: 0 clamp(1rem, 4vw, 3.5rem);
}

.container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    min-height: calc(100dvh - 140px);
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* -------------------- Navigation -------------------- */
.navigation {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    min-height: 88px;
    backdrop-filter: blur(10px);
    background: rgba(249, 245, 236, 0.82);
    border-bottom: 1px solid var(--line);
}

.navigation .links {
    margin-left: auto;
}

.navigation .brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.navigation .brand img {
    width: 3.2rem;
    filter: drop-shadow(0 8px 10px rgba(121, 74, 1, 0.18));
}

.navigation .brand .text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.navigation .brand span {
    font-size: 1.55rem;
    line-height: 1;
    letter-spacing: 0.01em;
    color: var(--primary-strong);
    font-weight: 800;
    text-transform: uppercase;
}

.navigation .brand small {
    font-size: 0.76rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.22em;
    font-weight: 700;
}

.navigation .links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 96px;
    border-radius: 999px;
    padding: 0.55rem 0.95rem;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.55);
    font-weight: 600;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.navigation .links a:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
}

/* -------------------- Login -------------------- */
.login {
    width: min(520px, 100%);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 2.2rem;
    border-radius: 1.2rem;
    background: var(--panel);
    border: 1px solid rgba(143, 90, 4, 0.2);
    box-shadow: var(--shadow);
    animation: riseIn 0.5s ease-out;
}

.login h1 {
    text-align: center;
}

/* -------------------- Dashboard -------------------- */
.dashboard {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    animation: riseIn 0.5s ease-out;
}

.dashboard,
.panel,
.saved-panel {
    min-width: 0;
}

.dashboard .title {
    text-align: center;
    width: 100%;
    margin-bottom: 0.1rem;
}

.dashboard .title p {
    color: var(--muted);
    margin-top: 0.35rem;
    font-size: 1.02rem;
}

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

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

.panel-steps {
    grid-column: 1 / -1;
}

.panel h2 {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 0.85rem;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.field-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    color: #3f454c;
    font-size: 0.89rem;
    font-weight: 600;
}

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

.inline-fields {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 0.55rem;
    margin-bottom: 0.85rem;
}

.step-fields {
    grid-template-columns: minmax(0, 1fr) auto;
}

.step-fields #step_name {
    grid-column: 1;
}

.step-fields #step_add_btn {
    grid-column: 2;
}

.step-fields #step_details {
    grid-column: 1 / -1;
    min-height: 84px;
}

.step-fields #step_cancel_edit_btn {
    grid-column: 1;
}

.step-fields .step-template-btn {
    grid-column: 2;
}

.inline-fields button.secondary {
    grid-column: 1 / -1;
}

#material_cancel_edit_btn,
#step_cancel_edit_btn {
    grid-column: auto;
}

.planner-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 0.9rem;
    overflow: hidden;
}

.planner-table th,
.planner-table td {
    border: 1px solid rgba(143, 90, 4, 0.18);
    padding: 0.58rem;
}

.planner-table th {
    background: #fef6e4;
    color: #7b4b00;
    font-size: 0.79rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: center;
}

.planner-table td {
    background: var(--surface-soft);
    font-size: 0.93rem;
    overflow-wrap: anywhere;
}

.summary-row {
    margin-top: 0.75rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    align-items: center;
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-left: 0;
    list-style-position: inside;
}

.steps-list li {
    background: #fffaf0;
    border: 1px solid rgba(143, 90, 4, 0.22);
    border-radius: 0.75rem;
    padding: 0.55rem 0.6rem;
}

.step-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.6rem;
}

.step-copy {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.step-copy strong {
    font-size: 0.95rem;
}

.step-details {
    font-size: 0.84rem;
    color: var(--muted);
    line-height: 1.35;
}

.step-details-empty {
    font-style: italic;
}

.step-item.is-completed {
    background: #f1f7f2;
    border-color: rgba(31, 107, 99, 0.34);
}

.step-item.is-completed .step-copy strong,
.step-item.is-completed .step-details {
    color: #4f565e;
    text-decoration: line-through;
}

.step-item button,
.plan-actions button,
.materials-actions button {
    width: auto;
    padding: 0.42rem 0.72rem;
    font-size: 0.82rem;
    box-shadow: none;
}

.plan-actions,
.materials-actions {
    display: flex;
    gap: 0.45rem;
}

.material-row-actions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.panel-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.85rem;
}

.saved-panel {
    margin-bottom: 1.3rem;
}

.saved-panel .planner-table {
    table-layout: fixed;
}

button.secondary {
    background: linear-gradient(120deg, #4c5058, #32363d);
    box-shadow: 0 10px 22px rgba(39, 42, 49, 0.24);
}

button.secondary:hover {
    box-shadow: 0 14px 24px rgba(39, 42, 49, 0.3);
}

button.danger {
    background: linear-gradient(120deg, #c74444, var(--danger));
    box-shadow: 0 10px 20px rgba(182, 46, 46, 0.26);
}

button.danger:hover {
    box-shadow: 0 14px 24px rgba(182, 46, 46, 0.34);
}

button.success {
    background: linear-gradient(120deg, #2f8c63, #1f6b63);
    box-shadow: 0 10px 20px rgba(31, 107, 99, 0.28);
}

button.success:hover {
    box-shadow: 0 14px 24px rgba(31, 107, 99, 0.34);
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 0.8rem;
}

/* -------------------- Footer -------------------- */
.footer {
    min-height: 82px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.18rem;
    color: #454a51;
    background: rgba(250, 247, 240, 0.84);
    border-top: 1px solid var(--line);
}

.footer span {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
}

.footer small {
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.72rem;
}

/* -------------------- Responsive -------------------- */
@media (max-width: 1100px) {
    .container {
        min-height: calc(100dvh - 136px);
        padding-top: 1.1rem;
    }

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

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

    .panel-actions {
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .navigation {
        min-height: 76px;
        justify-content: center;
        text-align: center;
    }

    .navigation .brand span {
        font-size: 1.2rem;
    }

    .navigation .brand img {
        width: 2.7rem;
    }

    .navigation .brand {
        width: 100%;
        justify-content: center;
    }

    .navigation .links {
        width: 100%;
        margin-left: 0;
    }

    .navigation .links a {
        width: 100%;
    }

    .login {
        padding: 1.2rem;
        border-radius: 0.9rem;
    }

    .dashboard .title p {
        font-size: 0.94rem;
    }

    .panel {
        padding: 0.9rem;
    }

    .summary-row {
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .step-item {
        flex-direction: column;
    }

    .materials-actions,
    .plan-actions,
    .material-row-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .step-item button,
    .plan-actions button,
    .materials-actions button {
        flex: 1 1 auto;
    }
}

@media (max-width: 700px) {
    .planner-table {
        border: 0;
    }

    .planner-table thead {
        display: none;
    }

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

    .planner-table tr {
        margin-bottom: 0.7rem;
        border: 1px solid rgba(143, 90, 4, 0.2);
        border-radius: 0.75rem;
        overflow: hidden;
    }

    .planner-table td {
        border: 0;
        border-bottom: 1px solid rgba(143, 90, 4, 0.14);
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.8rem;
        text-align: right;
        padding: 0.58rem 0.7rem;
    }

    .planner-table td:last-child {
        border-bottom: 0;
    }

    .planner-table td::before {
        content: attr(data-label);
        font-size: 0.74rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #7b4b00;
        text-align: left;
        flex: 0 0 42%;
    }

    .planner-table td[colspan] {
        justify-content: center;
        text-align: center;
    }

    .planner-table td[colspan]::before {
        content: '';
        display: none;
    }

    .plan-actions,
    .material-row-actions,
    .materials-actions {
        justify-content: flex-end;
    }

    .plan-actions button,
    .material-row-actions button,
    .materials-actions button {
        width: auto;
    }
}

/* -------------------- Motion -------------------- */
@keyframes pageFade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}