/* BrickHold — minimal UI styles */

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    margin: 0;
    background: #f5f5f5;
    color: #222;
}

/* ── Nav ── */
nav {
    background: #1a1a2e;
    color: #fff;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

nav .brand {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.03em;
}

nav form button {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.4);
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

nav form button:hover { background: rgba(255,255,255,0.1); }

/* ── Main layout ── */
main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

h1 { margin: 0 0 1rem; font-size: 1.4rem; }

/* ── Login form ── */
.login-wrapper {
    max-width: 360px;
    margin: 4rem auto;
    background: #fff;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.login-wrapper h1 { margin-bottom: 1.5rem; }

.login-wrapper label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 500;
}

.login-wrapper input[type="text"],
.login-wrapper input[type="password"] {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
}

.login-wrapper button[type="submit"] {
    width: 100%;
    padding: 0.6rem;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 0.5rem;
}

.login-wrapper button[type="submit"]:hover { background: #2d2d50; }

.flash-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* ── Quota strip ── */
.quota-strip {
    padding: 0.6rem 0.9rem;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.quota-strip.quota-near-target {
    background: #fef3c7;
    border-color: #fbbf24;
    color: #78350f;
}

/* ── Filters bar ── */
.filters {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* Signal-filter checkboxes — composable predicates, plan §6.2 */
.signal-filters {
    display: flex;
    gap: 0.6rem 1.1rem;
    flex-wrap: wrap;
    width: 100%;
    padding: 0.5rem 0.25rem 0;
    border-top: 1px dashed #e5e7eb;
    margin-top: 0.25rem;
    font-size: 0.85rem;
}
.signal-filters label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    user-select: none;
}
@media (max-width: 768px) {
    .signal-filters { gap: 0.5rem; font-size: 0.8rem; }
}

.filters select,
.filters input[type="search"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    background: #fff;
}

.filters label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    cursor: pointer;
}

/* ── Inventory table ── */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

thead tr { background: #1a1a2e; color: #fff; }
thead th { padding: 0.65rem 0.75rem; text-align: left; font-weight: 600; font-size: 0.85rem; }

tbody tr:nth-child(even) { background: #fafafa; }
tbody tr:hover { background: #f0f4ff; }
tbody tr.sell-signal { background: #fde8e8; }
tbody tr.sell-signal:hover { background: #fcd0d0; }
td { padding: 0.55rem 0.75rem; vertical-align: middle; }

td img { display: block; border-radius: 3px; }

td small { color: #777; font-size: 0.8rem; }

/* ── GP coloring ── */
.gp-positive { color: #15803d; font-weight: 600; }
.gp-negative { color: #b91c1c; font-weight: 600; }

/* ── Sort headers ── */
th.sort-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.sort-header:hover { background: #2d2d50; }
th.sort-active { background: #2d2d50; }

/* ── Status badges ── */
.retiring {
    display: inline-block;
    background: #fef9c3;
    border: 1px solid #fbbf24;
    color: #92400e;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    white-space: nowrap;
}

.badge-retired {
    display: inline-block;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    white-space: nowrap;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #888;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

/* ── HTMX loading indicator ── */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* ── Make-decision row button ── */
.btn-decision {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-decision:hover { background: #2d2d50; }

.hold-pill {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 700;
    background: #FFCE00;
    color: #1a1a2e;
    border: none;
    border-radius: 4px;
    white-space: nowrap;
    margin-right: 0.35rem;
}
.hold-pill-due {
    background: #dc2626;
    color: #fff;
}

/* ── Decision-entry modal (plan §6.3, responsive 375px+) ── */
.decision-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}
.decision-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    padding: 1.5rem;
    z-index: 100;
    width: min(95vw, 720px);
    max-height: 90vh;
    overflow-y: auto;
}
.decision-modal h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.decision-modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
}
.decision-modal-close:hover { color: #000; }

.decision-context {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 1rem;
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 6px;
    margin-bottom: 1rem;
}
.decision-thumb { width: 80px; height: 80px; object-fit: contain; }
.decision-set-name { font-weight: 600; font-size: 1rem; }
.decision-set-id { color: #666; font-size: 0.85rem; margin-bottom: 0.5rem; }
.decision-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.2rem 0.75rem;
    font-size: 0.85rem;
    margin: 0;
}
.decision-facts dt { color: #666; }
.decision-facts dd { margin: 0; font-weight: 500; }
.flag-warn { color: #b91c1c; font-weight: 600; }

.decision-badges {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #666;
}
.decision-badge {
    display: inline-block;
    background: #dbeafe;
    color: #1e3a8a;
    border-radius: 10px;
    padding: 0.1rem 0.55rem;
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

.decision-field {
    display: block;
    margin-bottom: 0.85rem;
}
.decision-field > span {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: #333;
}
.decision-field select,
.decision-field input[type="number"],
.decision-field textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    box-sizing: border-box;
}

.decision-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}
.btn-primary,
.btn-secondary {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    min-height: 44px;
}
.btn-primary { background: #1a1a2e; color: #fff; }
.btn-primary:hover { background: #2d2d50; }
.btn-secondary { background: #e5e7eb; color: #1f2937; }
.btn-secondary:hover { background: #d1d5db; }

.decision-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

/* Phone viewport: single-column stack, smaller padding */
@media (max-width: 768px) {
    .decision-modal { padding: 1rem; width: 95vw; }
    .decision-context {
        grid-template-columns: 1fr;
    }
    .decision-thumb { width: 64px; height: 64px; }
    .decision-facts { grid-template-columns: auto 1fr; font-size: 0.8rem; }
    .decision-actions { flex-direction: column-reverse; }
    .btn-primary, .btn-secondary { width: 100%; }
}

/* ── Nav + Quick-log entry points ── */
.nav-links { margin-left: 1rem; display: inline-flex; gap: 1rem; }
.nav-links a {
    color: #fff;
    text-decoration: none;
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    font-size: 0.9rem;
}
.nav-links a:hover { background: rgba(255,255,255,0.15); }

.quick-log-fab {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 56px; height: 56px;
    background: #1a1a2e;
    color: #fff;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 300;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 50;
}
.quick-log-fab:hover { background: #2d2d50; }

@media (max-width: 768px) {
    .quick-log-fab { display: flex; }
}

/* ── Quick-log page ── */
.quick-log-intro {
    color: #555;
    margin-top: -0.5rem;
    margin-bottom: 1.25rem;
    max-width: 60ch;
}
.quick-log-form {
    max-width: 520px;
    background: #fff;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.quick-log-form select,
.quick-log-form input,
.quick-log-form textarea {
    width: 100%;
    padding: 0.55rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    min-height: 44px;
    font-family: inherit;
    box-sizing: border-box;
    background: #fff;
}
.quick-log-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.quick-log-success {
    background: #d1fae5;
    border: 1px solid #6ee7b7;
    color: #065f46;
    padding: 0.65rem 0.9rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .quick-log-form { padding: 1rem; }
    .quick-log-row { grid-template-columns: 1fr; }
}

/* ── Decisions list + detail ── */
.decision-type-pill {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.decision-type-list { background: #dbeafe; color: #1e3a8a; }
.decision-type-hold { background: #fef3c7; color: #78350f; }
.decision-type-write_off { background: #fee2e2; color: #991b1b; }

.decision-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1rem 0;
}
.decision-card {
    background: #fff;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.decision-card h2 { font-size: 1rem; margin: 0 0 0.75rem; }

.decision-notes { list-style: none; padding: 0; margin: 0 0 1rem; }
.decision-notes li {
    border-left: 3px solid #60a5fa;
    background: #f9fafb;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 3px;
}
.note-ts { color: #666; font-size: 0.8rem; }
.note-body { white-space: pre-wrap; margin-top: 0.2rem; }
.note-form { display: flex; gap: 0.5rem; align-items: flex-start; }
.note-form textarea {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
}

.empty-state-inline { color: #888; font-style: italic; }

@media (max-width: 768px) {
    .decision-detail-grid { grid-template-columns: 1fr; }
    .note-form { flex-direction: column; }
    .note-form textarea { width: 100%; }
}

/* ── Analysis — quota pacer ── */
.pacer-numbers {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}
.pacer-big { font-size: 2.5rem; font-weight: 700; color: #1a1a2e; }
.pacer-of { font-size: 1.25rem; color: #666; }
.pacer-label { color: #666; margin-left: 0.5rem; }
.pacer-bar {
    position: relative;
    height: 14px;
    background: #e5e7eb;
    border-radius: 7px;
    overflow: visible;
    margin-bottom: 0.6rem;
}
.pacer-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #1e40af);
    border-radius: 7px;
    transition: width 0.3s;
}
.pacer-expected {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    background: #dc2626;
}
.pacer-expected::after {
    content: 'expected';
    position: absolute;
    bottom: -1.2rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: #dc2626;
    white-space: nowrap;
}
.pacer-caption { color: #555; font-size: 0.9rem; margin: 1.25rem 0 0; }
