@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

/* Brand tokens — derived from opentagagent.com (dark navy + sky→cyan). */
:root {
    --navy: #04121f;
    --navy-2: #0a0f1c;
    --brand-gradient: linear-gradient(90deg, #38bdf8, #22d3ee);
    --brand-blue: #2b8cff;
    --brand-tint: rgba(56, 189, 248, 0.14);
    --ink: #0a1224;
    --muted: #6b7a99;
    --bg: #f6f8fc;
    --surface: #ffffff;
    --line: #e6e7ea;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: #1a1a1a;
}
.layout { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--navy);
    color: #d8d8dc;
    display: flex;
    flex-direction: column;
    padding: 22px 14px;
    overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 22px 6px; }
.brand-logo { width: 100%; height: auto; display: block; border-radius: 8px; }
.brand-mark { width: 42px; height: 42px; flex-shrink: 0; display: block; filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.45)); }
.brand-wordmark { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: -0.02em; white-space: nowrap; }
.sidebar-toggle { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; background: none; border: none; color: #9a9aa2; cursor: pointer; padding: 4px; border-radius: 6px; }
.sidebar-toggle:hover { background: #1c1c20; color: #fff; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #c2c2c8;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav a:hover { background: #1c1c20; color: #fff; }
.nav a.active { background: #26262c; color: #fff; }
.nav a.disabled { color: #5a5a62; cursor: default; pointer-events: none; }
.nav .soon { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: #6a6a72; }
.nav .user-indicator {
    margin-top: auto;
    padding: 12px 12px 4px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-top: 1px solid #26262c;
    overflow: hidden;
}
.nav .user-indicator strong {
    font-size: 12px;
    color: #c2c2c8;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.workspace-name-sidebar { font-size: 11px; color: #6a6a72; }
.nav .foot { margin: 0; }
.logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    padding: 8px 12px;
    color: #9a9aa2;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    border-radius: 8px;
    text-align: left;
    width: 100%;
}
.logout-btn:hover { background: #1c1c20; color: #fff; }

/* Collapsed sidebar — logo + icons only */
.sidebar { transition: width 0.18s ease; }
.sidebar.collapsed { width: 72px; padding-left: 10px; padding-right: 10px; }
.sidebar.collapsed .brand { flex-direction: column; align-items: center; gap: 16px; padding: 10px 0 22px 0; }
.sidebar.collapsed .brand-mark { width: 48px; height: 48px; }
.sidebar.collapsed .brand-wordmark { display: none; }
.sidebar.collapsed .sidebar-toggle { margin-left: 0; }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }
.sidebar.collapsed .nav a { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .user-indicator { display: none; }
.sidebar.collapsed .logout-btn { justify-content: center; padding: 10px 0; }

/* Email-initials avatar — shown only when collapsed; pins the footer to the bottom */
.user-avatar {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    align-items: center;
    justify-content: center;
    margin: 12px auto 0;
    flex-shrink: 0;
}
.sidebar.collapsed .user-avatar { display: flex; margin-top: auto; }

/* Workspace switcher (hidden when the sidebar is collapsed) */
.ws-switcher { position: relative; margin: 0 0 18px 0; }
.ws-current {
    display: flex; align-items: center; gap: 8px; width: 100%;
    background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e8eaf0; padding: 8px 10px; border-radius: 10px; cursor: pointer; font: inherit;
}
.ws-current:hover { background: rgba(255, 255, 255, 0.1); }
.ws-badge {
    width: 22px; height: 22px; border-radius: 6px; background: var(--brand-gradient);
    color: var(--navy); font-weight: 700; font-size: 11px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ws-name {
    flex: 1; min-width: 0; text-align: left; font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-caret { flex-shrink: 0; opacity: 0.7; }
.ws-menu {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 50;
    background: #0d1a2b; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 10px;
    padding: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.ws-menu form { margin: 0; }
.ws-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    background: none; border: none; color: #c7ccd8; padding: 8px; border-radius: 8px;
    cursor: pointer; font: inherit;
}
.ws-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.ws-item.active { color: #fff; }
.ws-item .ws-check { margin-left: auto; color: var(--brand-blue); flex-shrink: 0; }
.sidebar.collapsed .ws-switcher { display: none; }

/* Content */
.content { flex: 1; padding: 32px 40px; overflow-y: auto; }
/* Bounded pages (usage, billing, …) center their content on wide displays
   instead of hugging the sidebar. The channels page (.content-full) is exempt. */
.content:not(.content-full) { display: flex; flex-direction: column; align-items: center; }
.content:not(.content-full) > * { width: 100%; max-width: 1000px; }
.content-full { padding: 0; max-width: none; display: flex; flex-direction: column; }
.content h1 { font-size: 22px; margin: 0 0 4px 0; }
.content .sub { color: #6a6a72; margin: 0 0 26px 0; font-size: 14px; }

.card { background: #fff; border: 1px solid #e6e7ea; border-radius: 12px; padding: 20px; margin-bottom: 18px; }
.stats { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.stats .card { flex: 1; min-width: 200px; margin-bottom: 0; }
.stat-num { font-size: 34px; font-weight: 700; line-height: 1; }
.stat-label { color: #6a6a72; font-size: 13px; margin-top: 6px; }
.btn { display: inline-block; background: var(--brand-gradient); color: #fff; text-decoration: none; padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 600; border: none; cursor: pointer; }
.btn:hover { opacity: 0.88; }
.btn.secondary { background: #fff; color: #111; border: 1px solid #d4d5d9; }
.banner { background: #fff6e5; border: 1px solid #f0c869; border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; font-size: 14px; }
.banner-error { background: #fce8e6; border-color: #e0b4ae; color: #b3261e; }
.banner-success { background: #e6f4ea; border-color: #b4dbc2; color: #1a7f37; }
.banner-warning { background: #fff6e5; border-color: #f0c869; color: #8a6d00; }
.banner-info { background: #e8f0fe; border-color: #aec7e8; color: #174ea6; }
.row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid #f0f0f2; font-size: 14px; }
.row:last-child { border-bottom: none; }
.muted { color: #8a8a92; }
.pos { color: #1a7f37; font-weight: 600; }
.neg { color: #b3261e; font-weight: 600; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: #eee; }
.pill.captured { background: #e6f4ea; color: #1a7f37; }
.pill.failed { background: #fce8e6; color: #b3261e; }
.pill.pending { background: #fef3d9; color: #8a6d00; }
.pill.refunded { background: #eef; color: #445; }
.grid { display: flex; gap: 18px; flex-wrap: wrap; }
.grid .col { flex: 1; min-width: 280px; }
.grid .card { margin-bottom: 0; }
h3 { font-size: 16px; margin: 0 0 12px 0; }
.spread { display: flex; justify-content: space-between; align-items: center; }
.packs { display: flex; gap: 16px; flex-wrap: wrap; }
.pack { border: 1px solid #e6e7ea; border-radius: 12px; padding: 20px; width: 200px; background: #fff; }
.pack h2 { margin: 0 0 6px 0; font-size: 18px; }

/* Channels page: Slack-style three-pane layout */
.channels-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Middle column: channel / DM list */
.channel-list {
    width: 280px;
    flex-shrink: 0;
    background: #1b1d21;
    color: #c2c2c8;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2c2f35;
}

.channel-list-header {
    padding: 18px 16px 14px;
    border-bottom: 1px solid #2c2f35;
}

.workspace-name {
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.channel-search {
    width: 100%;
    background: #0f1013;
    border: 1px solid #2c2f35;
    border-radius: 6px;
    padding: 8px 12px;
    color: #d8d8dc;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.channel-search:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 1px var(--brand-blue);
}

.channel-search::placeholder { color: #6a6a72; }

.channel-list-section {
    padding: 16px 0;
    overflow-y: auto;
    flex: 1;
}

.channel-list-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6a6a72;
    padding: 0 16px 8px;
    margin: 0;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 10px;
    padding: 6px 10px;
    border-radius: 6px;
    color: #c2c2c8;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease;
}

.channel-item:hover {
    background: #26282d;
    color: #fff;
}

.channel-item.active {
    background: var(--brand-blue);
    color: #fff;
}

.channel-item-muted {
    color: #6a6a72;
    cursor: default;
}

.channel-item-muted:hover {
    background: transparent;
    color: #6a6a72;
}

.channel-prefix {
    color: #6a6a72;
    font-size: 15px;
    line-height: 1;
    width: 16px;
    text-align: center;
}

.channel-item.active .channel-prefix { color: #fff; }

/* Right column: chat-area for integrations */
.integration-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    min-width: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 15px 24px;
    background: #fff;
    border-bottom: 1px solid #e6e7ea;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    z-index: 10;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.chat-header-prefix {
    color: #6a6a72;
    font-size: 18px;
    font-weight: 600;
}

.chat-header-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.integration-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.integration-search-bar {
    flex: 0 0 auto;
}

.integration-filter-tabs {
    margin-left: auto;
    display: flex;
    gap: 6px;
    background: #fff;
    border: 1px solid #e6e7ea;
    padding: 3px;
    border-radius: 8px;
}

.integration-filter-tab {
    font-size: 13px;
    font-weight: 600;
    color: #6a6a72;
    text-decoration: none;
    padding: 5px 12px;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

.integration-filter-tab:hover { color: #1a1a1a; }

.integration-filter-tab.active {
    background: #111;
    color: #fff;
}

.integration-search {
    width: 100%;
    max-width: 360px;
    padding: 10px 14px;
    border: 1px solid #d4d5d9;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.integration-search:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 1px rgba(17, 100, 163, 0.2);
}

.integration-search::placeholder { color: #8a8a92; }

.channel-tabs {
    display: flex;
    gap: 8px;
    background: #f0f0f2;
    padding: 4px;
    border-radius: 8px;
    flex-shrink: 0;
    position: relative;
}

.channel-tab {
    font-size: 13px;
    font-weight: 600;
    color: #6a6a72;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    position: relative;
    overflow: hidden;
}

.channel-tab:hover { color: #1a1a1a; }

.channel-tab.active {
    background: #fff;
    color: #111;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Progress-bar indicator that grows from the left on active tab */
.channel-tab.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: var(--brand-blue);
    border-radius: 2px 2px 0 0;
    transform: scaleX(0);
    transform-origin: left;
    animation: progress-from-left 0.35s ease-out forwards;
}

@keyframes progress-from-left {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

/* Integrations tab content slides in from the left */
.tab-content.integrations-active {
    animation: slide-from-left 0.3s ease-out;
}

@keyframes slide-from-left {
    from {
        opacity: 0;
        transform: translateX(-18px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.integration-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    grid-auto-rows: minmax(180px, auto);
    gap: 20px;
    align-content: start;
}

.integration-card {
    position: relative;
    background: #fff;
    border: 1px solid #e6e7ea;
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.integration-card:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    border-color: #d4d5d9;
    transform: translateY(-1px);
}

.integration-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.integration-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: contain;
    background: #f6f7f9;
    border: 1px solid #e6e7ea;
    flex-shrink: 0;
}

.integration-name {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: #1a1a1a;
}

.integration-auth {
    font-size: 11px;
    color: #8a8a92;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 3px;
}

.native-tag {
    margin-left: 5px;
    padding: 1px 5px;
    border-radius: 3px;
    background: #eef1ff;
    color: #4553c7;
    font-weight: 600;
}

.integration-desc {
    font-size: 13px;
    color: #6a6a72;
    line-height: 1.5;
    margin: 0;
    flex: 1;
    min-height: 0;
    max-height: 84px;
    overflow-y: auto;
    padding-right: 4px;
}

.integration-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
    padding-top: 4px;
}

.integration-status {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
}

.integration-status.connected { background: #e6f4ea; color: #1a7f37; }
.integration-status.disconnected { background: #f0f0f2; color: #6a6a72; }
.global-corner {
    position: absolute;
    top: 12px;
    right: 14px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--brand-tint);
    color: var(--brand-blue);
    cursor: default;
}

.btn-connect {
    display: inline-block;
    padding: 7px 16px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.btn-connect.connect { background: var(--brand-gradient); color: #fff; }
.btn-connect.connect:hover { opacity: 0.85; }

.btn-connect.disconnect {
    background: #fff;
    color: #111;
    border: 1px solid #d4d5d9;
}

.btn-connect.disconnect:hover { background: #f6f7f9; }

/* An edit form that opens in place. <details> rather than a JS toggle, so it
   works with the form's own POST and needs no state anywhere. The summary is
   styled as a button and the default disclosure triangle removed. */
.edit-panel { margin: 10px 0 0; }

.edit-panel > summary.edit-toggle {
    /* summary defaults to display:list-item, which renders as text and keeps the
       marker even with list-style:none. Both have to be overridden. */
    display: inline-block;
    background: #fff;
    color: #111;
    border: 1px solid #d4d5d9;
    list-style: none;
    width: fit-content;
    user-select: none;
}

.edit-panel > summary.edit-toggle::-webkit-details-marker { display: none; }
.edit-panel > summary.edit-toggle:hover { background: #f6f7f9; }
.edit-panel[open] > summary.edit-toggle { background: #f6f7f9; }

.empty-state {
    grid-column: 1 / -1;
    padding: 80px 24px;
    text-align: center;
    color: #6a6a72;
    font-size: 14px;
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f6f7f9;
}

.trigger-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 800px;
}

.trigger-card {
    background: #fff;
    border: 1px solid #e6e7ea;
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: box-shadow 0.18s ease, border-color 0.18s ease;
}

.trigger-card:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    border-color: #d4d5d9;
}

.trigger-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.trigger-name {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
}

.trigger-meta {
    font-size: 12px;
    color: #6a6a72;
    margin-top: 4px;
}

.trigger-prompt {
    font-size: 13px;
    color: #6a6a72;
    line-height: 1.5;
    margin: 0;
    background: #f6f7f9;
    border: 1px solid #e6e7ea;
    border-radius: 8px;
    padding: 12px;
}

.trigger-actions {
    display: flex;
    gap: 10px;
}

.bot-pane {
    max-width: 640px;
}

.task-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-input {
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #1a1a1a;
    background: #fff;
    border: 1px solid #e6e7ea;
    border-radius: 8px;
    padding: 10px 12px;
}

.task-input:focus {
    outline: none;
    border-color: var(--brand-blue, #1a1a1a);
    box-shadow: 0 0 0 3px var(--brand-tint, rgba(26,26,26,0.08));
}

.task-input::placeholder { color: #9a9aa2; }

.model-picker { min-width: 0; }
.model-picker [hidden] { display: none !important; }
.model-picker-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.model-picker-selection { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.model-picker-current { min-width: 0; }
.model-picker-current strong, .model-picker-inherit strong, .model-picker-result > strong { display: block; font-size: 13px; font-weight: 500; }
.model-picker-current > span, .model-picker-inherit > span { display: block; font-size: 12px; color: #616b7a; overflow-wrap: anywhere; }
.model-picker-panel { margin-top: 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); overflow: hidden; }
.model-picker-search-label { display: block; margin: 12px 12px 6px; font-size: 12px; color: #616b7a; }
.model-picker-panel > .task-input { margin: 0 12px 12px; width: calc(100% - 24px); font-size: 16px; }
.model-picker-inherit, .model-picker-result { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 12px 15px; font: inherit; color: var(--ink); text-align: left; cursor: pointer; background: var(--surface); }
.model-picker-inherit { background: var(--bg); border-top: 1px solid var(--line); }
.model-picker-result:hover, .model-picker-inherit:hover { background: #edf5fc; }
.model-picker-result:focus-visible, .model-picker-inherit:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: -3px; }
.model-picker-result:last-child { border-bottom: 0; }
.model-picker-caption { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 15px 5px; font-size: 11px; color: #616b7a; }
.model-picker-slug { display: block; color: #616b7a; font-size: 11px; overflow-wrap: anywhere; margin: 2px 0 10px; }
.model-picker-facts { display: grid; grid-template-columns: 1.1fr 1fr 1fr 1fr; gap: 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.model-picker-facts span { display: block; }
.model-picker-fact-label { font-size: 11px; color: #616b7a; margin-bottom: 2px; }
.model-picker-more { margin: 10px 15px; }
.model-picker-error { color: #b3261e; font-size: 12px; margin: 8px 0 0; }
.model-picker-selection > button { flex-shrink: 0; }
.task-form[aria-busy="true"] button[type="submit"] { opacity: .6; cursor: wait; }
@media (max-width: 520px) {
    .model-picker-facts { grid-template-columns: 1fr 1fr; gap: 9px 18px; }
}

textarea.task-input {
    min-height: 110px;
    resize: vertical;
    line-height: 1.5;
}

.task-schedule-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.task-schedule-row .task-input { width: auto; flex: 1 1 160px; min-width: 140px; }
.task-schedule-row input[type="time"].task-input,
.task-schedule-row input[type="number"].task-input { flex: 0 0 auto; min-width: 120px; }

.task-card-footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.hook-url-row {
    display: flex;
    gap: 8px;
    margin: 10px 0;
}

.hook-url-input {
    flex: 1 1 auto;
    font-family: monospace;
    font-size: 12px;
    color: #6a6a72;
}

.task-history {
    font-size: 12px;
    color: #6a6a72;
    flex: 1;
    min-width: 0;
}

.task-history summary {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.task-history summary::-webkit-details-marker { display: none; }

.task-history-toggle {
    color: #9a9aa2;
    font-weight: 700;
}

.task-history-toggle::after { content: " ▾"; }

.task-history[open] .task-history-toggle::after { content: " ▴"; }

.task-history summary:hover .task-history-toggle { color: #1a1a1a; }

.task-history-table {
    margin-top: 10px;
    border-collapse: collapse;
    min-width: 280px;
}

.task-history-table td {
    padding: 5px 18px 5px 0;
    border-top: 1px solid #f0f0f2;
    white-space: nowrap;
}

.task-history-cost {
    text-align: right;
    color: #9a9aa2;
}

.task-run-status {
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f0f0f2;
    color: #6a6a72;
}

.task-run-status.status-4 { background: #e6f4ea; color: #1a7f37; }
.task-run-status.status-5 { background: #fdecea; color: #b3261e; }
.task-run-status.status-2 { background: var(--brand-tint); color: var(--brand-blue); }

.task-actions {
    display: flex;
    gap: 10px;
}

.topup-amounts {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.topup-custom { width: 110px; }

.currency-switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; margin-bottom: 12px; }
.currency-switch input { position: absolute; opacity: 0; pointer-events: none; }
.currency-switch .track { position: relative; width: 36px; height: 20px; border-radius: 999px; background: #d0d0d6; transition: background .15s; }
.currency-switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.currency-switch input:checked + .track { background: #1c1c20; }
.currency-switch input:checked + .track::after { transform: translateX(16px); }
.currency-switch input:focus-visible + .track { outline: 2px solid #1c1c20; outline-offset: 2px; }

.topup-note { font-size: 12px; margin: 0 0 14px 0; }

.topup-error { font-size: 13px; color: #b3261e; margin: 10px 0 0 0; }

/* Mobile nav: hamburger + off-canvas drawer (hidden above the breakpoint) */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 210;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: var(--navy);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    cursor: pointer;
}
.sidebar.mobile-open ~ .mobile-menu-toggle { display: none; }
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 18, 31, 0.55);
    z-index: 150;
}
.sidebar-backdrop.visible { display: block; }

/* Responsive breakpoints */
@media (max-width: 860px) {
    .layout { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
    .mobile-menu-toggle { display: flex; }
    .sidebar-toggle { display: none; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 240px !important;
        max-width: 82vw;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    /* The desktop icon-rail collapse is meaningless on mobile — always render expanded. */
    .sidebar.collapsed { width: 240px !important; padding: 22px 14px; }
    .sidebar.collapsed .brand { flex-direction: row; align-items: center; gap: 10px; padding: 4px 6px 22px 6px; }
    .sidebar.collapsed .brand-mark { width: 42px; height: 42px; }
    .sidebar.collapsed .brand-wordmark { display: inline; }
    .sidebar.collapsed .nav a { justify-content: flex-start; padding: 10px 12px; }
    .sidebar.collapsed .nav-label { display: inline; }
    .sidebar.collapsed .user-indicator { display: flex; }
    .sidebar.collapsed .logout-btn { justify-content: flex-start; padding: 8px 12px; }
    .sidebar.collapsed .user-avatar { display: none; }
    .sidebar.collapsed .ws-switcher { display: block; }

    .content { padding: 64px 16px 20px; }
    .content-full { padding: 64px 0 0 0; }

    .stats, .grid, .packs { gap: 12px; }
    .table-scroll { overflow-x: auto; }

    .channels-layout { flex-direction: column; }
    .channel-list {
        width: 100%;
        max-height: 38vh;
        border-right: none;
        border-bottom: 1px solid #2c2f35;
    }
    .integration-pane { min-height: 0; }
    .chat-header { flex-wrap: wrap; row-gap: 10px; padding: 14px 16px; }
    .chat-header-right { flex-wrap: wrap; }
    .channel-tabs { flex-wrap: wrap; }
    .tab-content { padding: 16px; }
    .integration-toolbar { gap: 10px; }
    .integration-filter-tabs { margin-left: 0; }
    .integration-search-bar, .integration-search { max-width: none; }
}

@media (max-width: 640px) {
    .task-history-table { min-width: 0; }
}

@media (max-width: 480px) {
    .auth-card { padding: 32px 22px; }
    .auth-card .brand-logo { max-width: 160px; }
    .stat-num { font-size: 26px; }
    .task-schedule-row .task-input { flex: 1 1 100%; }
}

/* Notifications modal — pick which app events ping a channel */
.notify-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 18, 31, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 60;
}

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

.notify-modal {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 24px;
    width: min(520px, 100%);
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 18px 48px rgba(4, 18, 31, 0.18);
}

.notify-events {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}

.notify-event {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}

.notify-event:hover {
    border-color: var(--brand-blue);
}

.notify-event input {
    margin-top: 3px;
}

.notify-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============ Skills Hub ============ */

.skills-page { display: flex; flex-direction: column; gap: 22px; }

.skills-header { display: flex; flex-direction: column; gap: 4px; }
.skills-header h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.skills-header .sub { color: var(--muted); font-size: 14px; margin: 0; }
.skills-context {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 2px;
}
.skills-context .chan {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    color: var(--ink);
    background: var(--brand-tint);
    padding: 1px 7px;
    border-radius: 5px;
}
.skills-context select {
    font-size: 12.5px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 2px 6px;
    color: var(--ink);
    background: #fff;
}

.skills-search-row { position: relative; }
.skills-search {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 14px;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.skills-search:focus-within {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px var(--brand-tint);
}
.skills-search svg { flex-shrink: 0; color: var(--muted); }
.skills-search input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: transparent;
}
.skills-search input::placeholder { color: #9aa3b5; }
.skills-search-clear {
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    padding: 2px;
    border-radius: 4px;
}
.skills-search-clear:hover { color: var(--ink); background: var(--bg); }
.skills-search-clear[hidden] { display: none; }
.skills-kbd {
    font-size: 11px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 6px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    flex-shrink: 0;
}

.skills-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
}
.skills-tab {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 9px 4px;
    margin-right: 18px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
}
.skills-tab:hover { color: var(--ink); }
.skills-tab.active { color: var(--ink); border-bottom-color: var(--brand-blue); }

.skills-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.skills-chip {
    appearance: none;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.skills-chip:hover { border-color: #c7c9d1; color: var(--ink); }
.skills-chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.skills-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin: 4px 0 -6px;
}

.skills-list { display: flex; flex-direction: column; }
.skills-list.grid-mode {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 10px;
}

.skill-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 6px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background 0.1s ease;
}
.skills-list.grid-mode .skill-row {
    border: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
}
.skill-row:hover { background: #fafbfd; }
.skills-list.grid-mode .skill-row:hover { border-color: #c7c9d1; background: #fff; }
.skill-row:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: -2px; }

.skill-glyph {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--brand-tint);
    color: var(--brand-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
}

.skill-main { flex: 1; min-width: 0; }
.skill-title-line {
    display: flex;
    align-items: center;
    gap: 6px;
}
.skill-name { font-size: 14.5px; font-weight: 700; color: var(--ink); margin: 0; }
.skill-verified { color: #1a7f37; flex-shrink: 0; display: inline-flex; }
.skill-desc {
    font-size: 13px;
    color: #5c6478;
    margin: 3px 0 8px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.skill-meta-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: var(--muted);
}
.skill-repo {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    color: #6b7a99;
}
.skill-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.skill-tag {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 6px;
    font-size: 11px;
    color: var(--muted);
}
.skill-dot { color: #d0d3db; }

.skill-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.skill-install-btn {
    appearance: none;
    border-radius: 7px;
    padding: 7px 14px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
    transition: opacity 0.12s ease, background 0.12s ease;
}
.skill-install-btn.state-not_installed { background: var(--brand-gradient); color: #fff; }
.skill-install-btn.state-not_installed:hover { opacity: 0.88; }
.skill-install-btn.state-installed { background: #e6f4ea; color: #1a7f37; border-color: #c3e6cf; cursor: default; }
.skill-install-btn.state-disabled { background: #f0f0f2; color: #6a6a72; border-color: var(--line); }
.skill-install-btn.state-update { background: #fff6e5; color: #8a6d00; border-color: #f0c869; }
.skill-install-btn.state-installing { background: var(--bg); color: var(--muted); border-color: var(--line); cursor: wait; }
.skill-install-btn.state-failed { background: #fce8e6; color: #b3261e; border-color: #e0b4ae; }

/* Skeletons */
.skill-skeleton { display: flex; align-items: flex-start; gap: 14px; padding: 16px 6px; border-bottom: 1px solid var(--line); }
.skel-block { background: linear-gradient(90deg, #eef0f4 25%, #f6f7fa 37%, #eef0f4 63%); background-size: 400% 100%; animation: skel-shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes skel-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skel-glyph { width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skel-line { height: 10px; }
.skel-line.w60 { width: 60%; }
.skel-line.w90 { width: 90%; }
.skel-line.w40 { width: 40%; }

.skills-empty, .skills-error {
    padding: 70px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13.5px;
}
.skills-empty svg, .skills-error svg { color: #c7c9d1; margin-bottom: 10px; }
.skills-empty strong, .skills-error strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; font-weight: 700; }
.skills-error button, .skills-empty button {
    margin-top: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.skills-error button:hover { background: var(--bg); }

/* Detail side panel */
/* These backdrops are direct children of <main class="content">, which forces
   `width:100%; max-width:1000px` on its children on non-content-full pages —
   fine for page content, but it caps a full-viewport overlay to that same
   1000px instead of covering the screen. Beat that rule's specificity here
   rather than opting the whole page into content-full and losing its padding. */
main.content .skill-panel-backdrop,
main.content #create-skill-backdrop {
    max-width: none;
    width: 100vw;
}

.skill-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 18, 31, 0.32);
    z-index: 60;
    display: flex;
    justify-content: flex-end;
}
.skill-panel-backdrop[hidden] { display: none; }
.skill-panel {
    width: min(480px, 100%);
    height: 100%;
    background: var(--surface);
    box-shadow: -18px 0 48px rgba(4, 18, 31, 0.18);
    overflow-y: auto;
    animation: skill-panel-in 0.22s ease-out;
    display: flex;
    flex-direction: column;
}
@keyframes skill-panel-in { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.skill-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--line);
}
.skill-panel-close {
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    flex-shrink: 0;
}
.skill-panel-close:hover { background: var(--bg); color: var(--ink); }
.skill-panel-body { padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 18px; }
.skill-panel-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin: 0 0 8px;
}
.skill-panel-fact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    font-size: 13px;
}
.skill-panel-fact label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.skill-panel-fact div { color: var(--ink); font-weight: 600; }
.skill-panel-fact a { color: var(--brand-blue); text-decoration: none; }
.skill-panel-fact a:hover { text-decoration: underline; }

.skill-markdown {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px 18px;
    background: var(--bg);
    font-size: 13px;
    line-height: 1.65;
    color: #2c3345;
    max-height: 320px;
    overflow-y: auto;
}
.skill-markdown h1, .skill-markdown h2, .skill-markdown h3 { font-size: 13.5px; margin: 14px 0 6px; color: var(--ink); }
.skill-markdown h1:first-child, .skill-markdown h2:first-child, .skill-markdown h3:first-child { margin-top: 0; }
.skill-markdown p { margin: 0 0 10px; }
.skill-markdown ul, .skill-markdown ol { margin: 0 0 10px; padding-left: 20px; }
.skill-markdown code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 12px;
}
.skill-markdown pre {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: 0 0 10px;
}
.skill-markdown pre code { border: none; padding: 0; background: none; }

.skill-panel-install {
    display: flex;
    gap: 8px;
    padding-top: 4px;
}
.skill-panel-install .skill-install-btn { flex: 1; padding: 10px; font-size: 13.5px; }

/* Create Skill dialog */
.create-skill-modes {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 8px;
    padding: 3px;
    width: fit-content;
    margin-bottom: 16px;
}
.create-skill-modes button {
    appearance: none;
    border: none;
    background: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
}
.create-skill-modes button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.create-skill-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.create-skill-field label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.create-skill-field input, .create-skill-field textarea {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--ink);
}
.create-skill-field textarea { resize: vertical; min-height: 90px; }
.create-skill-field textarea.raw-md {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12.5px;
    min-height: 260px;
    background: var(--bg);
}

@media (max-width: 860px) {
    .skill-panel { width: 100%; }
    .skills-tabs { overflow-x: auto; }
}
@media (max-width: 640px) {
    .skill-row { flex-wrap: wrap; }
    .skill-side { flex-direction: row; align-items: center; width: 100%; justify-content: space-between; margin-top: 6px; }
    .skill-panel-fact-grid { grid-template-columns: 1fr; }
}

/* Smart Rules — the gate that decides whether a delivery starts a run at all.
   Indented from the card's own content with a left rail, because these are a
   property of the webhook above them rather than a sibling of it. */
.smart-rules {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
    padding-left: 14px;
    border-left: 2px solid #e6e7ea;
}

.smart-rules-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.smart-rules-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #1a1a1a;
}

.smart-rule {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f6f7f9;
    border: 1px solid #e6e7ea;
    border-radius: 8px;
    padding: 12px;
}

/* Paused rules stay legible rather than dimmed to grey: a rule that is off is
   still something the reader is deciding about. */
.smart-rule.is-paused { background: #fff; border-style: dashed; }

.smart-rule-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.smart-rule-name {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
}

.smart-rule-prompt {
    font-size: 13px;
    color: #6a6a72;
    line-height: 1.5;
    margin: 0;
}
.skills-git-form { margin: 20px 0; }
.skills-git-form label { display: block; font-weight: 600; margin-bottom: 8px; }
.skills-git-row { display: flex; gap: 10px; }
.skills-git-row input { flex: 1; min-width: 0; border: 1px solid #dbe1ea; border-radius: 8px; padding: 10px 12px; }
.skills-context select { max-width: 280px; border: 1px solid #dbe1ea; border-radius: 6px; padding: 5px 8px; background: white; }
.skills-page [hidden] { display: none; }
.skills-status { margin: 12px 0; color: #16704a; }
.skills-status.is-error { color: #a32727; }
