:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-subtle: #eef3f8;
    --text: #18202b;
    --muted: #637083;
    --border: #d9e0e8;
    --primary: #1f6feb;
    --primary-strong: #185abc;
    --success: #1f7a4d;
    --closed: #8a3ffc;
    --shadow: 0 12px 30px rgba(24, 32, 43, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: #ffffff;
    cursor: pointer;
    font-weight: 600;
    min-height: 40px;
    padding: 0 14px;
}

button:hover {
    background: var(--primary-strong);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

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

button.secondary:hover {
    background: #e3ebf4;
}

input,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    min-height: 40px;
    padding: 0 10px;
}

label {
    color: var(--muted);
    display: block;
    font-size: 0.84rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.topbar {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 18px clamp(16px, 4vw, 40px);
}

.eyebrow {
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin: 0 0 4px;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(1.6rem, 2.8vw, 2.4rem);
    line-height: 1.1;
    margin-bottom: 0;
}

h2 {
    font-size: 1.05rem;
    margin-bottom: 0;
}

h3 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.sync-status {
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    max-width: 45%;
    overflow-wrap: anywhere;
    padding: 8px 12px;
}

.topbar-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.nav-link {
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--primary);
    font-weight: 700;
    padding: 8px 12px;
    text-decoration: none;
}

.nav-link:hover {
    border-color: var(--primary);
    color: var(--primary-strong);
}

.layout {
    display: grid;
    gap: 16px;
    padding: 18px clamp(16px, 4vw, 40px) 40px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.controls-panel,
.filters-panel {
    display: grid;
    gap: 14px;
    grid-template-columns: 1fr;
    padding: 16px;
}

.repo-fields,
.filters-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.repo-fields,
.button-row {
    display: grid;
    gap: 12px;
}

.repo-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.button-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.content-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
}

.issue-list-panel,
.issue-detail-panel,
.report-panel {
    min-width: 0;
    padding: 16px;
}

.report-panel {
    display: grid;
    gap: 12px;
}

.report-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.statement-summary {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-panel {
    display: grid;
    gap: 8px;
    padding: 16px;
}

.metric-panel span {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
}

.metric-panel strong {
    font-size: 1.45rem;
}

.payment-form {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.payment-note {
    grid-column: span 3;
}

.statement-section {
    display: grid;
    gap: 10px;
}

.statement-section + .statement-section {
    margin-top: 18px;
}

.panel-heading {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

#resultCount,
#pageStatus {
    color: var(--muted);
    font-size: 0.9rem;
}

.issue-list {
    min-width: 0;
}

.table-wrap {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
}

.issues-table {
    border-collapse: collapse;
    min-width: 720px;
    width: 100%;
}

.issues-table th,
.issues-table td {
    border-bottom: 1px solid var(--border);
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

.issues-table th {
    background: var(--surface-subtle);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
}

.issues-table tbody tr {
    cursor: pointer;
}

.issues-table tbody tr:hover,
.issues-table tbody tr.active {
    background: var(--surface-subtle);
}

.issues-table tbody tr:last-child td {
    border-bottom: 0;
}

.issue-number {
    width: 110px;
}

.issue-status {
    width: 110px;
}

.issue-hours {
    font-weight: 700;
    text-align: right;
    width: 90px;
}

.table-select-button {
    background: transparent;
    border: 0;
    color: var(--primary);
    min-height: 0;
    padding: 0;
}

.table-select-button:hover {
    background: transparent;
    color: var(--primary-strong);
}

.issue-title {
    color: var(--text);
    font-weight: 700;
    overflow-wrap: anywhere;
}

.issue-meta,
.detail-meta {
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    font-size: 0.9rem;
}

.state {
    border-radius: 999px;
    color: #ffffff;
    display: inline-flex;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
    padding: 5px 8px;
    text-transform: uppercase;
}

.state.open {
    background: var(--success);
}

.state.closed {
    background: var(--closed);
}

.labels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.label-pill {
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font-size: 0.78rem;
    padding: 3px 7px;
}

.empty-state,
.error-state {
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--muted);
    padding: 18px;
}

.error-state {
    color: #9d2b2b;
}

.detail-body {
    border-top: 1px solid var(--border);
    color: var(--text);
    margin-top: 14px;
    overflow-wrap: anywhere;
    padding-top: 14px;
    white-space: pre-wrap;
}

.detail-link {
    color: var(--primary);
    display: inline-block;
    font-weight: 700;
    margin-top: 12px;
}

.pagination {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 14px;
}

.month-report {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.month-report summary {
    align-items: center;
    background: var(--surface-subtle);
    cursor: pointer;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    justify-content: space-between;
    padding: 12px;
}

.month-report summary strong {
    color: var(--text);
}

.report-table a {
    color: var(--primary);
    font-weight: 700;
}

@media (min-width: 840px) {
    .controls-panel {
        grid-template-columns: minmax(220px, 0.8fr) minmax(320px, 1.2fr) minmax(220px, 0.6fr);
        align-items: end;
    }
}

@media (max-width: 900px) {
    .filters-panel,
    .content-grid,
    .statement-summary,
    .payment-form {
        grid-template-columns: 1fr;
    }

    .payment-note {
        grid-column: auto;
    }
}

@media (max-width: 640px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .sync-status {
        max-width: 100%;
        width: 100%;
    }

    .topbar-actions {
        align-items: stretch;
        width: 100%;
    }

    .nav-link {
        text-align: center;
    }

    .repo-fields,
    .button-row,
    .report-filters {
        grid-template-columns: 1fr;
    }

    .pagination {
        justify-content: stretch;
    }

    .pagination button {
        flex: 1;
    }

    .table-wrap {
        border: 0;
        overflow-x: visible;
    }

    .issues-table,
    .issues-table thead,
    .issues-table tbody,
    .issues-table tr,
    .issues-table th,
    .issues-table td {
        display: block;
        min-width: 0;
        width: 100%;
    }

    .issues-table thead {
        display: none;
    }

    .issues-table tr {
        border: 1px solid var(--border);
        border-radius: 8px;
        margin-bottom: 10px;
        overflow: hidden;
    }

    .issues-table td {
        border-bottom: 1px solid var(--border);
        display: grid;
        gap: 8px;
        grid-template-columns: 86px minmax(0, 1fr);
    }

    .issues-table td::before {
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .issue-number::before {
        content: "Issue No";
    }

    .issue-summary::before {
        content: "Summary";
    }

    .issue-status::before {
        content: "Status";
    }

    .issue-hours::before {
        content: "Hours";
    }

    .issue-hours {
        text-align: left;
    }
}
