:root {
  color-scheme: light;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f4f6f8;
  color: #1f2933;
}

* { box-sizing: border-box; }
body { margin: 0; }
.page { padding: 18px; }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
h1 { margin: 0; font-size: 24px; }
.header p { margin: 3px 0 0; color: #667; }
.health { padding: 7px 11px; border-radius: 6px; background: #e8eef5; color: #334; font-size: 13px; }
.health.ok { background: #dff3df; color: #064b0b; }
.health.error { background: #ffe0e0; color: #8b0000; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; padding: 12px; background: white; border: 1px solid #d7dee6; border-radius: 8px; }
label { display: grid; gap: 4px; font-size: 12px; color: #52606d; }
input, select, button { height: 32px; border: 1px solid #b8c2cc; border-radius: 5px; background: white; padding: 0 8px; font: inherit; }
button { background: #1769aa; color: white; border-color: #1769aa; cursor: pointer; }
button:hover { background: #125487; }
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.summary-item { background: #eaf2fb; border-radius: 5px; padding: 7px 10px; font-size: 13px; }
.summary-item.calculated { background: #fdf1e0; }
.table-card { background: white; border: 1px solid #d7dee6; border-radius: 8px; overflow: hidden; }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid #e1e6eb; }
#message { color: #667; font-size: 13px; }
.table-wrap { overflow: auto; max-height: calc(100vh - 300px); }
table { border-collapse: collapse; width: max-content; min-width: 100%; }
th, td { border-bottom: 1px solid #e6eaee; padding: 7px 9px; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: #eef2f5; z-index: 1; font-size: 12px; }
td.numeric, th.numeric { text-align: right; font-variant-numeric: tabular-nums; }
td { text-align: left; }
tr.total-row td { background: #eef2f5; font-weight: 600; border-top: 2px solid #c8d2dc; }
tr.total-row:hover td { background: #e7edf3; }
.table-hint { color: #667; font-size: 13px; }
button.active { background: #0f4c75; border-color: #0f4c75; }
button.active:hover { background: #0b3c5d; }
tr:nth-child(even) { background: #fafbfc; }
tr:hover { background: #eaf4ff; }
tr.editable { cursor: pointer; }
.login-screen { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: #eef2f5; }
.login-screen[hidden] { display: none; }
.login-box { width: min(320px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 12px; padding: 24px; background: white; border: 1px solid #d7dee6; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.login-box h2 { margin: 0; font-size: 20px; }
.login-note { margin: 0; color: #667; font-size: 13px; }
.login-field { font-size: 13px; font-weight: 600; color: #44515e; }
.login-box input { width: 100%; min-height: 44px; font-size: 16px; }
.login-box button { width: 100%; min-height: 44px; font-size: 16px; }
.login-box input:focus-visible, .login-box button:focus-visible {
  outline: 3px solid rgba(23, 105, 170, .35);
  outline-offset: 1px;
}
.login-box #login-message { min-height: 18px; margin: 0; font-size: 13px; }

.header-right { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.whoami { color: #445; font-size: 13px; }
.cashier-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.cashier-nav a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 11px; border: 1px solid #b8c2cc;
  border-radius: 6px; background: #fff; color: #1769aa;
  font-size: 13px; text-decoration: none;
}
.cashier-nav a:hover { background: #eef2f5; }
.cashier-nav a[aria-current="page"] { background: #0f4c75; border-color: #0f4c75; color: #fff; }
.cashier-nav button { min-height: 40px; }
@media (max-width: 640px) {
  .cashier-nav { width: 100%; }
  .cashier-nav a { flex: 1 1 auto; min-height: 44px; }
  .cashier-nav button { flex: 0 0 auto; min-height: 44px; }
}
button.secondary { background: #fff; color: #1769aa; border: 1px solid #b8c2cc; }
button.secondary:hover { background: #eef2f5; }
button.accent { background: linear-gradient(135deg, #1f7ac0, #12588f); border-color: #12588f; font-weight: 600; }
button.accent:hover { background: linear-gradient(135deg, #1a6aab, #0f4b7c); }

.list-title { margin: 16px 0 8px; font-size: 14px; }
.payment-input { width: 100px; padding: 4px 6px; text-align: right; }
.payment-input:focus { outline: 2px solid #1769aa; }
td.numeric:has(.payment-input) { white-space: nowrap; }

.report-body { padding: 12px; }
.report-body .table-wrap { max-height: 320px; margin-bottom: 18px; }
.report-title { margin: 10px 0 8px; font-size: 15px; }
.report-toolbar-controls, .table-toolbar-controls { display: flex; align-items: center; gap: 8px; }
td.delta-up { color: #1b7a3d; }
td.delta-down { color: #b03030; }

td.numeric button { margin-left: 6px; padding: 2px 7px; font-size: 13px; }

.account-totals { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }

.photo-cell { white-space: nowrap; }
.photo-cell button { margin-right: 4px; padding: 3px 8px; font-size: 13px; }
.photo-gallery { display: flex; flex-wrap: wrap; gap: 12px; max-height: 60vh; overflow: auto; }
.photo-gallery figure { margin: 0; width: 190px; }
.photo-gallery img { width: 190px; height: 140px; object-fit: cover; border-radius: 6px; border: 1px solid #d7dee6; background: #f4f6f8; }
.photo-gallery figcaption { margin-top: 4px; color: #667; font-size: 12px; }

.sheet-card {
  position: relative;
  width: min(460px, calc(100vw - 32px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 25, 35, .28);
  overflow: hidden;
}
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid #eef1f4; }
.sheet-icon { width: 42px; height: 42px; display: grid; place-items: center; font-size: 20px; border-radius: 12px; background: linear-gradient(135deg, #e8f1fb, #d6e6f8); }
.sheet-title { flex: 1; }
.sheet-title h2 { margin: 0; font-size: 18px; }
.sheet-title p { margin: 2px 0 0; color: #6b7a89; font-size: 13px; }
.sheet-body { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px; }
.field-grid { display: flex; flex-wrap: wrap; gap: 12px; align-items: start; }
.field-grid > .field { flex: 1 1 0; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; font-size: 13px; color: #55636f; line-height: 18px; }
.field > span { display: block; margin: 0; padding: 0; font-size: 13px; font-weight: 600; line-height: 18px; letter-spacing: .01em; }
.field input, .field select { width: 100%; max-width: 100%; min-width: 0; height: auto; min-height: 44px; padding: 11px 12px; font-size: 15px; border: 1px solid #d7dee6; border-radius: 10px; background: #fbfcfd; }
.field input[type="date"] { -webkit-appearance: none; appearance: none; }
.field input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.field input[type="date"]::-webkit-datetime-edit { padding: 0; }
.field input:focus, .field select:focus { outline: none; border-color: #1769aa; background: #fff; box-shadow: 0 0 0 3px rgba(23, 105, 170, .15); }
.amount-input { position: relative; }
.amount-input input { padding-right: 38px; text-align: right; font-size: 18px; font-variant-numeric: tabular-nums; }
.amount-input em { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: #8a97a3; font-style: normal; font-size: 16px; }
.photo-drop { position: relative; display: grid; place-items: center; min-height: 132px; padding: 14px; border: 2px dashed #c6d2dd; border-radius: 14px; background: #f8fafc; transition: border-color .15s, background .15s; }
.photo-drop:hover { border-color: #1769aa; background: #f2f7fc; }
.photo-drop img { max-width: 100%; max-height: 220px; border-radius: 10px; display: block; }
.photo-drop img[hidden] { display: none; }
.photo-drop-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #6b7a89; font-size: 14px; text-align: center; }
.photo-drop-empty small { color: #97a3ae; }
.photo-drop-icon { font-size: 26px; }
.photo-actions { align-items: stretch; }
.photo-actions > .photo-btn { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 6px 8px; background: #fbfcfd; border: 1px solid #d7dee6; border-radius: 10px; color: #2f3b46; font-size: 13px; font-weight: 600; line-height: 1.2; text-align: center; }
.photo-actions > .photo-btn:hover { background: #f2f7fc; border-color: #1769aa; }
.photo-clear { width: 100%; min-height: 40px; padding: 6px 12px; background: #fff; border: 1px solid #e6c7c1; border-radius: 10px; color: #a3372b; font-size: 14px; }
.photo-clear:hover { background: #fdf3f1; }
.sheet-note { margin: 0; color: #6b7a89; font-size: 12.5px; }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid #eef1f4; background: #fbfcfd; }
.sheet-foot .form-message { flex: 1 1 100%; margin: 0; }
.sheet-foot .form-message:empty { display: none; }
.sheet-foot button { flex: 1 1 0; height: 44px; border-radius: 12px; font-size: 15px; font-weight: 600; }
button.primary { background: linear-gradient(135deg, #1f7ac0, #12588f); border: none; border-radius: 10px; padding: 0 20px; color: #fff; font-weight: 600; }
button.primary:hover { background: linear-gradient(135deg, #1a6aab, #0f4b7c); }
button.ghost { background: #fff; border: 1px solid #cfd8e0; border-radius: 10px; color: #44515e; padding: 0 18px; }
button.ghost:hover { background: #f2f5f8; }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 25, 35, .45); }
.edit-dialog { position: relative; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; background: white; border-radius: 9px; box-shadow: 0 12px 40px rgba(0,0,0,.25); padding: 16px; }
.combo { position: relative; display: flex; }
.combo input { flex: 1; min-width: 0; padding-right: 30px; }
.combo-toggle { position: absolute; right: 1px; top: 1px; width: 28px; height: 30px; padding: 0; border: 0; background: transparent; color: #52606d; font-size: 12px; }
.combo-toggle:hover { background: #eef2f5; }
.combo-menu { position: absolute; z-index: 3; left: 0; right: 0; top: 34px; max-height: 190px; overflow: auto; border: 1px solid #b8c2cc; border-radius: 5px; background: white; box-shadow: 0 5px 14px rgba(0,0,0,.16); }
.combo-option { display: block; width: 100%; height: auto; padding: 7px 9px; border: 0; border-radius: 0; background: white; color: #1f2933; text-align: left; }
.combo-option:hover { background: #eaf4ff; }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 18px; }
.icon-button { width: 30px; padding: 0; font-size: 20px; line-height: 1; }
.edit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.edit-grid .wide { grid-column: span 3; }
.edit-grid input, .edit-grid select { width: 100%; }
.edit-grid .calculated input, .edit-grid .readonly-value { background: #eef1f4; color: #667; }
.edit-grid .readonly-value { min-height: 32px; border: 1px solid #b8c2cc; border-radius: 5px; padding: 7px 8px; }
.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 16px; }
.form-message { margin-right: auto; color: #a00; font-size: 13px; }
.modal-note { margin: -4px 0 12px; color: #667; font-size: 13px; }
.seller-list { max-height: 320px; overflow: auto; border: 1px solid #e1e6eb; border-radius: 5px; }
.seller-row { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-bottom: 1px solid #eef1f4; }
.seller-row:last-child { border-bottom: 0; }
.seller-row input { width: 16px; height: 16px; }
.seller-row .seller-name { flex: 1; }
.seller-row .seller-count { color: #667; font-size: 12px; }
.seller-add-form { display: flex; gap: 8px; margin-top: 12px; }
.seller-add-form input { flex: 1; }
@media (max-width: 768px) { .edit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .edit-grid .wide { grid-column: span 2; } }
@media (max-width: 520px) {
  .sheet-head { padding: 14px 16px; }
  .sheet-body { padding: 16px; gap: 12px; }
  .sheet-foot { padding: 12px 16px; }
  .sheet-card { width: calc(100vw - 20px); }
  .header { flex-wrap: wrap; gap: 10px; }
  h1 { font-size: 21px; }
  .photo-actions > .photo-btn { font-size: 12px; }
  .field input[type="date"] { font-size: 14px; }
}
@media (max-width: 768px) {
  .page { padding: 10px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap > table { min-width: 720px; }
}
