/* =============================================
   CW&T Invoice - Monospace Utilitarian Style
   ============================================= */

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

html {
    font-size: 13px;
}

body {
    font-family: 'Courier New', Courier, monospace;
    color: #000;
    background: #fff;
    line-height: 1.5;
}

a {
    color: #000;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---- Login Overlay ---- */
.login-overlay {
    position: fixed;
    inset: 0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-box {
    text-align: center;
}

.login-title {
    font-size: 2rem;
    font-weight: bold;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.login-separator {
    font-size: 1.5rem;
    margin-bottom: 2rem;
}

.login-error {
    margin-top: 1rem;
    color: #000;
    font-size: 0.85rem;
}

/* ---- Navigation ---- */
.main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid #000;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-brand {
    font-weight: bold;
    font-size: 13px;
    margin-right: 1rem;
}

.nav-link {
    color: #999;
    text-decoration: none;
    background: none;
    border: none;
    font-family: inherit;
    font-size: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
}

.nav-link:hover, .nav-link.active {
    color: #000;
    text-decoration: none;
}

.nav-btn {
    padding: 0;
}

.nav-user {
    color: #999;
    font-size: 10px;
}

/* ---- App Container ---- */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

/* ---- Hidden utility ---- */
.hidden {
    display: none !important;
}

/* ---- Buttons ---- */
.btn {
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: #000;
    color: #fff;
    border: 1px solid #000;
    padding: 0.5rem 1.25rem;
    cursor: pointer;
}

.btn:hover {
    background: #333;
}

.btn-outline {
    background: #fff;
    color: #000;
}

.btn-outline:hover {
    background: #f5f5f5;
}

.btn-small {
    padding: 0.25rem 0.75rem;
    font-size: 10px;
}

.btn-danger {
    border-color: #000;
}

.btn-danger:hover {
    background: #c00;
    color: #fff;
    border-color: #c00;
}

/* ---- Action Bar ---- */
.action-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
    align-items: center;
}

.action-bar-right {
    margin-left: auto;
    display: flex;
    gap: 0.75rem;
}

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

th {
    text-align: left;
    font-weight: bold;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #000;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

tr:hover td {
    background: #fafafa;
}

th.right, td.right {
    text-align: right;
}

th.center, td.center {
    text-align: center;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
    color: #666;
}

input, select, textarea {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    border: 1px solid #ccc;
    padding: 0.4rem 0.5rem;
    width: 100%;
    background: #fff;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #000;
}

input[readonly] {
    background: #f5f5f5;
    color: #666;
}

textarea {
    resize: vertical;
    min-height: 4rem;
}

/* ---- Status Badges ---- */
.status {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.status-paid {
    color: #090;
}

.status-unpaid {
    color: #c00;
    font-weight: bold;
}

.status-draft {
    color: #999;
}

.status-overdue {
    color: #c00;
    font-weight: bold;
}

/* Inline status dropdown in invoice list */
.inline-status {
    font-family: 'Courier New', Courier, monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: 1px solid transparent;
    background: transparent;
    padding: 0.15rem 0.25rem;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.inline-status:hover {
    border-color: #ccc;
}

.inline-status:focus {
    border-color: #000;
    outline: none;
}

/* Inline editable notes */
.inline-notes {
    cursor: text;
    min-width: 3rem;
    border-bottom: 1px dashed #ccc;
}

.inline-notes:empty::before {
    content: attr(data-placeholder);
    color: #ccc;
}

.inline-notes:focus {
    outline: none;
    border-bottom-color: #000;
}

/* Color-coded status in list */
.inline-status option[value="paid"] { color: #090; }
.inline-status option[value="unpaid"] { color: #c00; }
.inline-status option[value="draft"] { color: #999; }

/* ---- Dashboard ---- */
.stats-row {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
}

.stat-card {
    flex: 1;
}

.stat-label {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #999;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
}

.section-title {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #000;
}

.section {
    margin-bottom: 2.5rem;
}

/* ---- Invoice View (matches PDF) ---- */
.invoice-page {
    max-width: 8.5in;
    min-height: 11in;
    margin: 0 auto;
    padding: 0.75in;
    position: relative;
    font-size: 13px;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

.invoice-date {
    font-size: 13px;
    margin-bottom: 1rem;
}

.invoice-title {
    font-size: 2.5rem;
    font-weight: normal;
    margin-bottom: 0;
    line-height: 1.2;
}

.invoice-separator {
    font-size: 1.5rem;
    margin: 0.25rem 0;
}

.invoice-number-row {
    display: flex;
    gap: 2rem;
    align-items: baseline;
    margin-bottom: 0.25rem;
}

.invoice-hash {
    font-size: 1.5rem;
    font-weight: bold;
}

.invoice-number {
    font-size: 1.5rem;
}

.invoice-po {
    margin-bottom: 1.5rem;
    color: #666;
}

/* Line items table */
.invoice-table {
    width: 100%;
    flex: 1;
}

.invoice-table th {
    font-size: 12px;
    font-weight: bold;
    text-transform: none;
    letter-spacing: 0;
    padding: 0.3rem 0;
    padding-right: 1rem;
}

.invoice-table td {
    padding: 0.15rem 0;
    padding-right: 1rem;
    border-bottom: none;
    font-size: 13px;
}

.invoice-table tr:hover td {
    background: none;
}

.invoice-table .col-date { width: 15%; }
.invoice-table .col-desc { width: 40%; }
.invoice-table .col-hours { width: 12%; text-align: right; }
.invoice-table .col-bill { width: 16%; text-align: right; }
.invoice-table .col-expenses { width: 17%; text-align: right; }

.invoice-footer {
    margin-top: auto;
}

.invoice-subtotal-row {
    display: flex;
    justify-content: flex-end;
    gap: 1.5rem;
    padding: 0.25rem 0;
}

.invoice-subtotal-label {
    text-align: right;
}

.invoice-due-row {
    display: flex;
    margin: 0.25rem 0;
}

.invoice-due-label {
    width: 10%;
}

.invoice-due-date {
    width: 30%;
}

.invoice-notes-row {
    display: flex;
    margin: 0.25rem 0;
}

.invoice-notes-label {
    width: 10%;
}

.invoice-notes-text {
    flex: 1;
}

.invoice-total-row {
    display: flex;
    justify-content: flex-end;
    gap: 1.5rem;
    padding: 0.25rem 0;
    font-weight: bold;
}

.invoice-bank {
    margin-top: 2rem;
    line-height: 1.6;
}

/* ---- Invoice Edit ---- */
.line-items-table input {
    border: none;
    border-bottom: 1px solid #eee;
    padding: 0.3rem 0.25rem;
    font-size: 12px;
}

.line-items-table input:focus {
    border-bottom-color: #000;
}

.line-items-table .col-num {
    width: 3%;
    color: #ccc;
    font-size: 10px;
    text-align: center;
}

/* ---- Clickable rows ---- */
tr.clickable {
    cursor: pointer;
}

tr.clickable:hover td {
    background: #f5f5f5;
}

/* ---- Filter bar ---- */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.filter-bar select, .filter-bar input {
    width: auto;
    min-width: 120px;
}

.filter-count {
    margin-left: auto;
    font-size: 11px;
    color: #999;
}

/* ---- Import ---- */
.import-dropzone {
    border: 2px dashed #ccc;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    margin-bottom: 1.5rem;
}

.import-dropzone:hover {
    border-color: #000;
}

.import-dropzone.dragover {
    border-color: #000;
    background: #fafafa;
}

.import-preview {
    margin-top: 1.5rem;
}

/* ---- Messages ---- */
.msg {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid #000;
    font-size: 12px;
}

.msg-error {
    border-color: #c00;
}

.msg-success {
    border-color: #090;
}

/* ---- Loading ---- */
.loading {
    text-align: center;
    padding: 3rem;
    color: #999;
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #999;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .main-nav {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .nav-left, .nav-right {
        gap: 1rem;
        flex-wrap: wrap;
    }

    .stats-row {
        flex-direction: column;
        gap: 1rem;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .app-container {
        padding: 1rem;
    }

    .filter-bar {
        flex-wrap: wrap;
    }
}
