:root {
    --bg:          #262624;
    --surface:     #30302e;
    --border:      #3d3d3a;
    --text:        #f0eee6;
    --text-muted:  #a3a099;
    --accent:      #d97757;
    --accent-hover:#c56647;
    --danger:      #e06c5f;
    --radius:      8px;
}

* { box-sizing: border-box; }

a { color: var(--accent); }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

h1, h2 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 600;
    margin: 0;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 230px;
    height: 100%;
    padding: 20px 14px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.brand {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 17px;
    color: var(--text);
    padding: 0 10px 18px;
}

.sidebar a {
    display: block;
    padding: 10px;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 15px;
}

.sidebar a:hover { background: var(--bg); color: var(--text); }

.sidebar a.here {
    background: var(--bg);
    color: var(--accent);
    font-weight: 500;
}

.sidebar a.signout {
    margin-top: auto;
    font-size: 14px;
}

.scrim { display: none; }

.content { margin-left: 230px; }

.topbar {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar h1 { font-size: 22px; }

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 36px;
    padding: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

.hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 0 auto;
    background: var(--text);
}

.wrap {
    max-width: 860px;
    margin: 0 auto;
    padding: 16px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    margin-bottom: 20px;
}

.panel h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn {
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: var(--radius);
    padding: 10px 18px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
}

.btn:hover { background: var(--accent-hover); }

.btn-quiet {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 15px;
}

.btn-quiet:hover { color: var(--text); }

.searchbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.searchbar input { margin-bottom: 0; }

.notice {
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin: 0 0 20px;
}

.alert {
    background: var(--surface);
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin: 0 0 20px;
}

.alert p { margin: 0 0 6px; }
.alert p:last-child { margin-bottom: 0; }

.empty {
    color: var(--text-muted);
    margin: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0 0 10px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }

.row-actions { text-align: right; white-space: nowrap; }

.row-actions a {
    color: var(--accent);
    text-decoration: none;
    margin-left: 16px;
    font-size: 15px;
}

.row-actions a:hover { text-decoration: underline; }
.row-actions a.danger { color: var(--danger); }

/* ---------- mobile ---------- */
@media (max-width: 768px) {

    .hamburger { display: flex; }

    .content { margin-left: 0; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 20;
    }

    .sidebar.open { transform: translateX(0); }

    .scrim.open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 10;
    }

    .searchbar { flex-wrap: wrap; }
    .searchbar input { flex: 1 1 100%; margin-bottom: 12px; }

    thead { display: none; }

    tr {
        display: block;
        padding: 14px 0;
        border-bottom: 1px solid var(--border);
    }

    tbody tr:last-child { border-bottom: none; }

    td {
        display: flex;
        justify-content: space-between;
        gap: 16px;
        padding: 4px 0;
        border-bottom: none;
    }

    td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 14px;
    }

    .row-actions { justify-content: flex-start; padding-top: 10px; }
    .row-actions a { margin: 0 20px 0 0; }
}

/* ---------- form rows, checkbox, tags ---------- */


textarea { resize: vertical; }

.row { display: flex; gap: 12px; }
.col { flex: 1; }
.col.narrow { flex: 0 0 90px; }

.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 15px;
    margin-bottom: 16px;
}

.checkline input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    margin: 0;
}

.tag {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 7px;
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-muted);
    font-size: 12px;
}

@media (max-width: 768px) {
    .row { flex-wrap: wrap; }
    .col { flex: 1 1 100%; }
    .col.narrow { flex: 1 1 calc(50% - 6px); }
}

/* ---------- calendar ---------- */

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

.calnav {
    display: flex;
    align-items: center;
    gap: 14px;
}

.calmonth {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 19px;
    min-width: 160px;
}

.cal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.calhead {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
}

.calhead span {
    padding: 10px 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.calgrid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cell {
    min-height: 104px;
    padding: 6px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.cell:nth-child(7n) { border-right: none; }
.cell.empty { background: rgba(0, 0, 0, 0.12); }

.daynum {
    display: inline-block;
    min-width: 24px;
    padding: 2px 4px;
    margin-bottom: 4px;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
}

.daynum:hover { background: var(--bg); color: var(--text); }

.cell.today .daynum {
    background: var(--accent);
    color: #ffffff;
    text-align: center;
}

.event {
    display: block;
    padding: 4px 6px;
    margin-bottom: 4px;
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    line-height: 1.3;
}

.event:hover { border-left-color: var(--text); }
.event.hold     { border-left-color: var(--text-muted); border-left-style: dashed; }
.event.invoiced { border-left-color: #b9a06a; }
.event.paid     { border-left-color: #6a9a7b; }

.etime { display: block; color: var(--text-muted); font-size: 12px; }
.ename { display: block; }

.newvenue {
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.newvenue summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
}

.newvenue[open] summary { margin-bottom: 14px; }

.btn-quiet.danger { color: var(--danger); margin-left: auto; }

@media (max-width: 768px) {
    .calhead span { padding: 8px 4px; font-size: 11px; text-align: center; }
    .cell { min-height: 74px; padding: 3px; }
    .daynum { font-size: 12px; margin-bottom: 2px; }
    .event { padding: 2px 4px; font-size: 11px; border-left-width: 2px; }
    .etime { font-size: 10px; }
    .ename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .calmonth { min-width: 0; font-size: 17px; }
}

.venueinfo {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin: -8px 0 16px;
    font-size: 14px;
    color: var(--text-muted);
}

.venueinfo:empty { display: none; }

.venueinfo a {
    color: var(--accent);
    text-decoration: none;
}

.venueinfo a:hover { text-decoration: underline; }

/* ---------- clock ---------- */

.onclock { border-color: var(--accent); }

.eyebrow {
    margin: 0 0 4px;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
}

.onclock h2 { margin-bottom: 2px; }

.sub {
    display: block;
    color: var(--text-muted);
    font-size: 14px;
}

.elapsed {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 46px;
    line-height: 1.1;
    margin: 18px 0;
    font-variant-numeric: tabular-nums;
}

.btn.big {
    width: 100%;
    padding: 16px;
    font-size: 17px;
}

.gig {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.gig:last-child { border-bottom: none; }

.giginfo strong { display: block; margin-bottom: 2px; }

.gigactions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
}

.timeedit { display: none; margin-top: 14px; }
.timeedit.open { display: block; }

.clocked {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 0 16px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-muted);
}

.clabel {
    color: var(--accent);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.clocked a { margin-left: auto; font-size: 14px; }

/* ---------- invoices ---------- */

.lines { margin-bottom: 18px; }

.lines input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

.runtotal { margin: 0 0 20px; font-size: 15px; }
.runtotal strong { color: var(--accent); }

.invoiceactions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.paidform { display: flex; align-items: center; gap: 10px; }
.paidform input[type="date"] { margin-bottom: 0; width: auto; }

.invhead {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.invtitle {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 24px;
    margin: 0 0 2px;
}

.invfrom, .invto { display: flex; flex-direction: column; }
.invto { margin-bottom: 24px; }


.warn { color: var(--danger); }
.terms { margin-top: 20px; }

@media print {
    .sidebar, .topbar, .noprint, .scrim { display: none !important; }
    .content { margin-left: 0; }
    .wrap { max-width: none; padding: 0; }
    body { background: #ffffff; color: #000000; }
    .panel { background: #ffffff; border: none; padding: 0; }
    .sub, .clabel { color: #444444; }
    .invtotal strong, .runtotal strong { color: #000000; }
    th, td { border-color: #cccccc; }
    th { color: #444444; }
}

.pagebar {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-bottom: 12px;
}

/* ---------- invoice layout ---------- */

.bizname { font-family: 'Source Serif 4', Georgia, serif; font-size: 20px; }

.invmeta { display: flex; flex-direction: column; gap: 6px; min-width: 240px; }

.invband {
    background: var(--accent);
    color: #ffffff;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 17px;
}

.invband.light {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 14px;
    padding: 7px 14px;
}

.lines th.num, .lines td.num { text-align: right; }
.lines td { font-size: 14px; }

.invtotalband {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 0 20px;
    padding: 14px 18px;
    background: var(--accent);
    color: #ffffff;
    border-radius: var(--radius);
}

.invtotalband strong { font-size: 24px; }

.signoff { margin-top: 44px; }
.signoff p { margin: 0 0 26px; font-size: 14px; color: var(--text-muted); }

.ruled {
    display: inline-block;
    width: 320px;
    max-width: 60%;
    border-bottom: 1px solid var(--text-muted);
}

@media print {
    .invband, .invtotalband { background: #6b7a99 !important; color: #ffffff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .invband.light { background: #ffffff !important; color: #000000 !important; border: 1px solid #cccccc; }
    .signoff p { color: #000000; }
    .ruled { border-bottom-color: #000000; }
}

/* ---------- sign in ---------- */

body.plain { display: block; }

.signin {
    max-width: 380px;
    margin: 0 auto;
    padding: 12vh 16px 16px;
}

.signin .panel { padding: 28px 24px; }

.brandbig {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 24px;
    margin: 0 0 22px;
}

.signin .btn.big { margin-top: 4px; }

/* ---------- dashboard tiles ---------- */

.tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tilelabel {
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.tile strong {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 26px;
    font-weight: 600;
}

.onclock .btn.big { display: block; text-align: center; text-decoration: none; color: #ffffff; }

@media (max-width: 768px) {
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .tile strong { font-size: 22px; }
}

/* ---------- editable line tables ---------- */

.lines.editable td { padding: 6px 6px 6px 0; vertical-align: middle; }
.lines.editable th { padding-bottom: 8px; }

.lines.editable input[type="text"] {
    margin-bottom: 0;
    padding: 8px 10px;
    font-size: 14px;
}

/* the description column takes whatever is left over */
.lines.editable .colpick { width: 34px; }
.lines.editable .colqty  { width: 72px; }
.lines.editable .colrate { width: 110px; }
.lines.editable .colact  { width: 80px; }

.lines.editable input.tiny,
.lines.editable input.small { width: 100%; text-align: right; }
.lines.editable td.num { text-align: right; }
.lines.editable .row-actions a { margin-left: 12px; }

@media (max-width: 768px) {
    .lines.editable thead { display: none; }
    .lines.editable tr {
        display: block;
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
    }
    .lines.editable td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 4px 0;
    }
    .lines.editable td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 13px;
    }
    .lines.editable .colpick,
    .lines.editable .colqty,
    .lines.editable .colrate,
    .lines.editable .colact { width: auto; }

    .lines.editable input.tiny,
    .lines.editable input.small { width: 120px; }
}

/* The printed invoice table. Auto layout treats width and min-width on a
   cell as hints and spreads the slack anyway, so the table is fixed and the
   number columns get real widths. Description has none, so it takes the rest. */
.invoice .lines { table-layout: fixed; width: 100%; }

.invoice .lines .coldesc {
    padding-right: 20px;
    overflow-wrap: break-word;
}

.invoice .lines .colqty  { width: 80px; }
.invoice .lines .colrate { width: 120px; }
.invoice .lines .colamt  { width: 130px; }

@media (max-width: 768px) {
    .invoice .lines { table-layout: auto; }
    .invoice .lines .coldesc,
    .invoice .lines .colqty,
    .invoice .lines .colrate,
    .invoice .lines .colamt { width: auto; padding-left: 0; padding-right: 0; }
}

/* Edit and Delete sit together at the right of the action row */
.invoiceactions .rightside {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

.invoiceactions .rightside .btn-quiet.danger { margin-left: 0; }
