:root{font-family:system-ui,-apple-system,sans-serif;color:#16202b;background:#f5f7fb}*{box-sizing:border-box}body{margin:0}header{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:1rem max(1rem,calc((100vw - 1100px)/2));background:#fff;border-bottom:1px solid #e2e8f0}header nav{display:flex;align-items:center;gap:1rem;flex-wrap:wrap}a{color:#1d4ed8;text-decoration:none}a:hover{text-decoration:underline}.brand{font-size:1.15rem;font-weight:800;color:#16202b}main{max-width:1100px;margin:2rem auto;padding:0 1rem}.title{display:flex;justify-content:space-between;align-items:center;gap:1rem}h1{margin:.2rem 0 1.5rem;font-size:2rem}h2{font-size:1.15rem;margin-top:0}.card{background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:1.5rem;margin-bottom:1rem;box-shadow:0 2px 8px #1826350b}.narrow{max-width:560px}.auth{display:grid;place-items:center;min-height:100vh}.auth main{width:min(100%,560px)}label{display:block;font-weight:600;margin:0 0 1rem}input,textarea,select{display:block;width:100%;font:inherit;padding:.62rem;border:1px solid #cbd5e1;border-radius:7px;margin-top:.35rem;background:#fff}textarea{min-height:75px}button,.button{display:inline-block;border:0;border-radius:7px;background:#1d4ed8;color:#fff;font:inherit;font-weight:650;padding:.65rem 1rem;cursor:pointer}.button:hover,button:hover{background:#1e40af;color:#fff;text-decoration:none}.button.secondary,button.secondary{background:#eaf0ff;color:#1d4ed8}.link{background:transparent;color:#1d4ed8;padding:0}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:1rem}.table-wrap{overflow:auto}table{border-collapse:collapse;width:100%;white-space:nowrap}th,td{text-align:left;padding:.7rem;border-bottom:1px solid #e2e8f0}td input{min-width:100px;margin:0}td:first-child input{min-width:260px}.actions{display:flex;gap:.75rem;align-items:center;flex-wrap:wrap;margin-top:1.2rem}.badge{background:#eaf0ff;color:#1d4ed8;border-radius:99px;padding:.3rem .7rem;font-weight:700}.hint,.error{color:#a32626}small{display:block;color:#64748b;font-weight:400;margin-top:.25rem}@media(max-width:600px){header{align-items:flex-start;flex-direction:column}h1{font-size:1.6rem}.card{padding:1rem}}

/* Customer directory and shared add/edit dialog */
.customer-title{align-items:flex-start;margin-bottom:1.25rem}
.customer-title h1{margin:0 0 .2rem}
.customer-subtitle{margin:0;color:#64748b}
.customer-list{padding:.35rem 1.5rem}
.customer-empty{padding:2rem .25rem}
.customer-empty p{margin:.4rem 0 0;color:#64748b}
.customers-table{table-layout:fixed;white-space:normal}
.customers-table th,.customers-table td{padding:.9rem .65rem;vertical-align:middle;overflow-wrap:anywhere}
.customers-table tbody tr:last-child td{border-bottom:0}
.customers-table th:first-child,.customers-table td:first-child{padding-left:0}
.customers-table th:last-child,.customers-table td:last-child{padding-right:0}
.customers-table th:nth-child(1){width:27%}
.customers-table th:nth-child(2){width:10%}
.customers-table th:nth-child(3){width:20%}
.customers-table th:nth-child(4){width:14%}
.customers-table th:nth-child(5){width:17%}
.customers-table th:nth-child(6){width:12%}
.customer-name{font-weight:650}
.customer-actions-heading,.customer-action-cell{text-align:right}
.customer-edit{white-space:nowrap;padding:.48rem .8rem}
.customer-dialog{width:min(640px,calc(100vw - 2rem));max-height:min(88vh,840px);padding:0;border:1px solid #d9e2ef;border-radius:14px;color:#16202b;background:#fff;box-shadow:0 24px 70px #16202b40;overflow:hidden}
.customer-dialog::backdrop{background:#16202b99}
.customer-dialog form{display:flex;flex-direction:column;max-height:min(88vh,840px)}
.modal-header{display:flex;justify-content:space-between;align-items:flex-start;gap:1rem;padding:1.2rem 1.5rem;border-bottom:1px solid #e2e8f0}
.modal-header h2{margin:0 0 .2rem;font-size:1.3rem}
.modal-header p{margin:0;color:#64748b}
.modal-close{flex:none;background:transparent;color:#64748b;font-size:1.65rem;line-height:1;padding:.1rem .35rem}
.modal-close:hover{background:#f1f5f9;color:#16202b}
.modal-body{overflow-y:auto;padding:1.25rem 1.5rem .35rem}
.modal-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem}
.modal-actions{display:flex;justify-content:flex-end;gap:.75rem;padding:1rem 1.5rem;border-top:1px solid #e2e8f0;background:#fff}
@media(max-width:700px){
  .customer-title{align-items:flex-start}
  .customer-title button{white-space:nowrap}
  .customer-list{padding:.25rem 1rem}
  .customers-table,.customers-table tbody{display:block}
  .customers-table thead{display:none}
  .customers-table tr{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.3rem 1rem;padding:.9rem 0;border-bottom:1px solid #e2e8f0}
  .customers-table tbody tr:last-child{border-bottom:0}
  .customers-table td{display:block;border:0;padding:0!important;text-align:left}
  .customers-table td:not(:first-child):not(:last-child){grid-column:1/-1;color:#475569;font-size:.9rem}
  .customers-table td:not(:first-child):not(:last-child)::before{content:attr(data-label) ': ';font-weight:650;color:#16202b}
  .customers-table td:last-child{grid-column:2;grid-row:1;align-self:center;text-align:right}
  .modal-grid{grid-template-columns:1fr;gap:0}
}
@media(max-width:420px){
  .customer-title{flex-wrap:wrap}
  .customer-title button{width:100%}
  .modal-header,.modal-body,.modal-actions{padding-left:1rem;padding-right:1rem}
}
.invoice-actions .delete-draft-form{margin-left:auto}
button.danger{background:#fff;color:#b42318;border:1px solid #f2b8b5}
button.danger:hover{background:#fef3f2;color:#912018}
@media(max-width:600px){.invoice-actions .delete-draft-form{margin-left:0}}

/* Shared navigation */
.site-header{display:block;padding:0;background:#fff}
.site-header-inner{max-width:1100px;margin:auto;padding:.7rem 1rem;display:flex;align-items:center;gap:1.5rem}
.site-header .brand{white-space:nowrap}
.site-workspace{min-width:0;max-width:280px;color:#64748b;font-size:.88rem}
.site-workspace>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.site-workspace form{display:flex;align-items:center;gap:.45rem}
.site-workspace label{margin:0;white-space:nowrap;font-weight:500}
.site-workspace select{margin:0;padding:.35rem 1.5rem .35rem .45rem;min-width:0;max-width:200px;font-size:.88rem}
.site-nav{margin-left:auto;gap:.15rem;flex-wrap:nowrap}
.site-nav a,.site-nav .site-signout{display:inline-block;padding:.5rem .65rem;border-radius:7px;white-space:nowrap;font-size:.94rem;font-weight:500}
.site-nav a:hover,.site-nav .site-signout:hover{background:#f1f5f9;color:#1d4ed8;text-decoration:none}
.site-nav a.active{background:#eaf0ff;color:#1d4ed8;font-weight:700}
.site-nav form{margin:0}
.site-nav .site-signout{background:transparent;color:#64748b}
@media(max-width:850px){
  .site-header-inner{flex-wrap:wrap;gap:.45rem 1rem}
  .site-workspace{margin-left:auto}
  .site-nav{width:100%;margin-left:0;flex-wrap:wrap}
}
@media(max-width:600px){
  .site-header{display:block}
  .site-header-inner{position:relative;display:grid;grid-template-columns:1fr auto;padding:.7rem 1rem;gap:.2rem}
  .site-header .brand{grid-column:1;display:flex;align-items:center;min-height:2.3rem}
  .site-workspace{grid-column:1/-1;margin:0;max-width:100%;padding:.1rem 0}
  .site-nav{grid-column:1/-1;display:flex;justify-content:space-between;gap:0;padding-top:.15rem}
  .site-nav form{position:absolute;right:1rem;top:.55rem}
  .site-nav a{padding:.4rem .3rem;font-size:.88rem}
  .site-nav .site-signout{padding:.45rem .55rem}
}
.admin-intro{color:#64748b;max-width:700px}
.admin-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem}
.form-error{color:#a32626;background:#fff1f0;border:1px solid #f2b8b5;border-radius:7px;padding:.65rem .8rem;font-weight:600;margin:.5rem 0 1rem}
.form-error[hidden]{display:none}
input[aria-invalid="true"]{border-color:#a32626;outline:2px solid #f2b8b5}
html[data-theme="dark"] .form-error{color:#ffd6d4;background:#49303a;border-color:#80505a}
.admin-grid .card{min-width:0}
.admin-note{color:#64748b;margin-top:0}
.profile-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem}
.profile-help{color:#64748b;line-height:1.45}
.profile-success{color:#166534;font-weight:600}
.profile-error{color:#a32626;font-weight:600}
@media(max-width:750px){.profile-grid{grid-template-columns:1fr}}
@media(max-width:750px){.admin-grid{grid-template-columns:1fr}}
@media(max-width:600px){
  .admin-workspaces,.admin-workspaces tbody{display:block;white-space:normal}
  .admin-workspaces thead{display:none}
  .admin-workspaces tr{display:block;padding:.65rem 0;border-bottom:1px solid #e2e8f0}
  .admin-workspaces tr:last-child{border-bottom:0}
  .admin-workspaces td{display:block;border:0;padding:.2rem 0;overflow-wrap:anywhere}
  .admin-workspaces td::before{content:attr(data-label) ': ';font-weight:700}
}

/* The app theme affects HTML only; invoice PDFs are rendered separately. */
.theme-toggle{flex:none;min-width:2.2rem;padding:.42rem .55rem;border:1px solid #cbd5e1;background:transparent;color:#475569;font-size:1.1rem;line-height:1.2}
.theme-toggle:hover{background:#f1f5f9;color:#1d4ed8}
.auth-theme-toggle{position:fixed;top:1rem;right:1rem}
.site-nav .theme-toggle{margin-left:.2rem}
@media(max-width:600px){
  .site-nav .theme-toggle{position:absolute;right:6.5rem;top:.55rem;margin:0}
}
:focus-visible{outline:2px solid #1d4ed8;outline-offset:2px}
html[data-theme="dark"]{color-scheme:dark;color:#e5edf7;background:#0d1523}
html[data-theme="dark"] body{background:#0d1523}
html[data-theme="dark"] header,
html[data-theme="dark"] .site-header,
html[data-theme="dark"] .card,
html[data-theme="dark"] .customer-dialog,
html[data-theme="dark"] .modal-actions{background:#172235;border-color:#34445b;color:#e5edf7}
html[data-theme="dark"] .card{box-shadow:0 2px 12px #0002}
html[data-theme="dark"] .brand{color:#f4f7fb}
html[data-theme="dark"] a{color:#a8c5ff}
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select{background:#101a2b;border-color:#4b5d78;color:#e5edf7}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder{color:#91a2b9}
html[data-theme="dark"] th,
html[data-theme="dark"] td,
html[data-theme="dark"] .customers-table tr,
html[data-theme="dark"] .admin-workspaces tr,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-actions{border-color:#34445b}
html[data-theme="dark"] small,
html[data-theme="dark"] .customer-subtitle,
html[data-theme="dark"] .customer-empty p,
html[data-theme="dark"] .admin-intro,
html[data-theme="dark"] .admin-note,
html[data-theme="dark"] .site-workspace,
html[data-theme="dark"] .modal-header p{color:#afbed2}
html[data-theme="dark"] .customers-table td:not(:first-child):not(:last-child){color:#c5d0df}
html[data-theme="dark"] .customers-table td:not(:first-child):not(:last-child)::before{color:#e5edf7}
html[data-theme="dark"] button,
html[data-theme="dark"] .button{background:#315fd5;color:#fff}
html[data-theme="dark"] button:hover,
html[data-theme="dark"] .button:hover{background:#4371e2;color:#fff}
html[data-theme="dark"] button.secondary,
html[data-theme="dark"] .button.secondary,
html[data-theme="dark"] .badge,
html[data-theme="dark"] .site-nav a.active{background:#263d62;color:#b9d0ff}
html[data-theme="dark"] .site-nav a:hover,
html[data-theme="dark"] .site-nav .site-signout:hover,
html[data-theme="dark"] .theme-toggle:hover,
html[data-theme="dark"] .modal-close:hover{background:#263d62;color:#dce8ff}
html[data-theme="dark"] .site-nav .site-signout,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .modal-close{background:transparent;color:#afbed2}
html[data-theme="dark"] .theme-toggle{border-color:#4b5d78}
html[data-theme="dark"] .hint,
html[data-theme="dark"] .error{color:#ffaaa5}
html[data-theme="dark"] button.danger{background:#2d1d26;border-color:#80505a;color:#ffc1bf}
html[data-theme="dark"] button.danger:hover{background:#49303a;color:#ffd6d4}
html[data-theme="dark"] .customer-dialog::backdrop{background:#050a12b3}
html[data-theme="dark"] :focus-visible{outline-color:#a8c5ff}
button:disabled{opacity:.5;cursor:not-allowed}
.invoice-line-table{table-layout:fixed;min-width:980px;white-space:normal}
.invoice-line-table th:nth-child(1){width:29%}
.invoice-line-table th:nth-child(2){width:12%}
.invoice-line-table th:nth-child(3){width:12%}
.invoice-line-table th:nth-child(4){width:10%}
.invoice-line-table th:nth-child(5){width:11%}
.invoice-line-table th:nth-child(6){width:17%}
.invoice-line-table th:nth-child(7){width:9%}
.invoice-line-table td{padding:.6rem .35rem}
.invoice-line-table td input,.invoice-line-table td:first-child input{min-width:0}
.invoice-line-table .remove-line{padding:.48rem .55rem;font-size:.9rem}
.invoice-form-add-line{margin:.8rem 0 1.35rem}
@media(max-width:700px){
  .invoice-line-table,.invoice-line-table tbody{display:block;min-width:0;white-space:normal}
  .invoice-line-table thead{display:none}
  .invoice-line-table tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.6rem .75rem;padding:1rem 0;border-bottom:1px solid #e2e8f0}
  .invoice-line-table tr:last-child{border-bottom:0}
  .invoice-line-table td{display:block;border:0;padding:0}
  .invoice-line-table td::before{content:attr(data-label);display:block;font-weight:600;margin-bottom:.2rem}
  .invoice-line-table td:first-child,.invoice-line-table td:nth-child(6),.invoice-line-table td:last-child{grid-column:1/-1}
  .invoice-line-table td:last-child::before{display:none}
  .invoice-line-table td input,.invoice-line-table td select{margin-top:0}
  .invoice-line-table td:last-child{text-align:right}
}
html[data-theme="dark"] .invoice-line-table tr{border-color:#34445b}
