:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #6b7280;
    --line: #e6eaf2;
    --green: #61c918;
    --green-dark: #43a70b;
    --blue: #2368e8;
    --shadow: 0 20px 55px rgba(33, 44, 77, 0.10);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 14% 6%, rgba(97, 201, 24, 0.16), transparent 30%),
        radial-gradient(circle at 86% 14%, rgba(35, 104, 232, 0.11), transparent 32%),
        linear-gradient(180deg, #fbfcff 0%, var(--bg) 58%, #eef3fa 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 72px;
    padding: 14px clamp(20px, 5vw, 72px);
    border-bottom: 1px solid rgba(230, 234, 242, 0.86);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0;
    text-decoration: none;
    white-space: nowrap;
}

.brand-mark {
    display: inline-grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 10px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    box-shadow: 0 10px 24px rgba(83, 187, 19, 0.28);
    font-size: 18px;
    font-weight: 900;
}

.nav-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.nav-link,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    font-weight: 750;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.nav-link:hover,
.button:hover {
    transform: translateY(-1px);
    border-color: rgba(97, 201, 24, 0.35);
    box-shadow: 0 10px 22px rgba(33, 44, 77, 0.08);
}

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

.button-primary {
    border-color: transparent;
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(83, 187, 19, 0.26);
}

.button-secondary {
    border-color: rgba(35, 104, 232, 0.22);
    background: #f6f9ff;
    color: #194fae;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.62;
    transform: none;
}

.page-shell {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 40px 0 64px;
}

.page-heading {
    margin: 0 0 22px;
}

.eyebrow,
.panel-kicker {
    margin: 0 0 8px;
    color: var(--green-dark);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(34px, 5vw, 56px);
    line-height: 1.04;
}

h2 {
    font-size: 22px;
    line-height: 1.2;
}

.panel {
    overflow: hidden;
    margin-top: 22px;
    border: 1px solid rgba(230, 234, 242, 0.96);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 26px 20px;
    border-bottom: 1px solid var(--line);
}

.panel-note {
    flex: 0 0 auto;
    margin-top: 2px;
    padding: 8px 11px;
    border-radius: 999px;
    color: #426413;
    background: #effbdd;
    font-size: 12px;
    font-weight: 750;
}

.tool-form {
    padding: 24px 26px 26px;
}

.field {
    display: grid;
    gap: 9px;
    min-width: 0;
}

.field > span {
    color: #374151;
    font-size: 14px;
    font-weight: 800;
}

.field-hint {
    margin-left: 8px;
    color: var(--muted);
    font-style: normal;
    font-weight: 700;
}

.field-select {
    max-width: 360px;
    margin-bottom: 20px;
}

.group-control-row {
    display: flex;
    align-items: end;
    gap: 12px;
    margin-bottom: 20px;
}

.group-control-row .field-select {
    flex: 1 1 360px;
    margin-bottom: 0;
}

.group-add-button {
    flex: 0 0 auto;
    min-height: 44px;
}

select,
textarea,
input[type="text"],
input[type="password"],
input[type="email"] {
    width: 100%;
    border: 1px solid #d8deea;
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

select,
input[type="text"],
input[type="password"],
input[type="email"] {
    min-height: 44px;
    padding: 0 13px;
}

textarea {
    min-height: 300px;
    padding: 14px;
    resize: vertical;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.52;
}

textarea[readonly] {
    background: #fbfcff;
    color: #293244;
    cursor: default;
}

select:focus,
textarea:focus,
input:focus {
    border-color: rgba(97, 201, 24, 0.75);
    box-shadow: 0 0 0 4px rgba(97, 201, 24, 0.14);
}

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

.textarea-result {
    min-height: 360px;
}

.query-form {
    display: grid;
    gap: 20px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(23, 32, 51, 0.42);
    backdrop-filter: blur(10px);
}

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

.confirm-modal,
.group-modal {
    width: min(900px, 100%);
    max-height: min(820px, calc(100vh - 48px));
    overflow: auto;
    border: 1px solid rgba(230, 234, 242, 0.96);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 28px 80px rgba(23, 32, 51, 0.24);
}

.group-modal {
    width: min(520px, 100%);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 26px 20px;
    border-bottom: 1px solid var(--line);
}

.modal-body {
    padding: 22px 26px 0;
}

.icon-button {
    display: inline-grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--muted);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.confirm-summary {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 12px;
    padding: 20px 26px 0;
}

.confirm-summary-single {
    grid-template-columns: 1fr;
    padding: 0;
}

.confirm-summary div {
    display: grid;
    gap: 6px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
}

.confirm-summary span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.confirm-summary strong {
    color: var(--ink);
    font-size: 15px;
}

.confirm-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    padding: 20px 26px 0;
}

.confirm-grid textarea {
    min-height: 220px;
}

.group-preview-field {
    margin-top: 18px;
}

.group-preview-field textarea {
    min-height: 150px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 22px 26px 26px;
}

.toast {
    position: fixed;
    top: 88px;
    left: 50%;
    z-index: 60;
    max-width: min(360px, calc(100vw - 36px));
    padding: 13px 16px;
    border: 1px solid rgba(220, 38, 38, 0.18);
    border-radius: 8px;
    background: #fff7f7;
    color: #b42318;
    box-shadow: 0 18px 40px rgba(23, 32, 51, 0.16);
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    transform: translateX(-50%);
}

.toast[hidden] {
    display: none;
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 32px 20px;
}

.auth-panel {
    width: min(420px, 100%);
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow);
}

.auth-panel .brand {
    margin-bottom: 28px;
}

.auth-panel h1 {
    margin-bottom: 20px;
    font-size: 30px;
}

.auth-form {
    display: grid;
    gap: 16px;
}

.simple-card {
    width: min(720px, calc(100% - 40px));
    margin: 54px auto;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow);
}

.simple-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 24px 0;
}

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

.profile-table td {
    padding: 10px 0;
}

.profile-table td:first-child {
    width: 96px;
    color: var(--muted);
    font-weight: 750;
}

@media (max-width: 760px) {
    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav-actions,
    .nav-link {
        width: 100%;
    }

    .textarea-grid {
        grid-template-columns: 1fr;
    }

    .group-control-row {
        align-items: stretch;
        flex-direction: column;
    }

    .group-add-button {
        width: 100%;
    }

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

    .panel-note {
        align-self: flex-start;
    }

    .confirm-summary,
    .confirm-grid {
        grid-template-columns: 1fr;
    }
}
