:root {
    --bg: #f6f4ef;
    --surface: #fffdf8;
    --text: #1a1a1a;
    --muted: #5c5c5c;
    --accent: #2d6a4f;
    --accent-hover: #1b4332;
    --border: #e0dcd4;
    --radius: 8px;
    font-family: "Segoe UI", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

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

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.site-header__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.logo {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--accent);
    text-decoration: none;
}

.logo:hover {
    color: var(--accent-hover);
}

.tabs {
    display: flex;
    gap: 0.35rem;
    flex: 1;
    flex-wrap: wrap;
}

.tabs__link {
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.tabs__link:hover {
    background: var(--bg);
    color: var(--text);
}

.tabs__link--active {
    background: var(--bg);
    color: var(--accent);
    font-weight: 600;
}

.user-menu {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

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

.user-menu__out {
    color: var(--accent);
    text-decoration: none;
}

.user-menu__out:hover {
    text-decoration: underline;
}

.main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

.site-footer {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.25rem 2rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.site-footer p {
    margin: 0;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 1rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.muted {
    color: var(--muted);
    font-size: 0.95rem;
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-box {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
}

.login-box h1 {
    margin-top: 0;
}

.login-box label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 1rem;
}

.login-error {
    color: #b42318;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.btn {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn--secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn--secondary:hover {
    background: var(--bg);
}

.btn--danger {
    background: #9b2226;
}

.btn--danger:hover {
    background: #7f1d1d;
}

.btn--small {
    padding: 0.35rem 0.65rem;
    font-size: 0.875rem;
}

.templates-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.templates-toolbar h1 {
    margin: 0;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.template-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.template-card__title {
    font-weight: 600;
    font-size: 1.05rem;
    margin: 0;
}

.template-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.5rem;
}

.flash {
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.flash--ok {
    background: #d8f3dc;
    color: #1b4332;
}

.flash--err {
    background: #ffdad6;
    color: #7f1d1d;
}

.form-field {
    margin-bottom: 1rem;
}

.form-field label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}

.form-field textarea.code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.45;
}

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

.form-field--inline input[type="checkbox"] {
    width: auto;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
    z-index: 1000;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    margin: auto;
}

.modal__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

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

.modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.job-panel {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.job-panel[hidden] {
    display: none !important;
}

.job-panel h2 {
    font-size: 1.1rem;
    margin: 0 0 0.75rem;
}

.job-panel__meta {
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.job-panel__meta code {
    font-size: 0.85rem;
}

.job-progress-big {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 1rem;
}

.job-phases {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.job-phase {
    display: grid;
    grid-template-columns: 1fr minmax(80px, 28%);
    gap: 0.5rem 1rem;
    align-items: center;
    font-size: 0.9rem;
}

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

.job-phase--active .job-phase__label {
    color: var(--text);
    font-weight: 600;
}

.job-phase--done .job-phase__label {
    color: var(--accent);
}

.job-phase__bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.job-phase__fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.25s ease;
}

.job-error {
    color: #9b2226;
    font-weight: 500;
    margin-top: 0.75rem;
}

.job-success {
    color: #1b4332;
    font-weight: 500;
    margin-top: 0.75rem;
}
