:root {
    --bg: #f7f3ec;
    --surface: #fffaf2;
    --surface-strong: #ffffff;
    --text: #241a14;
    --muted: #746a61;
    --line: #e5d8c8;
    --coffee: #6f3f2a;
    --coffee-dark: #3f2418;
    --accent: #1f6f68;
    --accent-dark: #174f4a;
    --danger: #a4342f;
    --danger-bg: #fff0ee;
    --shadow: 0 18px 50px rgba(62, 36, 24, 0.12);
    --shadow-soft: 0 10px 30px rgba(62, 36, 24, 0.08);
}

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

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background:
        linear-gradient(135deg, rgba(111, 63, 42, 0.08), transparent 34%),
        linear-gradient(225deg, rgba(31, 111, 104, 0.09), transparent 38%),
        var(--bg);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(36, 26, 20, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(36, 26, 20, 0.03) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 70%);
}

.container {
    width: min(100% - 32px, 980px);
    margin: 0 auto;
    padding: 34px 0 48px;
}

header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 26px;
    padding: 0 2px 22px;
    border-bottom: 1px solid rgba(111, 63, 42, 0.16);
}

header h1 {
    max-width: 680px;
    color: var(--coffee-dark);
    font-size: clamp(2rem, 5vw, 3.25rem);
    line-height: 1.04;
    letter-spacing: 0;
}

.auth-page header {
    justify-content: center;
    text-align: center;
}

.auth-page header h1 {
    max-width: none;
}

header p {
    margin-top: 8px;
    color: var(--muted);
    font-size: 1rem;
}

main {
    display: grid;
    gap: 48px;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    color: var(--muted);
    font-size: 0.95rem;
    white-space: nowrap;
}

.hero,
.auth-form,
.scripts,
.result,
.dashboard-empty {
    position: relative;
    overflow: hidden;
    background: color-mix(in srgb, var(--surface) 88%, white);
    border: 1px solid rgba(111, 63, 42, 0.14);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.dashboard-shell {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 24px;
}

.sidebar-menu {
    position: sticky;
    top: 18px;
    display: grid;
    gap: 8px;
    padding: 12px;
    background: color-mix(in srgb, var(--surface) 92%, white);
    border: 1px solid rgba(111, 63, 42, 0.14);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.sidebar-link {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    color: var(--coffee-dark);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 750;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.sidebar-link:hover,
.sidebar-link.active {
    color: #fff;
    background: var(--coffee);
    border-color: var(--coffee);
}

.dashboard-content {
    min-width: 0;
}

.dashboard-empty {
    padding: clamp(24px, 4vw, 36px);
}

.dashboard-empty h2 {
    color: var(--coffee-dark);
    font-size: clamp(1.45rem, 3vw, 2.05rem);
    line-height: 1.15;
}

.dashboard-empty p {
    margin-top: 10px;
    color: var(--muted);
}

.dashboard-panel .alert,
.dashboard-panel .result,
.dashboard-panel .timer-section {
    margin-top: 22px;
}

.hamburger-nav {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1000;
}

.hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 48px;
    height: 48px;
    background: var(--coffee);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.hamburger-btn span:not(:last-child) {
    margin-bottom: 5px;
}

.hamburger-btn.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.hamburger-menu {
    position: absolute;
    top: 56px;
    left: 0;
    min-width: 200px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.hamburger-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.hamburger-menu a,
.hamburger-link,
.hamburger-link-admin {
    display: block;
    width: 100%;
    padding: 12px 16px;
    color: var(--text);
    background: transparent;
    border: 0;
    text-decoration: none;
    font-weight: 600;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.hamburger-menu a:first-child,
.hamburger-link:first-child {
    border-radius: 8px 8px 0 0;
}

.hamburger-menu a:last-child,
.hamburger-link:last-child {
    border-radius: 0 0 8px 8px;
}

.hamburger-menu a:hover,
.hamburger-link:hover,
.hamburger-link-admin:hover,
.hamburger-link.active {
    background: rgba(111, 63, 42, 0.08);
}

.hamburger-menu a:not(:last-child),
.hamburger-link:not(:last-child),
.hamburger-link-admin:not(:last-child) {
    border-bottom: 1px solid var(--line);
}

.hero {
    min-height: 360px;
    display: grid;
    align-content: center;
    gap: 18px;
    padding: clamp(34px, 7vw, 72px);
}

.hero::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    width: min(42vw, 360px);
    height: 100%;
    background:
        linear-gradient(135deg, transparent 10%, rgba(255, 250, 242, 0.58)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 420'%3E%3Cg fill='none' stroke='%236f3f2a' stroke-width='8' stroke-linecap='round' stroke-linejoin='round' opacity='.34'%3E%3Cpath d='M92 164h128l-21 142a44 44 0 0 1-44 38h-8a44 44 0 0 1-44-38L92 164Z'/%3E%3Cpath d='M220 196h32c28 0 38 42 10 64-15 12-37 13-50 7'/%3E%3Cpath d='M126 118c-12-18 18-28 6-48M166 116c-12-18 18-28 6-48M206 118c-12-18 18-28 6-48'/%3E%3Cpath d='M68 350h188'/%3E%3C/g%3E%3C/svg%3E") bottom right / contain no-repeat;
    opacity: 0.9;
}

.hero h2,
.scripts h2,
.result h2 {
    position: relative;
    z-index: 1;
    color: var(--coffee-dark);
    font-size: clamp(1.45rem, 3vw, 2.05rem);
    line-height: 1.15;
}

.hero p {
    position: relative;
    z-index: 1;
    max-width: 560px;
    color: var(--muted);
    font-size: 1.08rem;
}

.btn-primary,
.btn-secondary,
.btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.btn-primary {
    position: relative;
    z-index: 1;
    color: #fff;
    background: var(--accent);
    box-shadow: 0 12px 26px rgba(31, 111, 104, 0.24);
}

.btn-primary:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    position: relative;
    z-index: 1;
    margin-left: 10px;
    color: var(--coffee-dark);
    background: rgba(255, 255, 255, 0.72);
    border-color: rgba(111, 63, 42, 0.2);
}

.btn-secondary:hover {
    background: #fff;
    transform: translateY(-1px);
}

.btn-logout {
    min-height: 36px;
    padding: 7px 12px;
    color: #fff;
    background: var(--coffee);
    font-size: 0.88rem;
    box-shadow: none;
}

.btn-logout:hover {
    background: var(--coffee-dark);
}

.auth-form,
.scripts,
.result {
    padding: clamp(24px, 4vw, 36px);
}

.auth-form {
    width: min(100%, 460px);
    margin: 0 auto;
}

.auth-main {
    min-height: calc(100vh - 180px);
    display: grid;
    place-items: center;
    align-content: center;
    gap: 20px;
}

.form-group,
.script-form .form-group {
    margin-bottom: 20px;
}

.form-group label,
.script-form label {
    display: block;
    margin-bottom: 8px;
    color: var(--coffee-dark);
    font-weight: 750;
}

.form-group input,
.script-form select,
.script-form input[type="number"] {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: var(--surface-strong);
    font: inherit;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.form-group input:focus,
.script-form select:focus,
.script-form input[type="number"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(31, 111, 104, 0.12);
    background: #fff;
}

.form-group small {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 0.88rem;
}

.script-form {
    margin-top: 18px;
}

.alert {
    padding: 14px 16px;
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.alert-error {
    color: var(--danger);
    background: var(--danger-bg);
    border: 1px solid rgba(164, 52, 47, 0.22);
}

.alert-success {
    color: var(--accent-dark);
    background: #eaf5f4;
    border: 1px solid rgba(31, 111, 104, 0.22);
}

.alert ul {
    margin: 0;
    padding-left: 20px;
}

.result h2 {
    margin-bottom: 16px;
}

.result pre {
    max-height: 58vh;
    padding: 18px;
    overflow: auto;
    color: #1f1813;
    background:
        linear-gradient(90deg, rgba(31, 111, 104, 0.13), transparent 5px),
        #fffdf8;
    border: 1px solid rgba(111, 63, 42, 0.13);
    border-radius: 8px;
    font-family: "Cascadia Mono", "Consolas", monospace;
    font-size: 0.94rem;
    line-height: 1.65;
    white-space: pre-wrap;
}

.auth-link {
    margin-top: 18px;
    text-align: center;
    color: var(--muted);
}

.auth-link a {
    color: var(--accent);
    font-weight: 750;
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

footer {
    margin-top: 38px;
    padding-top: 18px;
    color: var(--muted);
    border-top: 1px solid rgba(111, 63, 42, 0.14);
    text-align: center;
    font-size: 0.92rem;
}

.timer-section {
    position: relative;
    overflow: hidden;
    background: color-mix(in srgb, var(--surface) 88%, white);
    border: 1px solid rgba(111, 63, 42, 0.14);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: clamp(24px, 4vw, 36px);
}

.timer-section h2 {
    position: relative;
    z-index: 1;
    color: var(--coffee-dark);
    font-size: clamp(1.45rem, 3vw, 2.05rem);
    line-height: 1.15;
    margin-bottom: 20px;
}

.timer-container {
    text-align: center;
    margin-bottom: 24px;
}

.timer-display {
    font-size: clamp(3rem, 10vw, 5rem);
    font-weight: 700;
    color: var(--coffee-dark);
    font-variant-numeric: tabular-nums;
    letter-spacing: -2px;
}

.timer-progress {
    height: 8px;
    background: rgba(111, 63, 42, 0.12);
    border-radius: 4px;
    overflow: hidden;
    margin: 20px 0;
}

.timer-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-dark));
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.timer-current-step {
    padding: 16px;
    background: linear-gradient(135deg, rgba(31, 111, 104, 0.12), rgba(255, 250, 242, 0.92));
    border: 1px solid rgba(31, 111, 104, 0.16);
    border-radius: 8px;
    margin-bottom: 16px;
    color: var(--text);
    line-height: 1.5;
}

.timer-current-step strong {
    color: var(--accent-dark);
}

.timer-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.timer-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border: 1px solid rgba(31, 111, 104, 0.22);
    border-radius: 50%;
    color: var(--coffee-dark);
    background: var(--surface-strong);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.timer-icon-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(31, 111, 104, 0.18);
}

.timer-icon-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    box-shadow: none;
}

.timer-start {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

.timer-pause,
.timer-reset {
    background: #fffdf8;
}

.timer-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.timer-steps {
    display: grid;
    gap: 10px;
}

.timer-step {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 14px 16px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.timer-step.active {
    background: linear-gradient(135deg, rgba(31, 111, 104, 0.18), rgba(255, 250, 242, 0.96));
    border-color: var(--accent);
    transform: scale(1.01);
    box-shadow: 0 14px 28px rgba(31, 111, 104, 0.16);
}

.timer-step.active::before {
    content: "";
    position: absolute;
    inset: 10px auto 10px 0;
    width: 5px;
    background: var(--accent);
    border-radius: 0 999px 999px 0;
}

.timer-step.active .step-time,
.timer-step.active .step-info strong {
    color: var(--accent-dark);
}

.timer-step.completed {
    background: rgba(31, 111, 104, 0.05);
    opacity: 0.7;
}

.step-time {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--coffee);
    min-width: 50px;
    font-variant-numeric: tabular-nums;
}

.step-info {
    flex: 1;
}

.step-info strong {
    color: var(--coffee-dark);
    display: block;
}

.step-info span {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
}

.step-info p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.9rem;
}

.step-live-timer {
    display: none;
    margin-top: 10px;
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--accent-dark);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.timer-step.active .step-live-timer {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 10px;
    color: #fff;
    background: var(--accent);
    border-radius: 8px;
    box-shadow: 0 10px 22px rgba(31, 111, 104, 0.22);
}

@media (max-width: 900px) {
    .container {
        padding-top: 86px;
    }

    .hamburger-nav {
        top: 18px;
        left: 18px;
    }

    header {
        display: grid;
        align-items: start;
        gap: 14px;
    }

    header h1 {
        font-size: clamp(1.85rem, 8vw, 2.7rem);
    }

    .user-info {
        justify-content: flex-start;
        flex-wrap: wrap;
        white-space: normal;
    }

    .is-sticky-ready .timer-container {
        position: sticky;
        top: 10px;
        z-index: 20;
        margin: -6px -6px 18px;
        padding: 14px;
        background: color-mix(in srgb, var(--surface) 94%, white);
        border: 1px solid rgba(111, 63, 42, 0.14);
        border-radius: 8px;
        box-shadow: 0 16px 34px rgba(62, 36, 24, 0.14);
    }

    .timer-section.is-sticky-ready .timer-container {
        backdrop-filter: blur(10px);
    }

    .timer-display {
        font-size: clamp(2.6rem, 14vw, 4.2rem);
        letter-spacing: 0;
    }

    .timer-progress {
        margin: 12px 0;
    }

    .timer-current-step {
        padding: 12px;
        margin-bottom: 12px;
        font-size: 0.95rem;
    }

    .timer-controls {
        gap: 12px;
    }

    .timer-icon-btn {
        width: 52px;
        height: 52px;
    }

    .timer-step {
        display: grid;
        grid-template-columns: 58px minmax(0, 1fr);
        gap: 12px;
        padding: 16px 14px;
    }

    .timer-step.active {
        transform: none;
    }

    .timer-step.active .step-live-timer {
        display: flex;
        width: fit-content;
    }
}

@media (max-width: 720px) {
    .container {
        width: min(100% - 22px, 980px);
    }

    header {
        display: grid;
        align-items: start;
    }

    .dashboard-shell {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .hero {
        min-height: 330px;
        padding: 30px 22px;
    }

    .hero::after {
        width: 74vw;
        opacity: 0.32;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        margin: 8px 0 0;
    }

    .auth-form,
    .scripts,
    .result,
    .timer-section {
        padding: 18px;
    }

    .timer-section h2 {
        font-size: 1.45rem;
    }

    .step-time {
        min-width: 0;
        font-size: 1rem;
    }
}
