/* ── Reset & design tokens ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg:       #f0f2f5;
    --surface:  #ffffff;
    --border:   #dde1e7;
    --text:     #1c1e21;
    --muted:    #65676b;
    --link:     #0866ff;
    --success:  #1a7f37;
    --error:    #cf222e;
    --btn:      #0866ff;
    --btn-h:    #0550cc;
    --r:        6px;
    --shadow:   0 1px 3px rgba(0, 0, 0, .07);
}

html { font-size: 14px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    line-height: 1.5;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth body (login / register) ────────────────────────────── */
body.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
}

/* ── App header ──────────────────────────────────────────────── */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow);
}
.header__brand { font-weight: 700; font-size: 15px; }
.header__brand span { color: var(--btn); }
.header__nav { display: flex; gap: 16px; align-items: center; }

/* ── Container ───────────────────────────────────────────────── */
.container { max-width: 980px; margin: 0 auto; padding: 28px 16px; }

/* ── Card ────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.card__head {
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
}

/* ── Table ───────────────────────────────────────────────────── */
/* Horizontal scroll fallback so action buttons are never clipped by
   the card's overflow:hidden when the row is wider than the card. */
.table-wrap { overflow-x: auto; }
table  { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 18px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    background: #f8f9fa;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }
td.mono { font-family: 'Consolas', 'Monaco', monospace; font-size: 12px; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-success { background: #dafbe1; color: var(--success); }
.badge-error   { background: #ffebe9; color: var(--error);   }
.badge-neutral { background: #eaecef; color: var(--muted);   }

/* ── Trigger labels ──────────────────────────────────────────── */
.trigger { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.trigger-webhook { background: #ddf4ff; color: #0969da; }
.trigger-manual  { background: #fff3e0; color: #9a3412; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 5px 13px;
    border-radius: var(--r);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1.5;
    text-decoration: none !important;
    transition: background .12s, border-color .12s;
}
.btn-primary   { background: var(--btn);     color: #fff;        border-color: var(--btn);    }
.btn-primary:hover { background: var(--btn-h); border-color: var(--btn-h); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-full { display: block; width: 100%; text-align: center; padding: 9px; font-size: 14px; font-weight: 600; }
/* Compact action buttons inside table rows so multiple fit on one line. */
td .btn { padding: 4px 9px; font-size: 11px; }
td form { margin: 0; }

/* ── Flash messages ──────────────────────────────────────────── */
.flash { padding: 11px 16px; border-radius: var(--r); margin-bottom: 20px; border: 1px solid transparent; font-size: 13px; }
.flash-success { background: #dafbe1; border-color: #a7f3b8; color: var(--success); }
.flash-error   { background: #ffebe9; border-color: #ffaaa5; color: var(--error);   }

/* ── Auth box ────────────────────────────────────────────────── */
.auth-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}
.auth-box h1 { font-size: 19px; margin: 0 0 6px; }
.auth-box p  { color: var(--muted); font-size: 13px; margin: 0 0 24px; }

.warning-box {
    background: #fff8e1;
    border: 1px solid #ffe082;
    color: #7a5000;
    border-radius: var(--r);
    padding: 12px 16px;
    font-size: 13px;
    width: 100%;
    max-width: 400px;
    line-height: 1.5;
}
.warning-box strong { display: block; margin-bottom: 4px; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.form-group input {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus {
    border-color: var(--btn);
    box-shadow: 0 0 0 3px rgba(8, 102, 255, .15);
}
.form-hint  { font-size: 11px; color: var(--muted); margin-top: 4px; }
.form-error { color: var(--error); font-size: 13px; margin-bottom: 14px; }

.error-list {
    background: #ffebe9;
    border: 1px solid #ffaaa5;
    border-radius: var(--r);
    padding: 10px 14px;
    margin-bottom: 16px;
}
.error-list ul { margin: 0; padding-left: 18px; }
.error-list li { font-size: 13px; color: var(--error); padding: 2px 0; }

/* ── Log entries ─────────────────────────────────────────────── */
.log-entry { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; margin-bottom: 14px; }
.log-entry__head {
    padding: 9px 14px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
}
.log-entry__head .ts { font-weight: 600; color: var(--text); }
.log-entry__toggle { margin-left: auto; cursor: pointer; color: var(--link); font-size: 12px; user-select: none; }
.log-entry__body { padding: 12px 14px; }

pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 12px 14px;
    border-radius: var(--r);
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.5;
}

.page-title { font-size: 18px; font-weight: 700; margin: 0 0 20px; }
.back-link  { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 18px; font-size: 13px; }
.empty-state { padding: 32px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
