:root {
  color-scheme: light;
  --ink: #171a1f;
  --muted: #68707c;
  --line: #dce2e8;
  --soft-line: #edf1f4;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --surface-3: #eef3f6;
  --orange: #ff6900;
  --orange-dark: #ce5100;
  --teal: #00a9bd;
  --green: #12a66a;
  --blue: #3366e8;
  --shadow: 0 18px 45px rgba(18, 28, 37, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[hidden] { display: none !important; }
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: #f5f7f8; }
.login-form { display: grid; gap: 18px; width: min(100%, 390px); }
.login-form h1 { font-size: 32px; }
.login-form p { line-height: 1.5; margin: 0; }
.login-form img { object-fit: contain; }
#loginMessage, #quoteError, #notice { overflow-wrap: anywhere; }
#notice { padding: 12px; background: #e4f3ed; border-left: 3px solid #16804b; }
.workspace h1 { font-size: 30px; }
* { letter-spacing: 0 !important; }
.panel { background: transparent; border: 0; box-shadow: none; padding: 0; }
details { border-bottom: 1px solid var(--line); padding: 16px 0; }
details details { padding-left: 12px; }
summary { cursor: pointer; font-weight: 750; padding: 8px 0; }
details[open] > summary { margin-bottom: 14px; }
.service-row { display: grid; grid-template-columns: minmax(0,1fr) 140px 40px; align-items: end; gap: 10px; padding: 12px 0; }
.window-row { margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.save-bar { position: sticky; bottom: 0; padding: 16px 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; z-index: 2; }
.save-bar p { margin: 4px 0 0; font-size: 13px; }
.wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; }
.check input { width: 20px; min-height: 20px; }
.job-card { display: grid; gap: 8px; }
.job-card p { margin: 0; }
.job-dots { display: flex; gap: 3px; min-height: 8px; margin-top: 4px; flex-wrap: wrap; }
.job-dots i { display: block; width: 6px; height: 6px; border-radius: 50%; }
.day-cell small { font-size: 11px; }
.day-cell { height: 72px; min-width: 0; color: var(--ink); }
#quotePhoto { max-width: 100%; max-height: 240px; object-fit: contain; }
.filter-row { flex-wrap: wrap; }
.filter-row input,.filter-row select { flex: 1; min-width: 140px; width: auto; }
.filter-row strong { flex: 1; text-align: center; }
button:disabled { opacity: .6; cursor: wait; }
input,select,textarea { min-width: 0; }
@media(max-width:640px) {
  .service-row { grid-template-columns: minmax(0,1fr) 100px 36px; gap: 6px; }
  .filter-row { flex-direction: row; }
  .calendar-grid { gap: 3px; }
  .day-cell { padding: 4px; height: 62px; }
  .save-bar .primary-button { width: auto; }
  .nav-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media(prefers-color-scheme:dark) {
  :root { color-scheme:dark; --ink:#edf1f4; --muted:#aab4bd; --line:#454b50; --soft-line:#363b40; --surface:#202529; --surface-2:#181c20; --surface-3:#292f34; --orange-dark:#ff9d59; }
  .login-screen { background:var(--surface-2); }
  input,select,textarea,.ghost-button,.icon-button,dialog { background:var(--surface); color:var(--ink); }
  .day-cell.has-work { background:#41301f; }
  .primary-button { color:#141414; }
  #notice { background:#1c3b30; }
  a { color:#70c7e8; }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface-2);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #11161c;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-weight: 850;
  font-size: 1.2rem;
}

.brand img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  color: #dce3eb;
  background: transparent;
  text-align: left;
  padding: 12px 14px;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 105, 0, .18);
}

.sync-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  gap: 10px;
  background: rgba(255, 255, 255, .06);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  background: var(--orange);
  flex: 0 0 auto;
}

.status-dot.connected {
  background: var(--green);
}

.sync-card p {
  margin: 4px 0 0;
  color: #b7c0ca;
  font-size: .88rem;
  line-height: 1.35;
}

.workspace {
  padding: 26px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--orange-dark);
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: .78rem;
  margin: 0 0 3px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.15rem);
  line-height: 1;
}

h2 {
  font-size: 1.05rem;
  margin-bottom: 0;
}

.topbar-actions,
.dialog-actions,
.month-controls,
.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.ghost-button,
.text-button,
.icon-button {
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  border: 0;
  color: #fff;
  background: var(--orange);
  box-shadow: 0 8px 18px rgba(255, 105, 0, .22);
}

.primary-button:hover {
  background: var(--orange-dark);
}

.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.text-button {
  border: 0;
  color: var(--orange-dark);
  background: transparent;
  padding-inline: 4px;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 1.35rem;
}

.auth-panel,
.panel,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(18, 28, 37, .02);
}

.auth-panel {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px;
  margin-bottom: 20px;
}

.auth-panel.visible {
  display: flex;
}

.auth-panel p,
.muted {
  color: var(--muted);
  margin-bottom: 0;
}

.auth-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  min-height: 40px;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

.auth-form input {
  width: 190px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 20px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.metric-card span {
  color: var(--muted);
  font-weight: 750;
  font-size: .9rem;
}

.metric-card strong {
  font-size: 1.75rem;
}

.content-grid,
.schedule-layout,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 20px;
  align-items: start;
}

.settings-grid .panel:last-child {
  grid-column: 1 / -1;
}

.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.quote-list,
.job-list,
.customer-grid {
  display: grid;
  gap: 10px;
}

.quote-card,
.job-card,
.customer-card {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 13px;
  background: var(--surface-2);
}

.quote-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.quote-card button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0;
}

.quote-main,
.job-main {
  display: grid;
  gap: 4px;
}

.quote-meta,
.job-meta {
  color: var(--muted);
  font-size: .9rem;
}

.amount-stack {
  text-align: right;
  white-space: nowrap;
}

.amount-stack strong {
  display: block;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(51, 102, 232, .1);
  color: #244ebd;
  padding: 4px 9px;
  font-size: .8rem;
  font-weight: 850;
}

.status-pill.Scheduled {
  background: rgba(255, 105, 0, .12);
  color: var(--orange-dark);
}

.status-pill.Completed {
  background: rgba(18, 166, 106, .12);
  color: #08774a;
}

.status-pill.Paid {
  background: rgba(111, 66, 193, .12);
  color: #5e35a8;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--soft-line);
  padding: 12px 10px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

td button {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 850;
  padding: 0;
  text-align: left;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.weekday,
.day-cell {
  min-height: 62px;
  border-radius: 8px;
  padding: 8px;
}

.weekday {
  min-height: auto;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
  text-align: center;
}

.day-cell {
  border: 1px solid var(--soft-line);
  background: var(--surface-2);
  text-align: left;
}

.day-cell.outside {
  opacity: .35;
}

.day-cell.selected {
  border-color: var(--orange);
  box-shadow: 0 0 0 2px rgba(255, 105, 0, .16);
}

.day-cell.has-work {
  background: linear-gradient(180deg, #fff 0%, #fff2e8 100%);
}

.day-number {
  font-weight: 850;
}

.work-count {
  margin-top: 8px;
  color: var(--orange-dark);
  font-size: .78rem;
  font-weight: 850;
}

.customer-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.customer-card {
  display: grid;
  gap: 8px;
}

.customer-card strong {
  font-size: 1.05rem;
}

.customer-facts {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .9rem;
}

.settings-list {
  display: grid;
  gap: 12px;
  margin-bottom: 0;
}

.settings-list div {
  padding-top: 12px;
  border-top: 1px solid var(--soft-line);
}

.settings-list dt {
  font-weight: 850;
}

.settings-list dd {
  margin: 4px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.plain-list {
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 0;
}

dialog {
  border: 0;
  border-radius: 10px;
  padding: 0;
  width: min(820px, calc(100vw - 28px));
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(10, 14, 18, .55);
}

.quote-form {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 800;
}

.dialog-actions {
  justify-content: end;
}

.dialog-actions span {
  flex: 1;
}

.empty {
  color: var(--muted);
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.payment-preview {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
  display: grid;
  gap: 12px;
}

.payment-preview h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.payment-preview p {
  color: var(--muted);
  margin: 0;
}

.payment-button-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sync-card {
    margin-top: 0;
  }

  .metric-grid,
  .content-grid,
  .schedule-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .panel-heading,
  .auth-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .auth-form,
  .filter-row,
  .month-controls {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .nav-list,
  .form-grid,
  .payment-button-grid {
    grid-template-columns: 1fr;
  }

  .auth-form input,
  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .calendar-grid {
    gap: 5px;
  }

  .day-cell {
    min-height: 54px;
    padding: 6px;
  }
}

/* Keep these after the base form styles so dark-mode inputs remain legible. */
@media (prefers-color-scheme: dark) {
  input, select, textarea, .ghost-button, .icon-button, dialog {
    background: var(--surface);
    color: var(--ink);
  }
  .primary-button { color: #141414; }
  .day-cell.has-work { background: #41301f; }
  .quote-card button { color: var(--ink); }
}
@media (max-width: 640px) {
  .filter-row { flex-direction: row; align-items: center; }
  .filter-row .icon-button { flex: 0 0 36px; }
  .filter-row select { min-width: 100px; }
  .nav-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-grid { gap: 3px; }
  .day-cell { padding: 4px; height: 62px; }
  .save-bar .primary-button { width: auto; }
}

@media (max-width: 640px) {
  .sidebar { padding: 12px; gap: 10px; }
  .sidebar .nav-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .sidebar .nav-item { padding: 8px 5px; font-size: 12px; }
  .sidebar .sync-card { padding: 8px; }
  .sidebar .sync-card p { margin: 2px 0 0; font-size: 12px; }
}
