:root {
    --green-primary: #1f7a5a;   /* dark green */
    --green-secondary: #28a745; /* action green */
    --green-light: #e6f4ea;

    --text-dark: #1e1e1e;
    --text-muted: #6c757d;

    --bg-main: #f4f7f6;
    --bg-card: #ffffff;
}

/* Base */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-dark);
}

/* Top bar */
.topbar {
    background: var(--green-primary);
    color: white;
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top));
    text-align: center;
    font-weight: 600;
}

/* Layout */
.container {
    padding: 12px;
    padding-bottom: 70px; /* space for bottom nav */
}

/* Cards */
.card {
    background: white;
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 12px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.04);
}

/* Feedback */
.success {
    border-left: 4px solid var(--green-secondary);
}

.error {
    border-left: 4px solid #dc3545;
}

/* Sections */
.section {
    margin-bottom: 10px;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Rows */
.row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

/* Status badges */
.status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status.active {
    background: #e6f4ea;
    color: var(--green-primary);
    font-weight: 600;
}

.status.inactive {
    background: #f8d7da;
    color: #721c24;
}

/* Actions */
.actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* Buttons */
.btn {
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: #e9ecef;
    color: var(--text-dark);
    font-size: 14px;
}

.btn.primary {
    background: var(--green-secondary);
    color: white;
    font-weight: 600;
}

/* Inputs */
input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-size: 16px;
    background: white;
    color: var(--text-dark);
}

input::placeholder {
    color: var(--text-muted);
}

/* Bottom navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    display: flex;
    background: white;
    border-top: 1px solid #ddd;
}

.bottom-nav a {
    flex: 1;
    text-align: center;
    padding: 12px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 14px;
}

.bottom-nav a.active {
    color: var(--green-primary);
    font-weight: 600;
}

a {
    text-decoration: none;
    color: inherit;
}

.btn {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    border: none;
}

/* Primary (green) */
.btn.primary {
    background: var(--green-secondary);
    color: white;
}

/* Outline (premium subtle look) */
.btn.outline {
    background: transparent;
    border: 1px solid #dcdcdc;
    color: var(--text-dark);
}

/* Soft action button */
.btn.soft {
    background: #f1f3f5;
    color: #333;
}

.member-name {
    font-size: 16px;
    font-weight: 600;
}

.member-id {
    color: #8c8c8c;
    margin-right: 6px;
    font-weight: 500;
}

.member-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.member-id {
    color: #8c8c8c;
    margin-right: 6px;
}

/* One clean line */
.member-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

/* Keep status compact */
.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 600;
}

/* Action links (not buttons anymore) */
.link-action {
    background: none;
    border: none;
    padding: 0;
    color: var(--green-primary);
    font-weight: 500;
    cursor: pointer;
}

/* Prevent form spacing issues */
.member-meta form {
    margin: 0;
}

* {
    box-sizing: border-box;
}

form.card {
    padding: 10px;
}

input {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #ddd;
    font-size: 16px;
    outline: none;
}

input:focus {
    border-color: var(--green-primary);
}

/* Labels */
.label {
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 6px;
}

/* Amount display */
.amount {
    font-size: 24px;
    font-weight: 700;
}

.amount.positive {
    color: var(--green-primary);
}

.amount.negative {
    color: #dc3545;
}

/* Actions grid */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    align-items: stretch;
}

.actions-grid > .btn,
.actions-grid > a.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 10px 2px;
    font-size: 11px;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 10px;
    box-sizing: border-box;
}

.btn {
    text-align: center;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
}

.btn.primary {
    background: var(--green-secondary);
    color: white;
}

.btn.outline {
    border: 1px solid #dcdcdc;
    background: white;
}

.progress {
    background: #e9ecef;
    height: 10px;
    border-radius: 10px;
    margin-top: 10px;
}

.progress-bar {
    background: var(--green-secondary);
    height: 10px;
    border-radius: 10px;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Slightly tighter cards for grid */
.summary-grid .card {
    padding: 14px;
}

.summary-grid strong {
    font-size: 16px;
}

.terms-accept {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Text */
.terms-text {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
}

/* Row layout */
.terms-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Checkbox */
.terms-row input[type="checkbox"] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* Button FIX */
.terms-btn {
    flex: 1;                 /* take remaining space */
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    text-align: center;
}

.member-card {
    padding: 16px;
}

/* Top row */
.member-top {
    margin-bottom: 10px;
}

.member-name {
    font-weight: 600;
    font-size: 16px;
}

.member-id {
    color: #6c757d;
    margin-right: 6px;
}

/* Stats */
.member-stats {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.member-stats > div {
    flex: 1;
}

/* Labels */
.muted {
    font-size: 12px;
    color: #6c757d;
}

/* Amounts */
.amount {
    font-size: 16px;
    font-weight: 600;
}

.amount.positive {
    color: var(--green-primary);
}

.amount.negative {
    color: #dc3545;
}

.members-table td:first-child {
    width: 50px;
}

/* Compact table */
.members-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.members-table th {
    text-align: left;
    font-weight: 600;
    padding: 8px 6px;
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 2;
}

.members-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #eee;
}

/* Borrowed highlight */
.members-table td.neg {
    color: #dc3545;
}

/* Scrollable container */
.table-wrap {
    height: calc(100vh - 200px);
    overflow-y: auto;
    background: #fff;
    border-radius: 12px;
    margin-top: 10px;
}

/* Search input */
#search {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #ddd;
    font-size: 16px; /* prevents iOS zoom */
}

input, select, textarea {
    font-size: 16px;
}

.empty {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    font-size: 14px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* KEY: forces proper column spacing */
}

.data-table th:nth-child(1),
.data-table td:nth-child(1) {
    width: 50px; /* ID */
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
    width: 35%; /* Name */
}

.data-table th,
.data-table td {
    text-align: left;
}

.data-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #eee;
}

.data-table td {
    font-size: 13px;
}

.data-table td.pos {
    color: var(--green-primary);
}

.data-table td.neg {
    color: #dc3545;
}

.data-table tr:nth-child(even) {
    background: #fafafa;
}

button:disabled {
    background: #ccc !important;
    color: #666 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.data-table {
    width: 100%;
    table-layout: auto;   /* key: allow content-based sizing */
}

.data-table th,
.data-table td {
    white-space: nowrap;  /* keep everything on one line */
    padding: 10px 8px;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    color: #555;
}