:root {
    --app-ink: #20262d;
    --app-muted: #6c757d;
    --app-line: #d8dee7;
    --app-bg: #f6f8fb;
    --app-nav: #263445;
    --app-blue: #2f6fed;
    --app-green: #178060;
}

body {
    background: var(--app-bg);
    color: var(--app-ink);
}

.app-navbar {
    background: var(--app-nav);
}

.app-navbar .navbar-brand,
.app-navbar .nav-link {
    color: #fff;
}

.app-navbar .nav-link:hover {
    color: #d8e6ff;
}

.navbar-account {
    color: #d8e6ff;
    font-size: 14px;
    line-height: 1;
}

.app-main {
    padding: 28px;
}

.page-heading {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.page-heading h1 {
    font-size: 28px;
    margin: 0;
}

.page-heading p {
    color: var(--app-muted);
    margin: 6px 0 0;
}

.settlement-heading-content {
    width: 100%;
}

.settlement-heading-row {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 6px;
}

.settlement-heading-row p {
    margin: 0;
}

.dashboard-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.page-heading + .dashboard-grid {
    margin-top: 24px;
}

.metric-card {
    background: #fff;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    padding: 18px;
}

.metric-card span {
    color: var(--app-muted);
    display: block;
    font-size: 14px;
}

.metric-card strong {
    display: block;
    font-size: 26px;
    margin-top: 8px;
}

.filter-bar {
    align-items: end;
    background: #fff;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-top: 24px;
    padding: 18px;
}

.report-section {
    background: #fff;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    margin-top: 18px;
    padding: 18px;
}

.section-title {
    font-size: 18px;
    margin: 0 0 16px;
}

.compact-form {
    margin-top: 0;
}

#toolForm {
    grid-template-columns: minmax(160px, 1fr) 130px minmax(360px, 2.4fr) minmax(120px, 0.8fr) minmax(150px, 0.9fr) minmax(160px, 1fr) auto;
}

.tool-type-field {
    max-width: 140px;
}

.tool-url-field {
    min-width: 360px;
}

.channel-filter {
    min-width: 260px;
}

.channel-menu {
    min-width: 280px;
    padding: 10px;
}

.channel-menu-actions {
    border-bottom: 1px solid var(--app-line);
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 8px;
}

.channel-check-list {
    display: grid;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.channel-check-item {
    margin: 0;
    min-height: 28px;
}

.section-toolbar {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-toolbar .nav-tabs {
    border-bottom: 0;
    flex: 1;
}

#reportTable {
    table-layout: fixed;
}

#reportTable th,
#reportTable td {
    text-align: left !important;
    vertical-align: middle;
}

#reportTable th:nth-child(1),
#reportTable td:nth-child(1),
#reportTable th:nth-child(2),
#reportTable td:nth-child(2),
#reportTable th:nth-child(3),
#reportTable td:nth-child(3),
#reportTable th:nth-child(4),
#reportTable td:nth-child(4),
#reportTable th:nth-child(5),
#reportTable td:nth-child(5) {
    width: 20%;
}

.detail-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.detail-strip span,
.detail-strip strong {
    background: #f6f8fb;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    padding: 6px 12px;
}

.settings-grid {
    display: grid;
    gap: 22px;
    grid-template-columns: 1fr;
}

.settings-group {
    display: grid;
    gap: 12px;
}

.settings-group-title {
    color: var(--app-muted);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    margin: 0;
}

.settings-inline-fields {
    align-items: start;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.settings-field-medium {
    width: min(100%, max(280px, 28vw));
}

.settings-field-narrow {
    width: min(100%, 320px);
}

.settings-field-uri {
    width: min(100%, max(560px, 52vw));
}

.settings-actions {
    align-items: center;
    display: flex;
    gap: 12px;
    grid-column: 1 / -1;
    justify-content: flex-start;
}

.status-text {
    align-self: center;
    color: var(--app-green);
}

.tool-list {
    display: grid;
    gap: 12px;
}

.gm-tool-shell {
    align-items: start;
    display: grid;
    gap: 18px;
    grid-template-columns: 180px minmax(0, 1fr);
}

.tool-type-nav {
    background: #f6f8fb;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    padding: 8px;
}

.tool-type-nav button {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--app-ink);
    display: flex;
    justify-content: space-between;
    min-height: 36px;
    padding: 6px 10px;
    text-align: left;
}

.tool-type-nav button.active,
.tool-type-nav button:hover {
    background: #e8f0ff;
    color: var(--app-blue);
}

.tool-type-nav span {
    color: var(--app-muted);
    font-size: 12px;
}

.tool-item {
    align-items: center;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 14px;
}

.gm-tool-item {
    align-items: end;
    display: grid;
    grid-template-columns: minmax(180px, 0.8fr) minmax(360px, 2fr) auto;
    min-height: 58px;
}

.tool-item div {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.tool-item span,
.tool-item code {
    color: var(--app-muted);
    overflow-wrap: anywhere;
}

.tool-main {
    min-width: 0;
}

.tool-main strong,
.tool-main span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-param-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}

.param-field {
    display: grid;
    gap: 4px;
    min-width: 120px;
}

.param-field.wide {
    min-width: 220px;
}

.param-field span,
.muted-text,
.empty-state {
    color: var(--app-muted);
    font-size: 13px;
}

.empty-state {
    border: 1px dashed var(--app-line);
    border-radius: 8px;
    padding: 18px;
}

.result-panel {
    background: #111827;
    border-radius: 8px;
    color: #e5e7eb;
    margin: 0;
    min-height: 220px;
    padding: 16px;
    white-space: pre-wrap;
}

.channel-name-cell {
    align-items: center;
    display: flex;
    gap: 8px;
}

.channel-name-link,
.channel-rate-link {
    background: transparent;
    border: 0;
    color: var(--app-ink);
    padding: 0;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.channel-name-link:hover,
.channel-rate-link:hover {
    color: var(--app-blue);
}

.settlement-date-selector {
    align-items: center;
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

.settlement-date-selector .form-select {
    width: auto;
    min-width: 76px;
}

.status-pill {
    background: #eef7f2;
    border: 1px solid #b7dfc8;
    border-radius: 999px;
    color: var(--app-green);
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    padding: 2px 10px;
}

.status-pill.muted {
    background: #f6f8fb;
    border-color: var(--app-line);
    color: var(--app-muted);
}

.settlement-progress {
    align-items: center;
    display: flex;
    gap: 8px;
    min-width: 420px;
}

.settlement-progress button {
    align-items: center;
    background: #eef2f7;
    border: 1px solid var(--app-line);
    border-radius: 999px;
    color: var(--app-muted);
    display: inline-flex;
    font-size: 13px;
    min-height: 28px;
    padding: 2px 10px;
    position: relative;
}

.settlement-progress button.active {
    background: #e8f0ff;
    border-color: #b7ccff;
    color: var(--app-blue);
}

.settlement-progress button:disabled {
    cursor: not-allowed;
    opacity: 1;
}

.settlement-progress button:not(:last-child)::after {
    background: var(--app-line);
    content: "";
    height: 1px;
    position: absolute;
    right: -9px;
    width: 8px;
}

.settlement-amount-input {
    max-width: 120px;
}

.settlement-section-row td {
    background: #f8fafc;
    color: var(--app-muted);
    font-weight: 700;
}

#taskRows td:nth-child(3),
#taskRows td:nth-child(4) {
    text-align: right;
}

.chart-box {
    height: 320px;
    min-width: 0;
}

.login-page {
    background: #edf2f7;
    min-height: 100vh;
}

.login-shell {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-panel {
    background: #fff;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    box-shadow: 0 18px 40px rgba(23, 36, 50, 0.08);
    max-width: 420px;
    padding: 32px;
    width: 100%;
}

.login-brand {
    align-items: center;
    display: flex;
    gap: 14px;
    margin-bottom: 26px;
}

.brand-mark {
    align-items: center;
    background: var(--app-blue);
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    font-weight: 700;
    height: 48px;
    justify-content: center;
    width: 48px;
}

.login-brand h1 {
    font-size: 24px;
    margin: 0;
}

.login-brand p {
    color: var(--app-muted);
    margin: 2px 0 0;
}

@media (max-width: 720px) {
    .app-main {
        padding: 18px;
    }

    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .tool-item {
        align-items: stretch;
        flex-direction: column;
    }

    .section-toolbar,
    .gm-tool-item {
        align-items: stretch;
        display: flex;
        flex-direction: column;
    }

    .gm-tool-shell {
        grid-template-columns: 1fr;
    }

    .tool-type-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #toolForm {
        grid-template-columns: 1fr;
    }

    .tool-type-field,
    .tool-url-field {
        max-width: none;
        min-width: 0;
    }

}
