@import url("/fonts.css");
:root {
  --navy: #103f60;
  --blue: #096b9d;
  --blue-pale: #eaf4fa;
  --ink: #192f42;
  --muted: #65778a;
  --line: #dce5ed;
  --bg: #f4f7fa;
  --green: #136f59;
  --red: #b83e45;
  --amber: #966113;
  --white: #fff;
  --radius: 12px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    16px/1.65 "Noto Sans Bengali",
    "Hind Siliguri",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
a {
  color: var(--blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #58aedb;
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
.wordmark {
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 700;
  font-size: 19px;
  line-height: 1.3;
}
.brand-mark {
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: white;
  border-radius: 13px;
  font: 700 31px/1 Arial;
}
.wordmark small {
  display: block;
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 500;
  opacity: 0.7;
  margin-top: 5px;
}
#sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 246px;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 30px 19px 20px;
  z-index: 20;
}
#sidebar .wordmark {
  padding: 0 10px 28px;
}
#sidebar .brand-mark {
  background: #ffffff1a;
}
nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.nav-item {
  display: flex;
  gap: 12px;
  align-items: center;
  color: #d6e6f0;
  background: transparent;
  border: 0;
  text-align: left;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
}
.nav-item:hover {
  background: #ffffff0c;
}
.nav-item.active {
  background: #fff;
  color: var(--navy);
  font-weight: 600;
}
.nav-icon {
  width: 23px;
  font-family: system-ui;
  text-align: center;
  font-size: 19px;
}
.sidebar-bottom {
  margin-top: auto;
  padding: 24px 12px 0;
  font-size: 14px;
  color: #c8dde9;
}
.sidebar-bottom span {
  display: block;
  word-break: break-word;
  margin-bottom: 12px;
}
.quiet {
  display: block;
  background: none;
  border: 0;
  color: inherit;
  padding: 5px 0;
  text-align: left;
  font-size: 13px;
}
.workspace {
  margin-left: 246px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 36px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.global-search {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  flex: 1;
}
.global-search span {
  font-size: 26px;
  color: var(--muted);
}
.global-search input {
  border: none;
  background: transparent;
  width: 100%;
  outline-offset: 4px;
  min-width: 0;
}
.global-search button {
  background: var(--blue-pale);
  border: 0;
  color: var(--blue);
  padding: 7px 16px;
  border-radius: 7px;
  white-space: nowrap;
  font-size: 14px;
}
.today-label {
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}
main#main {
  padding: 30px 36px 40px;
  max-width: 1800px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 1.7px;
  text-transform: uppercase;
  color: var(--blue);
  font-weight: 700;
  margin-bottom: 5px;
}
h1 {
  font-size: 27px;
  line-height: 1.4;
  letter-spacing: -0.5px;
  margin: 0;
  font-weight: 650;
}
h2 {
  font-size: 20px;
  line-height: 1.5;
  margin: 0 0 16px;
}
h3 {
  font-size: 16px;
  margin: 0 0 10px;
}
.sub {
  color: var(--muted);
  font-size: 14px;
  margin: 7px 0 0;
}
.actions,
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.btn {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 9px 15px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg);
  text-decoration: none;
}
.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}
.btn.primary:hover {
  background: #075783;
}
.btn.danger {
  color: var(--red);
  border-color: #e6c8cb;
}
.btn.small {
  padding: 5px 9px;
  font-size: 12px;
}
.btn.block {
  width: 100%;
}
.icon-btn {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 25px;
  min-width: 38px;
  min-height: 38px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0 26px;
}
.stat {
  padding: 20px 22px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
}
.stat.featured {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}
.stat-label {
  color: var(--muted);
  font-size: 13px;
}
.featured .stat-label {
  color: #c2dce9;
}
.stat-value {
  font-size: 29px;
  letter-spacing: -0.7px;
  font-weight: 650;
  margin: 7px 0 4px;
  font-variant-numeric: tabular-nums;
}
.stat-note {
  font-size: 12px;
  color: var(--muted);
}
.featured .stat-note {
  color: #c2dce9;
}
.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.panel-head {
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2,
.panel-head h3 {
  margin: 0;
}
.panel-body {
  padding: 22px;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  white-space: normal;
  font-size: 14px;
}
th {
  text-align: left;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.2px;
  font-weight: 550;
  padding: 13px 18px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 15px 18px;
  border-bottom: 1px solid #eaf0f4;
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: #fbfdff;
}
td.number {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
th.number {
  text-align: right;
}
.name-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink);
  font-weight: 650;
  text-align: left;
}
.name-link:hover {
  color: var(--blue);
}
.secondary {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.badge {
  display: inline-block;
  padding: 3px 9px;
  font-size: 12px;
  border-radius: 5px;
  background: var(--blue-pale);
  color: var(--blue);
  white-space: nowrap;
}
.badge.green {
  background: #e7f4ee;
  color: var(--green);
}
.badge.red {
  background: #fdecee;
  color: var(--red);
}
.badge.amber {
  background: #fff3df;
  color: var(--amber);
}
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty strong {
  display: block;
  color: var(--ink);
  font-size: 17px;
  margin-bottom: 8px;
}
.split {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 22px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}
.field > span {
  font-size: 13px;
  font-weight: 550;
}
.field input,
.field select,
.field textarea,
input.control,
select.control {
  width: 100%;
  border: 1px solid #cbd7e1;
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 44px;
  font-size: 15px;
}
.field textarea {
  min-height: 90px;
  resize: vertical;
}
.field small {
  color: var(--muted);
  font-size: 12px;
}
.check {
  display: flex;
  gap: 9px;
  align-items: center;
  font-size: 14px;
  margin: 14px 0;
}
.check input {
  width: 18px;
  height: 18px;
}
.full {
  grid-column: 1/-1;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.form-error {
  padding: 10px 14px;
  background: #fff0f1;
  color: #982e37;
  border-radius: 7px;
  font-size: 14px;
  margin: 14px 0;
}
.notice {
  padding: 12px 16px;
  background: var(--blue-pale);
  color: #285e7d;
  font-size: 13px;
  border-radius: 8px;
  margin-bottom: 18px;
}
.warning {
  background: #fff4e1;
  color: #89601f;
}
.tabs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.tab {
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 12px 15px;
  color: var(--muted);
  font-size: 14px;
}
.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 600;
}
.patient-banner {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}
.avatar {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  background: var(--blue-pale);
  color: var(--blue);
  border-radius: 18px;
  font-size: 28px;
  font-weight: 650;
  flex-shrink: 0;
}
.patient-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}
.patient-banner .actions {
  margin-left: auto;
}
.definition {
  display: grid;
  grid-template-columns: 145px 1fr;
  gap: 10px;
  font-size: 14px;
  margin: 0;
}
.definition dt {
  color: var(--muted);
}
.definition dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.timeline {
  padding: 0 22px;
}
.timeline-item {
  border-left: 2px solid var(--line);
  padding: 0 0 25px 22px;
  margin-left: 5px;
}
.timeline-item:last-child {
  padding-bottom: 0;
}
.timeline-item h3 {
  margin-bottom: 7px;
}
.timeline-item p {
  margin: 7px 0;
  font-size: 14px;
  white-space: pre-wrap;
}
.teeth {
  display: grid;
  grid-template-columns: repeat(16, minmax(27px, 1fr));
  gap: 5px;
  margin: 16px 0;
}
.tooth {
  border: 1px solid #c9d8e2;
  min-height: 39px;
  border-radius: 9px 9px 13px 13px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}
.tooth.marked {
  background: #d7edf8;
  border-color: var(--blue);
  color: var(--navy);
}
.tooth.selected {
  outline: 2px solid var(--blue);
}
.item-editor {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px;
  margin: 12px 0;
  background: #fbfdff;
}
.item-editor .grid-2 {
  gap: 12px;
}
.item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.file-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.file-card img {
  width: 100%;
  height: 145px;
  object-fit: cover;
  background: #eef3f7;
}
.file-card .file-label {
  padding: 12px;
  overflow-wrap: anywhere;
  font-size: 13px;
}
.file-placeholder {
  display: grid;
  place-items: center;
  height: 100px;
  background: var(--blue-pale);
  font-size: 30px;
  color: var(--blue);
}
.app-footer {
  padding: 15px 36px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
}
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: linear-gradient(140deg, #e9f1f7 0%, #f9fbfd 60%, #dcecf6 100%);
}
.auth-card {
  max-width: 440px;
  width: 100%;
  background: white;
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 20px 80px #103f600b;
}
.auth-card .wordmark {
  margin-bottom: 34px;
}
.auth-card h1 {
  font-size: 25px;
  margin-bottom: 9px;
}
.auth-card .field {
  margin-top: 18px;
}
.auth-foot {
  font-size: 13px;
  color: var(--muted);
}
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 22px 90px #103f6030;
  max-width: 760px;
  width: calc(100% - 32px);
  max-height: 90vh;
  padding: 0;
  color: var(--ink);
}
dialog.wide {
  max-width: 1040px;
}
dialog::backdrop {
  background: #102f4c70;
  backdrop-filter: blur(3px);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 19px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: white;
  z-index: 2;
}
.modal-head h2 {
  margin: 0;
}
#modal-content {
  padding: 24px;
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: #123d58;
  color: white;
  padding: 12px 22px;
  border-radius: 9px;
  box-shadow: 0 5px 30px #103f6030;
  max-width: 90vw;
}
.mobile-only {
  display: none;
}
.loading {
  padding: 50px;
  text-align: center;
  color: var(--muted);
}
.balance-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  font-size: 14px;
}
.muted {
  color: var(--muted);
}
.space-top {
  margin-top: 18px;
}
.danger-text {
  color: var(--red);
}
.positive {
  color: var(--green);
}
.toolbar input[type="date"] {
  width: 165px;
}
.toolbar select {
  width: auto;
  max-width: 230px;
}
@media (max-width: 1180px) {
  #sidebar {
    width: 215px;
    padding-left: 12px;
    padding-right: 12px;
  }
  .workspace {
    margin-left: 215px;
  }
  main#main {
    padding: 25px 24px;
  }
  .topbar {
    padding: 18px 24px;
  }
  .stats {
    gap: 12px;
  }
  .stat {
    padding: 17px;
  }
  .stat-value {
    font-size: 25px;
  }
  .split {
    grid-template-columns: 1fr;
  }
  .page-head {
    flex-wrap: wrap;
  }
}
@media (max-width: 800px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s;
    width: 246px;
  }
  #sidebar.open {
    transform: translateX(0);
  }
  .workspace {
    margin-left: 0;
  }
  .mobile-only {
    display: block;
  }
  .topbar {
    padding: 12px 16px;
    gap: 12px;
    height: 72px;
  }
  .today-label {
    display: none;
  }
  main#main {
    padding: 22px 16px;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .full {
    grid-column: auto;
  }
  .patient-banner {
    flex-wrap: wrap;
  }
  .patient-banner .actions {
    margin-left: 0;
  }
  .app-footer {
    padding: 14px 16px;
  }
  h1 {
    font-size: 24px;
  }
  td,
  th {
    padding: 12px;
  }
  .teeth {
    grid-template-columns: repeat(8, minmax(27px, 1fr));
  }
  .auth-card {
    padding: 26px;
  }
  #modal-content {
    padding: 18px;
  }
  .definition {
    grid-template-columns: 100px 1fr;
  }
  .stat-value {
    font-size: 23px;
  }
  .stat {
    padding: 14px;
  }
  .global-search input {
    font-size: 14px;
  }
  .tabs {
    gap: 0;
  }
  .tab {
    padding: 10px;
    font-size: 13px;
  }
  .btn {
    min-height: 42px;
  }
  .btn.small {
    min-height: 36px;
  }
}

/* v1.1: a clear, repeatable bill → payment → receipt flow. */
.brand-logo {
  width: 56px;
  height: 68px;
  object-fit: contain;
  flex: 0 0 auto;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
}
.wordmark small {
  letter-spacing: 0;
  font-size: 11px;
  line-height: 1.6;
}
#sidebar .wordmark {
  gap: 10px;
  padding-left: 0;
  padding-right: 0;
  font-size: 17px;
}
.money-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.money-summary .stat {
  border-top: 3px solid #1b77c5;
}
.money-summary .stat:nth-child(2) {
  border-top-color: #14886a;
}
.money-summary .stat:nth-child(2) .stat-value {
  color: #136f59;
}
.money-summary .stat.featured {
  background: #fff8ef;
  color: #754513;
  border: 1px solid #ecd6b6;
  border-top: 3px solid #be7823;
}
.money-summary .stat.featured .stat-label,
.money-summary .stat.featured .stat-note {
  color: #805b30;
}
.money-summary .stat-value {
  font-size: clamp(22px, 2.6vw, 32px);
  overflow-wrap: anywhere;
}
.advanced-options {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  padding: 12px 15px;
}
.advanced-options summary {
  cursor: pointer;
  color: #24567b;
  font-weight: 600;
}
.advanced-options[open] summary {
  margin-bottom: 14px;
}
.payment-preview {
  border: 1px solid #bedcca;
  background: #f1faf5;
  border-radius: 12px;
  padding: 16px 20px;
  margin: 16px 0;
}
.payment-preview > span {
  font-weight: 600;
  color: #226342;
}
.preview-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}
.preview-row strong {
  display: block;
  color: #164b36;
  font-size: 25px;
}
.payment-preview p {
  margin: 8px 0;
}
.payment-preview small {
  display: block;
  color: #4d695c;
  margin-top: 8px;
}
.invoice-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 16px 20px;
  background: #edf5fc;
  border-radius: 10px;
  margin: 18px 0;
}
.invoice-total strong {
  font-size: 27px;
  color: #145f98;
}
#modal .money-summary {
  gap: 8px;
}
#modal .money-summary .stat {
  padding: 12px;
}
#modal .money-summary .stat-value {
  font-size: 22px;
}
#modal .money-summary .stat-note {
  font-size: 11px;
}
.payment-entry input[name="amount"] {
  font-size: 23px;
  font-weight: 600;
  border-color: #559bce;
}
@media (max-width: 600px) {
  .money-summary {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .money-summary .stat {
    padding: 14px 16px;
  }
  .money-summary .stat-value {
    font-size: 27px;
  }
  #modal .money-summary {
    grid-template-columns: 1fr;
  }
  #modal .money-summary .stat {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 8px;
  }
  #modal .money-summary .stat-note {
    grid-column: 1/-1;
  }
  #modal .money-summary .stat-value {
    font-size: 22px;
  }
  .preview-row strong {
    font-size: 22px;
  }
  .payment-preview {
    padding: 14px;
  }
  .patient-banner .actions {
    width: 100%;
  }
  .patient-banner .actions .btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 600px) {
  #modal .money-summary {
    display: block;
    margin: 4px 0 16px;
  }
  #modal .money-summary .stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 6px;
  }
  #modal .money-summary .stat-note {
    display: none;
  }
  #modal .money-summary .stat-value {
    margin: 0;
    font-size: 21px;
  }
  #modal-form > .form-actions {
    position: sticky;
    bottom: -18px;
    background: white;
    z-index: 1;
    padding: 12px 0;
  }
  .money-summary .stat {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }
  .money-summary .stat-note {
    grid-column: 1 / -1;
  }
  .money-summary .stat-value {
    margin: 0;
  }
}
