:root {
  --bg: #eef4f0;
  --card: #ffffff;
  --card-soft: #f8fbf9;
  --border: #cfded8;
  --border-strong: #b8cdc5;
  --text: #31433f;
  --muted: #6a7e78;

  --primary: #5ca9c9;
  --primary-2: #7cc7c4;
  --accent: #86b77f;
  --accent-soft: #edf7ef;
  --primary-soft: #e8f6f8;

  --success-bg: #ebf8ee;
  --success-border: #c7e4cc;
  --error-bg: #fceaea;
  --error-border: #ecc4c4;

  --shadow: 0 6px 16px rgba(108, 154, 144, 0.10);
  --radius: 12px;
}

body {
  font-family: "Century Gothic", CenturyGothic, "Trebuchet MS", Arial, sans-serif;
  background: linear-gradient(180deg, #f5fbf8 0%, var(--bg) 100%);
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  margin: 0;
  padding: 0;
}

.is-auth-hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  box-sizing: border-box;
}

.auth-gate.hidden {
  display: none;
}

.auth-card {
  width: min(520px, 100%);
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

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

.auth-brand h1 {
  margin: 0 0 2px;
  font-size: 22px;
  line-height: 1.1;
}

.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.auth-tab-button {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fbf9;
  color: #365d59;
  font-weight: 700;
  cursor: pointer;
}

.auth-tab-button.active {
  background: var(--primary-2);
  border-color: var(--primary-2);
  color: #ffffff;
}

.auth-panel {
  display: none;
  gap: 8px;
}

.auth-panel.active {
  display: grid;
}

.auth-submit-button {
  width: max-content;
  min-width: 116px;
  margin-top: 4px;
}

.auth-result-box:empty {
  display: none;
}

.auth-result-box.toast-message {
  animation: authToastFade 3.6s ease forwards;
}

@keyframes authToastFade {
  0% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

.password-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field-wrap input {
  flex: 1;
  padding-right: 36px;
}

.password-toggle-button {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
}

.password-toggle-button:hover {
  color: var(--text);
}

.page-shell {
  padding: 6px 8px 12px;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
}

.app-header {
  background: linear-gradient(135deg, #a9ddd1 0%, #85cddd 52%, #becfcb 100%);
  color: #24403e;
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.55);
}

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

.brand-text {
  flex: 1 1 auto;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.header-icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.62);
  color: #3f6d6c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(82, 135, 132, 0.10);
  transition: all 0.15s ease;
}

.header-icon-button:hover,
.header-icon-button.active {
  background: #ffffff;
  color: #2f6562;
  transform: translateY(-1px);
}

.header-icon-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.brand-logo {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text h1 {
  margin: 0 0 2px;
  font-size: 23px;
  line-height: 1.1;
  color: #2a4b48;
}

.brand-subtitle {
  margin: 0;
  font-size: 13px;
  color: #496764;
}

.brand-author-script {
  margin: 3px 0 0;
  font-size: 16px;
  color: #5c6f6c;
  font-family: "Rage Italic", "Rage", "Segoe Script", "Brush Script MT", cursive;
  line-height: 1;
}

.tabs-nav {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.tab-button {
  background: #ffffff;
  color: #3f6d6c;
  border: 1px solid #cfe1dc;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(113, 164, 160, 0.07);
  transition: all 0.15s ease;
  min-height: 38px;
  font-family: "Century Gothic", CenturyGothic, "Trebuchet MS", Arial, sans-serif;
}

.tab-button:hover {
  background: #effaf8;
}

.tab-button:not(.active) {
  color: #315f5d;
  background: #ffffff;
}

.tab-button:not(.active):hover {
  color: #315f5d;
  background: #effaf8;
}

.tab-button.active {
  background: linear-gradient(135deg, #76c5cf 0%, #7bc3b2 100%);
  color: #ffffff;
  border-color: #78beb6;
  box-shadow: 0 4px 14px rgba(103, 174, 171, 0.18);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.app-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.section-heading {
  margin-bottom: 8px;
}

.section-heading h2 {
  margin: 0 0 2px;
  font-size: 19px;
  color: #4a7e7b;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

h3 {
  margin-top: 0;
  margin-bottom: 6px;
  color: #4e7d7a;
  font-size: 16px;
}

p {
  margin-bottom: 8px;
}

form {
  display: flex;
  flex-direction: column;
}

label {
  margin-top: 6px;
  margin-bottom: 3px;
  font-weight: 700;
  color: #4e7d7a;
  font-size: 12px;
}

input,
select,
button {
  box-sizing: border-box;
}

input,
select,
textarea {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-family: "Century Gothic", CenturyGothic, "Trebuchet MS", Arial, sans-serif;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #79bcc4;
  box-shadow: 0 0 0 3px rgba(124, 199, 196, 0.15);
}

input[readonly],
textarea[readonly] {
  background: var(--card-soft);
  color: #5d706d;
}

button {
  margin-top: 0;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-shadow: 0 2px 8px rgba(110, 159, 148, 0.09);
  font-family: "Century Gothic", CenturyGothic, "Trebuchet MS", Arial, sans-serif;
}

button:hover {
  opacity: 0.97;
}

button:active {
  transform: translateY(1px) scale(0.99);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary,
button.btn-primary,
#generateProtocolButton {
  background: linear-gradient(135deg, #66b9c8 0%, #7bbfa0 100%);
  color: #ffffff;
}

.btn-secondary,
button.btn-secondary {
  background: linear-gradient(135deg, #7fc7d7 0%, #7cc7c4 100%);
  color: #ffffff;
}

.btn-ghost,
button.btn-ghost {
  background: #eef8f6;
  color: #4d7b78;
}

.delete-service-button {
  background: #f8e8e8;
  color: #9b5a5a;
  box-shadow: none;
}

.form-row {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

.two-cols {
  grid-template-columns: repeat(2, 1fr);
}

.three-cols {
  grid-template-columns: repeat(3, 1fr);
}

.four-cols {
  grid-template-columns: repeat(4, 1fr);
}

.five-cols {
  grid-template-columns: 0.7fr 1.25fr 1fr 0.8fr 1fr;
}

.payment-main-row {
  grid-template-columns:
    minmax(72px, 0.45fr)
    minmax(150px, 1.08fr)
    minmax(112px, 0.82fr)
    minmax(88px, 0.55fr)
    minmax(142px, 0.86fr)
    minmax(120px, 0.74fr);
  max-width: 1080px;
  align-items: end;
}

.payment-main-row #paymentRequestOutNo,
.payment-main-row #paymentReportYear {
  text-align: center;
}

.payment-main-row #paymentTotalAmountDisplay {
  text-align: right;
}

.form-col {
  min-width: 0;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.button-row button {
  flex: 1 1 180px;
}

.save-status-row {
  align-items: center;
  gap: 8px;
}

.save-status-row button {
  flex: 0 0 auto;
  width: auto;
  min-width: 138px;
  max-width: none;
}

.result-box {
  margin-top: 10px;
  padding: 9px 10px;
  background: #f8fbfa;
  border: 1px solid var(--border);
  border-radius: 10px;
  white-space: pre-line;
  word-break: break-word;
}

#paymentPreviewBox,
#paymentRequestsBox {
  white-space: normal;
}

.subsection-title {
  margin: 14px 0 0;
  color: var(--text);
  font-size: 16px;
}

.payment-preview-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 8px;
}

.payment-preview-table {
  min-width: 720px;
}

.service-result-inline {
  display: none;
  flex: 0 1 auto;
  align-items: center;
  gap: 6px;
  margin-top: 0;
  padding: 0;
  border: 0;
  background: transparent;
  white-space: normal;
  word-break: normal;
}

.service-result-inline.message-success,
.service-result-inline.message-error,
.service-result-inline.message-info {
  display: inline-flex;
  background: transparent;
  border: 0;
}

.service-result-text {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #f8fbfa;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}
.service-result-detail {
  display: block;
  margin-top: 3px;
  font-size: 0.86rem;
  line-height: 1.35;
  font-weight: 400;
  color: #557372;
}

.result-box.error .service-result-detail {
  color: #8a3f3f;
}


.message-success .service-result-text {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.message-error .service-result-text {
  background: var(--error-bg);
  border-color: var(--error-border);
}

.message-success {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.message-error {
  background: var(--error-bg);
  border-color: var(--error-border);
}

.message-info {
  background: #f8fbfa;
  border-color: var(--border);
}

.history-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.compact-filters {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1.2fr;
  gap: 8px;
  align-items: end;
}

.filter-actions .button-row {
  margin-top: 0;
}

.history-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.small-note {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}

#protocolBox a,
#servicesBox a,
#monthlyReportBox a {
  color: #4f97ae;
  text-decoration: none;
  font-weight: 700;
}

#protocolBox a:hover,
#servicesBox a:hover,
#monthlyReportBox a:hover {
  text-decoration: underline;
}

#placeInfo {
  margin-top: 6px;
}

.input-warning {
  color: #b45c46;
  font-weight: 700;
}

.client-mode-tabs,
.report-mode-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  margin: 2px 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fbfa;
}

.client-mode-button,
.report-mode-button {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 8px;
  background: transparent;
  color: #4d7b78;
  box-shadow: none;
  font-size: 12px;
}

.client-mode-button.active,
.report-mode-button.active {
  background: #ffffff;
  color: #2f6562;
  box-shadow: 0 2px 8px rgba(110, 159, 148, 0.10);
}

.client-mode-panel,
.report-mode-panel {
  display: none;
}

.client-mode-panel.active,
.report-mode-panel.active {
  display: block;
}

.compact-section-heading {
  margin-top: 4px;
}

.settings-block {
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid #e3ece8;
}

.settings-block:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

.table-wrap {
  overflow-x: visible;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
}

.services-table,
.report-table,
.settings-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  background: #ffffff;
}

.services-table th,
.services-table td,
.report-table th,
.report-table td,
.settings-table th,
.settings-table td {
  border-bottom: 1px solid #e3ece8;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}

.services-table th,
.report-table th,
.settings-table th {
  background: #edf7f4;
  color: #4a7e7b;
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 700;
}

.services-table tbody tr:nth-child(even),
.report-table tbody tr:nth-child(even),
.settings-table tbody tr:nth-child(even) {
  background: #fbfdfc;
}

.services-table tbody tr:hover,
.report-table tbody tr:hover,
.settings-table tbody tr:hover {
  background: #f2faf7;
}

.services-table td.actions-cell,
.report-table td.actions-cell,
.settings-table td.actions-cell {
  white-space: nowrap;
}

.services-table .compact-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.services-table {
  min-width: 0;
  table-layout: fixed;
}

.services-table th,
.services-table td {
  overflow-wrap: anywhere;
}

.services-table .date-col {
  width: 82px;
}

.services-table .client-col {
  width: 23%;
}

.services-table .time-col {
  width: 112px;
}

.services-table .icon-col {
  width: 52px;
  text-align: center;
}

.services-table .status-col {
  width: 92px;
}

.services-table .actions-col {
  width: 42px;
  text-align: center;
}

.compact-icon-cell {
  text-align: center;
}

.dsp-incoming-number-input {
  width: 98px;
  min-height: 30px;
  padding: 5px 7px;
  border: 1px solid #cfe1dc;
  border-radius: 8px;
  background: #ffffff;
  font-size: 12px;
}

.dsp-incoming-number-input:focus {
  outline: 2px solid rgba(111, 197, 194, 0.25);
  border-color: #79c8c5;
}

.dsp-incoming-number-input.save-ok {
  border-color: #77b99b;
}

.dsp-incoming-number-input.save-error {
  border-color: #d68787;
  background: #fff7f7;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid #cfe1dc;
  border-radius: 8px;
  background: #ffffff;
  color: #43716f;
  box-shadow: none;
  vertical-align: middle;
}

.icon-button:hover {
  background: #eef9f8;
  text-decoration: none;
}

.icon-button svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
}

.download-icon {
  color: #3f8ba5;
}

.info-icon {
  color: #4b7977;
}

.note-icon {
  color: #6e7d51;
}

.delete-service-button.icon-button {
  color: #9b5a5a;
  background: #fff7f7;
  border-color: #efd0d0;
}

.payment-status-toggle {
  width: 100%;
  min-height: 30px;
  padding: 5px 7px;
  border-radius: 8px;
  box-shadow: none;
  font-size: 12px;
  white-space: normal;
}

.payment-status-toggle.paid {
  background: #edf7ef;
  color: #4e7753;
  border: 1px solid #c7e4cc;
}

.payment-status-toggle.unpaid {
  background: #fff5e8;
  color: #98661e;
  border: 1px solid #efd9b3;
}

.info-popover {
  position: fixed;
  z-index: 10000;
  max-width: min(320px, calc(100vw - 20px));
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 14px 32px rgba(70, 110, 105, 0.18);
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-line;
}

.info-popover.hidden {
  display: none;
}

.services-table button {
  padding: 5px 8px;
  font-size: 12px;
}

.services-table .icon-button {
  padding: 0;
  font-size: 0;
}

.services-table .payment-status-toggle {
  padding: 5px 7px;
  font-size: 12px;
}

.schedule-heading,
.schedule-week-controls,
.schedule-item,
.schedule-item-actions {
  display: flex;
  align-items: center;
}

.schedule-heading {
  justify-content: space-between;
  gap: 10px;
}

.schedule-week-controls {
  gap: 6px;
  flex-wrap: wrap;
}

.icon-only-button {
  min-width: 36px;
  width: 36px;
  padding: 7px 0;
  text-align: center;
}

.schedule-layout {
  display: grid;
  grid-template-columns: minmax(420px, 760px) minmax(360px, 1fr);
  gap: 16px;
  align-items: start;
}

.schedule-form {
  width: 100%;
  max-width: none;
  min-width: 0;
}

.schedule-form h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #2a4b48;
}

.schedule-type-row,
.schedule-time-row,
.schedule-repeat-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.schedule-time-row {
  grid-template-columns: 1.2fr .9fr .9fr;
}

.schedule-interpreting-fields {
  padding: 8px;
  margin-bottom: 8px;
  background: #f8fbf9;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.schedule-remaining-info {
  min-height: 18px;
  margin: 2px 0 7px;
  color: #4b6c67;
  font-size: 12px;
}

.schedule-warning-box {
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid #e5c47b;
  background: #fff8e8;
  color: #6d4a14;
  border-radius: 8px;
  font-size: 12px;
}

.schedule-overlap-confirm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 12px;
  color: #5b4930;
}

.schedule-week-panel {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  align-self: start;
}

.schedule-week-panel .section-heading {
  justify-content: flex-end;
  margin-bottom: 8px;
}

#scheduleWeekLabel {
  width: 100%;
  margin: 0;
  text-align: right;
}

.schedule-week-list {
  display: grid;
  gap: 8px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.schedule-day {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdfc;
  min-width: 0;
}

.schedule-day h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: #315f5d;
  text-transform: capitalize;
}

.schedule-week-label-compact,
.schedule-day-label-compact,
.schedule-empty-compact {
  display: none;
}

.schedule-day-busy h4 {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #3f6b3c;
}

.schedule-item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) minmax(112px, .5fr) auto;
  gap: 7px;
  padding: 7px 0;
  border-top: 1px solid #e4eee9;
  min-width: 0;
}

.schedule-item:first-of-type {
  border-top: 0;
}

.schedule-item-time {
  font-weight: 700;
  color: #2d5c5a;
  font-size: 12px;
  white-space: nowrap;
}

.schedule-item-main {
  min-width: 0;
}

.schedule-item-main strong,
.schedule-item-main span {
  display: block;
  overflow-wrap: anywhere;
}

.schedule-item-main strong {
  font-size: 13px;
}

.schedule-item-main span,
.schedule-empty-day {
  color: var(--muted);
  font-size: 12px;
}

.schedule-status-select {
  width: 100%;
  min-height: 30px;
  padding: 5px 7px;
  font-size: 12px;
}

.schedule-item-actions {
  gap: 5px;
  justify-content: flex-end;
}

.schedule-item-actions .icon-button {
  width: 30px;
  height: 30px;
  min-width: 30px;
}

.security-action-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

@media (max-width: 1100px) {
  .tabs-nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .schedule-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .page-shell {
    padding: 6px 6px 10px;
  }

  .app-header {
    padding: 10px;
  }

  .brand-wrap {
    align-items: flex-start;
    gap: 8px;
  }

  .brand-logo {
    width: 44px;
    height: 44px;
  }

  .brand-text h1 {
    font-size: 19px;
  }

  .brand-subtitle {
    font-size: 12px;
  }

  .brand-author-script {
    font-size: 14px;
  }

  .tabs-nav {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .tab-button {
    min-height: 36px;
    font-size: 12px;
    padding: 7px 8px;
  }

  .app-card {
    padding: 10px;
  }

  .two-cols,
  .three-cols,
  .four-cols,
  .five-cols,
  .payment-main-row,
  .compact-filters,
  .service-main-row,
  .service-second-row,
  .schedule-type-row,
  .schedule-time-row,
  .schedule-repeat-row {
    grid-template-columns: 1fr;
  }

  .schedule-heading,
  .schedule-item {
    align-items: stretch;
  }

  .schedule-heading {
    flex-direction: column;
  }

  .schedule-week-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .schedule-item {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .schedule-item-status,
  .schedule-item-actions {
    width: 100%;
  }

  .schedule-item-actions {
    justify-content: flex-start;
  }

  .button-row {
    flex-direction: column;
  }

  .button-row button {
    width: 100%;
  }

  .settings-block {
    padding-top: 8px;
    margin-top: 8px;
  }

  .settings-block h3 {
    font-size: 14px;
    margin: 0 0 4px;
  }

  .save-status-row {
    flex-direction: row;
  }

  .save-status-row button {
    width: auto;
  }

  .button-row.single-action-row {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .settings-block .button-row.single-action-row {
    margin-top: 4px;
  }

  .client-mode-tabs,
  .report-mode-tabs {
    display: flex;
  }

  .client-mode-button,
  .report-mode-button {
    flex: 1 1 0;
  }

}

textarea {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  resize: vertical;
  overflow-x: hidden;
  overflow-wrap: break-word;
  min-height: 76px;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-family: "Century Gothic", CenturyGothic, "Trebuchet MS", Arial, sans-serif;
}

.service-title-block {
  margin-bottom: 8px;
}

.service-client-picker label {
  margin-top: 0;
}

.service-main-row {
  grid-template-columns: minmax(190px, 1.15fr) minmax(150px, 1fr) minmax(190px, 1.25fr) minmax(120px, .72fr) minmax(100px, .58fr) minmax(130px, .72fr);
  align-items: end;
}

.service-second-row {
  grid-template-columns: minmax(95px, .56fr) minmax(95px, .56fr) minmax(130px, .74fr) minmax(130px, .74fr) minmax(240px, 1.4fr);
  align-items: end;
}

.compact-time-picker {
  padding-left: 8px;
  padding-right: 8px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, #4e7d7a 50%), linear-gradient(135deg, #4e7d7a 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.compact-time-picker:read-only {
  background-color: #ffffff;
}

.quarter-time-popover {
  position: fixed;
  z-index: 9999;
  width: 232px;
  padding: 8px 10px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 14px 32px rgba(70, 110, 105, 0.20);
}

.quarter-time-popover::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 28px;
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
  border-left: 1px solid var(--border-strong);
  border-top: 1px solid var(--border-strong);
  background: #ffffff;
}

.quarter-time-popover.hidden {
  display: none;
}

.quarter-time-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.quarter-time-title {
  flex: 1;
  text-align: center;
  font-weight: 700;
  color: #254f4d;
  font-size: 13px;
}

.quarter-time-nav {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: #eef8f6;
  color: #2d6864;
  font-weight: 800;
  cursor: pointer;
  box-shadow: none;
}

.quarter-time-nav:hover {
  background: #d9f0ed;
}

.quarter-time-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.quarter-time-option {
  min-height: 30px;
  padding: 4px 3px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #ffffff;
  color: #244846;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow: none;
}

.quarter-time-option:hover {
  border-color: #9fd6d0;
  background: #eef9f8;
}

.quarter-time-option.active {
  background: #6fc4c1;
  color: #ffffff;
  border-color: #6fc4c1;
  font-weight: 700;
}

.quarter-time-footer {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.quarter-time-back {
  border: none;
  background: transparent;
  color: #3e7773;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 7px;
}

@media (max-width: 560px) {
  .quarter-time-popover {
    left: 16px !important;
    right: 16px;
    width: auto;
  }
}

.single-action-row button {
  max-width: 360px;
}

.description-cell {
  max-width: 260px;
  white-space: pre-line;
}

.services-table,
.report-table,
.settings-table {
  min-width: 1000px;
}

.services-table,
.settings-table {
  min-width: 0;
}

@media (max-width: 900px) {
  .service-second-row {
    grid-template-columns: 1fr 1fr;
  }

  .single-action-row button {
    max-width: none;
  }

  .services-table th,
  .services-table td {
    padding: 6px 5px;
    font-size: 12px;
  }

  .services-table .date-col {
    width: 76px;
  }

  .services-table .time-col {
    width: 98px;
  }

  .services-table .icon-col {
    width: 46px;
  }

  .services-table .status-col {
    width: 86px;
  }

  .services-table .actions-col {
    width: 42px;
  }

  .icon-button {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }
}

@media (max-width: 560px) {
  .service-second-row {
    grid-template-columns: 1fr;
  }
}

/* V2.1: Двустъпков избор на час — първо час, после минути */
.quarter-time-popover {
  width: 260px;
}

.quarter-time-nav.placeholder {
  pointer-events: none;
  background: transparent;
}

.quarter-time-help {
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 1.25;
  color: #58736f;
  text-align: center;
}

.selected-hour-strip {
  margin: 0 0 6px;
  padding: 5px 8px;
  border-radius: 8px;
  background: #eef9f8;
  color: #355e5a;
  text-align: center;
  font-size: 13px;
}

.quarter-time-grid.hours-grid {
  grid-template-columns: repeat(4, 1fr);
}

.quarter-time-grid.minutes-grid {
  grid-template-columns: repeat(4, 1fr);
}

.quarter-time-option.minute-option {
  min-height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.minute-label {
  font-size: 14px;
  font-weight: 800;
}

.full-time-label {
  font-size: 10px;
  opacity: 0.78;
}

.app-version-badge {
  display: inline-block;
  margin-top: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(76, 83, 106, 0.08);
  color: #4c536a;
  font-size: 11px;
  font-weight: 700;
}

.payment-requests-filters {
  margin: 4px 0 8px;
}

.payment-requests-filters select,
.payment-requests-filters input {
  min-height: 30px;
  font-size: 12px;
}

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

.payment-requests-table {
  min-width: 1080px;
}

.dsp-incoming-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.archive-payment-request-button.icon-button {
  color: #8a6f3d;
}

.archived-payment-request-row {
  opacity: 0.72;
}

#paymentRequestsStatusBox:empty {
  display: none;
}

@media (max-width: 720px) {
  .payment-requests-filters {
    grid-template-columns: 1fr 1fr;
  }

  .dsp-incoming-number-input {
    width: 96px;
  }
}

.payment-requests-filters.compact-filters {
  grid-template-columns: 1fr 0.8fr 1.2fr 0.9fr;
}


@media (max-width: 640px) {
  .brand-wrap {
    align-items: flex-start;
  }

  .header-actions {
    gap: 4px;
  }

  .header-icon-button {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .header-icon-button svg {
    width: 17px;
    height: 17px;
  }
}


/* Обяснение към ДСП */
.explanation-main-fields {
  grid-template-columns: minmax(200px, 1.4fr) minmax(120px, 0.8fr) minmax(120px, 0.7fr) minmax(110px, 0.55fr);
  align-items: end;
  overflow: hidden;
}

.explanation-field-date input[type="date"] {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.explanation-employment-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.explanation-form textarea {
  max-width: 100%;
  box-sizing: border-box;
  resize: vertical;
}

.explanation-employment-icons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
}

.mini-icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid #cfe1dc;
  border-radius: 9px;
  background: #ffffff;
  color: #43716f;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  padding: 0;
}

.mini-icon-button:hover {
  background: #eef9f8;
}

.mini-icon-button.success {
  color: #2f8d7e;
}

.mini-icon-button.danger {
  color: #9b5a5a;
}

.explanation-settings-message {
  margin-top: 4px;
}

.explanation-preview-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.explanation-preview-item {
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 8px;
}

.explanation-preview-item strong {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 2px;
}

.explanation-table-wrap,
.explanations-table-wrap {
  overflow-x: auto;
}

.explanation-preview-table th:nth-child(1),
.explanation-preview-table td:nth-child(1) { width: 42px; }
.explanation-preview-table th:nth-child(2),
.explanation-preview-table td:nth-child(2) { min-width: 170px; }
.explanation-preview-table th:nth-child(3),
.explanation-preview-table td:nth-child(3) { width: 100px; }
.explanation-preview-table th:nth-child(4),
.explanation-preview-table td:nth-child(4) { width: 120px; }
.explanation-preview-table th:nth-child(5),
.explanation-preview-table td:nth-child(5) { min-width: 150px; }
.explanation-preview-table th:nth-child(6),
.explanation-preview-table td:nth-child(6) { min-width: 150px; }
.explanation-preview-table th:nth-child(7),
.explanation-preview-table td:nth-child(7) { min-width: 300px; }

.explanation-employment-hint {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 8px;
}

.explanation-filters.compact-filters {
  display: grid;
  grid-template-columns: minmax(140px, 0.9fr) minmax(100px, 0.55fr) minmax(165px, 1fr) minmax(125px, 0.65fr);
  gap: 8px;
  align-items: end;
}

.explanations-table .actions-cell {
  white-space: nowrap;
}

.delete-explanation-button.icon-button {
  color: #9b5a5a;
  background: #fff7f7;
}

.delete-explanation-button.icon-button:hover {
  background: #fbecec;
}

.archived-explanation-row {
  opacity: 0.72;
}

@media (max-width: 900px) {
  .explanation-main-fields,
  .explanation-filters.compact-filters {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .explanation-preview-summary {
    grid-template-columns: 1fr 1fr;
  }

  .explanation-employment-editor {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (max-width: 560px) {
  .explanation-main-fields,
  .explanation-filters.compact-filters {
    grid-template-columns: 1fr;
  }
}


/* Потвърждения */
.confirmation-top-fields {
  grid-template-columns: minmax(260px, 1.6fr) minmax(130px, 0.7fr) minmax(155px, 0.85fr);
  align-items: end;
}

.confirmation-participant-fields {
  grid-template-columns: minmax(200px, 1fr) minmax(200px, 1fr);
  align-items: end;
}

.locked-module-note {
  border: 1px dashed #b8cdc5;
  background: #f8fbfa;
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 8px;
}

.confirmation-phone-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(165px, 0.45fr);
  gap: 8px;
  align-items: center;
  margin: 6px 0 8px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 700;
}

.inline-check input {
  width: auto;
}

.confirmation-text-preview {
  background: #f8fbfa;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  margin: 8px 0;
  line-height: 1.35;
}

.online-placeholder {
  background: #fffdf4;
  border: 1px solid #eadfb8;
  color: #756633;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  margin: 6px 0 8px;
}

.online-placeholder.hidden {
  display: none;
}

.signature-pad-block {
  margin-top: 6px;
}

.signature-pad-block.hidden {
  display: none;
}

/* Информационни placeholder текстове — малки, без поле */
.info-placeholder-text {
  font-size: 11px;
  color: var(--muted);
  margin: 4px 0;
  padding: 0;
  background: none;
  border: none;
  display: block;
}

/* Потвърждения placeholder */
#confirmationServicePreview.message-info {
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 2px 0;
  margin: 2px 0;
}

/* Обяснения placeholder */
#explanationPreviewBox.message-info {
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 2px 0;
  margin: 2px 0;
}

.signature-canvas {
  width: 100%;
  height: 140px;
  border: 1px solid #cfe1dc;
  border-radius: 10px;
  background: #ffffff;
  touch-action: none;
  display: block;
}

@media (max-width: 768px) {
  .signature-canvas {
    height: 70px;
  }

  /* Confirmations карти — по-компактни */
  table.cards-mobile tr {
    margin-bottom: 6px;
    padding: 6px 8px;
  }

  table.cards-mobile td {
    padding: 2px 0;
    font-size: 12px;
    gap: 6px;
  }

  table.cards-mobile td::before {
    font-size: 11px;
    flex: 0 0 32%;
  }

  table.cards-mobile td.card-title-cell {
    font-size: 13px;
    padding: 1px 0 3px;
  }

  /* Премахни горното отстояние на result-box с карти */
  #confirmationsBox,
  #explanationsBox {
    margin-top: 0;
    padding: 0;
    background: none;
    border: none;
  }
}

.signature-actions {
  margin-top: 6px;
}

.compact-generate-button {
  width: auto;
  min-width: 124px;
}

.confirmation-preview-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.confirmation-preview-item {
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 8px;
}

.confirmation-preview-item strong {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 2px;
}

.confirmations-filters.compact-filters {
  display: grid;
  grid-template-columns: minmax(140px, 0.9fr) minmax(100px, 0.55fr) minmax(125px, 0.65fr);
  gap: 8px;
  align-items: end;
}

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

.confirmations-table {
  min-width: 900px;
}

.confirmations-table .actions-cell {
  white-space: nowrap;
}

.delete-confirmation-button.icon-button {
  color: #9b5a5a;
  background: #fff7f7;
}

.archived-confirmation-row {
  opacity: 0.72;
}

@media (max-width: 1040px) {
  .tabs-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .confirmation-top-fields,
  .confirmation-participant-fields,
  .confirmation-phone-row,
  .confirmations-filters.compact-filters {
    grid-template-columns: 1fr;
  }

  .confirmation-preview-summary {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .tabs-nav {
    grid-template-columns: 1fr 1fr;
  }
  .confirmation-preview-summary {
    grid-template-columns: 1fr;
  }
}


/* Compact profile/header refinement */
.header-actions {
  gap: 6px;
  align-self: center;
}

.header-icon-button {
  width: 40px;
  height: 40px;
  padding: 5px 5px 4px;
  flex-direction: column;
  gap: 2px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.78), rgba(239,250,248,.66));
  border-color: rgba(255, 255, 255, 0.84);
}

.header-icon-button:hover,
.header-icon-button.active {
  background: linear-gradient(180deg, #ffffff, #edf9f6);
  box-shadow: 0 4px 12px rgba(73, 132, 127, 0.16);
}

.header-icon-mark {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #377472;
}

.header-icon-button svg,
.header-icon-mark svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
}

.header-icon-label {
  display: none;
  font-size: 10px;
  line-height: 1;
  font-weight: 700;
  color: #315f5d;
  letter-spacing: 0;
}

.profile-card {
  padding-bottom: 14px;
}

.profile-main-heading {
  margin-bottom: 8px;
}

.profile-main-heading h2 {
  margin-bottom: 2px;
}

.profile-form label {
  font-size: 11px;
  color: #55726d;
  font-weight: 700;
}

.profile-form input {
  min-height: 32px;
}

.profile-topline {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid #d7e8e3;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfefd, #f3faf7);
}

.profile-avatar-panel {
  display: grid;
  grid-template-columns: max-content max-content;
  align-items: center;
  gap: 6px;
}

.profile-avatar {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #8ed8cf, #7dbed7);
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(89, 152, 148, .18);
  background-size: cover;
  background-position: center;
}

.profile-avatar.has-photo {
  color: transparent;
}

.profile-avatar-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.profile-avatar-actions input[type="file"] {
  display: none;
}

.icon-mini-button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid #cfe3de;
  border-radius: 9px;
  background: #ffffff;
  color: #3f7e7b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(110, 159, 148, 0.10);
}

.icon-mini-button:hover {
  background: #edf9f6;
  color: #2f6562;
}

.icon-mini-button svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.profile-field-grid {
  display: grid;
  gap: 8px;
  align-items: end;
}

.profile-main-grid {
  grid-template-columns: minmax(260px, 1fr) minmax(90px, 150px) minmax(110px, 170px);
}

.profile-section-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.profile-mini-section {
  padding: 9px;
  border: 1px solid #dcebe7;
  border-radius: 12px;
  background: #ffffff;
}

.profile-mini-section h3 {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 6px;
  font-size: 14px;
  color: #356866;
}

.profile-mini-section h3 span {
  color: #6bb9b5;
  font-size: 11px;
}

.profile-data-grid {
  grid-template-columns: minmax(230px, 1.4fr) minmax(120px, .7fr) minmax(210px, 1fr);
}

.profile-bank-grid {
  grid-template-columns: minmax(90px, .7fr) minmax(90px, .55fr) minmax(100px, .7fr) minmax(230px, 1.25fr) minmax(220px, 1.1fr);
}

.profile-security-section {
  display: grid;
  grid-template-columns: max-content 1fr;
  align-items: center;
  gap: 8px;
}

.profile-password-grid {
  grid-template-columns: minmax(160px, .9fr) minmax(160px, .9fr) max-content;
}

.profile-password-action-col {
  width: max-content;
}

.profile-security-section h3 {
  margin: 0;
}

.security-chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.security-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid #d5e7e2;
  border-radius: 999px;
  background: #f6fbf9;
  color: #355e5c;
  font-size: 11px;
  white-space: nowrap;
}

.security-chip small {
  color: #6a8a85;
  font-size: 10px;
}

.security-session-list {
  display: grid;
  gap: 4px;
  margin-top: 7px;
  color: #52706b;
  font-size: 11px;
}

.security-session-list:empty {
  display: none;
}

.compact-text-button {
  min-height: 28px;
  width: max-content;
  margin-top: 7px;
  padding: 4px 9px;
  border-radius: 9px;
  font-size: 11px;
}

.profile-save-row {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.compact-save-button {
  width: 34px;
  min-width: 34px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1;
}

.button-row.single-action-row {
  justify-content: flex-start;
}

.button-row.single-action-row .compact-save-button {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  max-width: 34px;
}

.profile-result-inline {
  min-height: 32px;
  display: flex;
  align-items: center;
  margin-top: 0;
}

@media (max-width: 980px) {
  .profile-main-grid,
  .profile-data-grid,
  .profile-bank-grid {
    grid-template-columns: 1fr 1fr;
  }

  .profile-name-col,
  .profile-address-col,
  .profile-email-col,
  .profile-iban-col,
  .profile-holder-col {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .header-icon-button {
    width: 40px;
    height: 40px;
  }

  .header-icon-label {
    font-size: 9px;
  }

  .brand-subtitle {
    display: none;
  }

  .profile-topline {
    grid-template-columns: 1fr;
  }

  .profile-main-grid,
  .profile-data-grid,
  .profile-bank-grid,
  .profile-security-section,
  .profile-password-grid,
  .profile-save-row {
    grid-template-columns: 1fr;
  }

  .profile-avatar-panel {
    justify-content: start;
  }
}

@media (max-width: 640px) {
  .service-main-row,
  .service-second-row {
    grid-template-columns: 1fr 1fr;
  }

  .service-client-picker,
  .service-main-row .form-col:nth-child(2),
  .service-main-row .form-col:nth-child(3),
  .service-main-row .form-col:nth-child(4),
  .service-place-col {
    grid-column: 1 / -1;
  }
}

@media (max-width: 420px) {
  .service-main-row,
  .service-second-row {
    grid-template-columns: 1fr 1fr;
  }
}

.mobile-menu-bar,
.schedule-add-button {
  display: none;
}

.tabs-nav .mobile-only-tab-button {
  display: none;
}

@media (max-width: 768px) {
  .page-shell {
    padding: 4px 5px 8px;
  }

  .app-header {
    padding: 7px 8px;
    margin-bottom: 5px;
    border-radius: 12px;
  }

  .brand-wrap {
    align-items: center;
    gap: 7px;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .brand-text h1 {
    font-size: 17px;
    line-height: 1.05;
  }

  .brand-subtitle {
    display: none;
  }

  .brand-author-script {
    font-size: 12px;
    margin-top: 1px;
  }

  .header-actions {
    gap: 4px;
  }

  .header-actions .header-icon-button[data-header-tab="settingsTab"] {
    display: none;
  }

  .header-icon-button {
    width: 34px;
    height: 34px;
    padding: 4px;
    border-radius: 10px;
  }

  .header-icon-mark,
  .header-icon-button svg,
  .header-icon-mark svg {
    width: 18px;
    height: 18px;
  }

  .mobile-menu-bar {
    display: flex;
    align-items: center;
    margin: 0 0 5px;
  }

  .mobile-menu-toggle {
    width: auto;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid #cfe1dc;
    border-radius: 10px;
    background: #ffffff;
    color: #315f5d;
    box-shadow: 0 2px 8px rgba(113, 164, 160, 0.08);
  }

  .tabs-nav {
    display: none;
    grid-template-columns: 1fr;
    gap: 4px;
    margin-bottom: 6px;
  }

  .tabs-nav.mobile-open {
    display: grid;
  }

  .tabs-nav .tab-button,
  .tabs-nav.mobile-open .mobile-only-tab-button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
    text-align: left;
  }

  .tabs-nav .tab-button.active::before {
    content: "✓";
    display: inline-flex;
    width: 16px;
    margin-right: 6px;
    justify-content: center;
  }

  .schedule-heading {
    gap: 6px;
    margin-bottom: 6px;
  }

  .schedule-week-controls {
    gap: 5px;
    flex-wrap: nowrap;
  }

  .schedule-add-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: max-content;
    min-height: 30px;
    margin-left: auto;
    padding: 5px 12px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
  }

  .schedule-layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .schedule-week-panel,
  .schedule-week-list,
  .schedule-day {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .schedule-card,
  .schedule-layout,
  .schedule-week-panel,
  .schedule-week-list,
  .schedule-day {
    min-width: 0;
    overflow: hidden;
  }

  .schedule-week-panel {
    order: 2;
  }

  .schedule-form {
    display: none;
    order: 1;
    margin-bottom: 4px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f8fbf9;
  }

  .schedule-form.mobile-form-open {
    display: block;
  }

  .schedule-form h3 {
    margin-bottom: 6px;
    font-size: 15px;
  }

  .schedule-card > .section-heading h2 {
    font-size: 15px;
  }

  .schedule-week-controls {
    gap: 5px;
  }

  .schedule-week-controls .compact-text-button {
    margin-top: 0;
  }

  .schedule-week-controls .icon-only-button {
    width: auto;
    min-width: 0;
    padding: 4px 6px;
    border: none;
    background: transparent;
    box-shadow: none;
    font-size: 16px;
    color: #2d5c5a;
  }

  .schedule-week-controls .icon-only-button:hover {
    background: transparent;
  }

  .schedule-week-label-full {
    display: none;
  }

  .schedule-week-label-compact {
    display: inline;
    font-size: 13px;
    font-weight: 700;
  }

  .schedule-day-label-full,
  .schedule-empty-full {
    display: none;
  }

  .schedule-day-label-compact,
  .schedule-empty-compact {
    display: inline;
  }

  .schedule-empty-day {
    display: flex;
    gap: 4px;
  }

  .schedule-day {
    padding: 6px 8px;
    gap: 4px;
  }

  .schedule-day h4 {
    margin-bottom: 4px;
    font-size: 12px;
  }

  .schedule-day-empty {
    background: #fbfdfc;
    border: 1px solid var(--border);
    padding: 6px 9px;
  }

  .schedule-day-empty h4 {
    background: transparent;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: 12px;
  }

  .schedule-day-busy {
    border-color: var(--accent, #86b77f);
    border-left: 3px solid var(--accent, #86b77f);
    background: var(--accent-soft, #edf7ef);
  }

  .schedule-empty-day {
    padding: 0;
    font-size: 12px;
    color: var(--muted);
  }

  .schedule-item {
    padding: 6px 0;
  }
}

@media (max-width: 520px) {
  .auth-gate {
    padding: 10px;
  }

  .auth-card {
    padding: 12px;
    border-radius: 12px;
  }

  .auth-brand {
    gap: 8px;
    margin-bottom: 8px;
  }

  .auth-brand img {
    width: 36px;
    height: 36px;
  }

  .auth-brand h1 {
    font-size: 18px;
  }

  .auth-brand p {
    font-size: 12px;
  }

  .auth-tabs {
    gap: 5px;
    margin-bottom: 8px;
  }

  .auth-tab-button {
    min-height: 30px;
    font-size: 12px;
    padding: 4px 6px;
  }

  .auth-panel {
    gap: 6px;
  }

  .auth-panel input {
    min-height: 32px;
    padding: 6px 8px;
  }

  .auth-submit-button {
    width: 100%;
    min-height: 32px;
  }

  .auth-result-box {
    padding: 6px 8px;
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .auth-tabs {
    grid-template-columns: 1fr 1fr;
  }

  .auth-tab-button:last-child {
    grid-column: 1 / -1;
  }
}

/* Мобилно странично меню (drawer) */
.mobile-menu-overlay {
  display: none;
}

@media (max-width: 768px) {
  .mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(34, 56, 51, 0.35);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .mobile-menu-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .tabs-nav {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80%;
    max-width: 300px;
    margin: 0;
    padding: 56px 10px 16px;
    gap: 4px;
    background: var(--card);
    box-shadow: 4px 0 24px rgba(31, 56, 50, 0.18);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 1000;
    overflow-y: auto;
  }

  .tabs-nav.mobile-open {
    display: flex;
    transform: translateX(0);
  }
}


/* ===== Мобилни корекции: Настройки(II), Клиенти(VIII), Месечен отчет(X) ===== */
/* Кратки/пълни етикети по подразбиране (desktop): показваме пълните */
.label-compact { display: none; }
.label-full { display: inline; }

/* Скриване на празни заоблени резултатни кутии (премахва празни рамки) */
.result-box:empty { display: none; }

@media (max-width: 768px) {
  /* Етикети: на телефон показваме кратките */
  .label-full { display: none; }
  .label-compact { display: inline; }

  /* X. Месечен отчет — двата бутона на един ред, компактни */
  .monthly-report-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .monthly-report-actions .monthly-report-button {
    flex: 1 1 auto;
    width: auto;
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
  }

  /* II. Настройки/Ставки — по-ниски полета, по-малки отстояния */
  #settingsTab .settings-block { padding-top: 8px; }
  #settingsTab .settings-block h3 { font-size: 14px; margin-bottom: 6px; }
  #settingsTab input,
  #clientForm input,
  #editClientForm input,
  #clientForm select,
  #editClientForm select {
    min-height: 32px;
    padding: 6px 8px;
  }

  /* VIII. Клиенти — сдвоени полета на един ред (Телефон/ДСП, Общо/Остатък) */
  .client-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  /* VIII. Клиенти — компактен бутон за запис, без голяма плоча */
  #clientForm .button-row,
  #editClientForm .button-row {
    flex-direction: row;
    justify-content: flex-start;
  }

  #clientForm .button-row .btn-primary,
  #editClientForm .button-row .btn-primary {
    width: auto;
    align-self: flex-start;
    flex: 0 0 auto;
    min-height: 34px;
    padding: 7px 14px;
  }
}

/* ===== Таблици → карти на мобилен: V Потвърждения, VI Обяснения, IX Услуги ===== */
@media (max-width: 768px) {
  table.cards-mobile,
  table.cards-mobile tbody,
  table.cards-mobile tr,
  table.cards-mobile td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }

  table.cards-mobile thead {
    display: none;
  }

  table.cards-mobile tr {
    margin-bottom: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fbfdfc;
  }

  table.cards-mobile td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 3px 0;
    border: 0;
    font-size: 13px;
    text-align: left;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  table.cards-mobile td::before {
    content: attr(data-label);
    flex: 0 0 36%;
    font-weight: 600;
    color: var(--muted);
    font-size: 12px;
  }

  /* Заглавен ред (име/ДСП) — едро, без етикет, на цял ред */
  table.cards-mobile td.card-title-cell {
    display: block;
    font-weight: 700;
    color: #2a4b48;
    font-size: 14px;
    padding: 2px 0 4px;
  }

  table.cards-mobile td.card-title-cell::before {
    content: none;
  }

  /* Клетки без етикет (действия) — само иконите, вдясно */
  table.cards-mobile td[data-label=""]::before {
    content: none;
  }

  table.cards-mobile td[data-label=""] {
    justify-content: flex-end;
    padding-top: 4px;
  }

  /* компактни икони в картите */
  table.cards-mobile .compact-icon-cell .icon-button,
  table.cards-mobile .compact-icon-cell a,
  table.cards-mobile .compact-icon-cell button {
    min-width: 30px;
    height: 30px;
  }

  /* премахни долната граница на последния ред-празна клетка */
  table.cards-mobile td:last-child {
    padding-bottom: 0;
  }
}

/* ===== V: компактна зона около подписа (без промяна на canvas) ===== */
.signature-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.signature-head label {
  margin: 0;
}

.signature-clear-button {
  width: auto;
  min-height: 0;
  padding: 3px 9px;
  font-size: 12px;
  border-radius: 8px;
}

.signature-pad-block {
  margin-top: 4px;
}

@media (max-width: 768px) {
  /* По-лек информационен текст, по-малко празно пространство */
  .confirmation-text-preview {
    margin: 6px 0;
    padding: 7px 9px;
    font-size: 12px;
  }

  #confirmationNote {
    min-height: 56px;
  }

  /* Safe-area отдолу — последните полета/бутони да не се крият зад мобилната лента */
  .page-shell {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  /* ===== VII: компактна горна част на „Искане за плащане“ ===== */
  #paymentRequestTab .section-heading h2 { font-size: 16px; }
  #paymentRequestTab .section-heading p { font-size: 11px; margin: 2px 0 0; }
  #paymentRequestTab input,
  #paymentRequestTab select,
  #paymentRequestTab textarea { min-height: 32px; padding: 6px 8px; }

  .payment-main-row {
    grid-template-columns: 1fr 1fr 1.3fr;
    grid-template-areas:
      "out year month"
      "dsp dsp dsp"
      "date date date"
      "total total total";
    gap: 6px;
    max-width: none;
  }

  .payment-main-row > .form-col:nth-child(1) { grid-area: out; }
  .payment-main-row > .form-col:nth-child(2) { grid-area: dsp; }
  .payment-main-row > .form-col:nth-child(3) { grid-area: month; }
  .payment-main-row > .form-col:nth-child(4) { grid-area: year; }
  .payment-main-row > .form-col:nth-child(5) { grid-area: date; }
  .payment-main-row > .form-col:nth-child(6) { grid-area: total; }

  .payment-generate-button {
    width: auto;
    align-self: flex-start;
    flex: 0 0 auto;
    min-height: 34px;
    padding: 7px 14px;
  }

  /* ===== XI: компактен мобилен профил (по таблиците) ===== */
  .profile-main-grid { grid-template-columns: 1fr 1fr; }      /* ИНП | Град */
  .profile-name-col { grid-column: 1 / -1; }                  /* Име на цял ред */

  /* Данни: Адрес (цял ред), Имейл (цял ред), Телефон | Идентификационен № */
  .profile-data-grid { grid-template-columns: 1fr 1fr; }
  .profile-data-grid > :nth-child(1) { order: 1; grid-column: 1 / -1; } /* Адрес */
  .profile-data-grid > :nth-child(2) { order: 3; }                      /* Телефон */
  .profile-data-grid > :nth-child(3) { order: 2; grid-column: 1 / -1; } /* Имейл */
  .profile-data-grid > :nth-child(4) { order: 4; }                      /* Идентификационен № */

  /* Банка | BIC | Клон на един ред; IBAN и Титуляр на цял ред */
  .profile-bank-grid { grid-template-columns: repeat(3, 1fr); }
  .profile-bank-grid > .form-col:nth-child(n+4) { grid-column: 1 / -1; }

  /* Парола компактно: Стара | Нова | ✓ на един ред */
  .profile-password-grid {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
    gap: 6px;
  }

  #settingsTab input,
  #profileTab input,
  #paymentRequestTab input,
  .profile-field-grid input {
    min-height: 32px;
  }

  .profile-mini-section { padding: 8px; }
}

/* ===== IX: компактни филтри и бутони „Филтрирай/Покажи всички“ на мобилен ===== */
@media (max-width: 768px) {
  .filter-actions .button-row {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .filter-actions .button-row button {
    width: auto;
    flex: 0 0 auto;
    min-height: 34px;
    padding: 7px 12px;
    font-size: 13px;
  }

  /* филтрите да не са огромни празни блокове */
  .compact-filters .form-col label { font-size: 12px; }
  .compact-filters input,
  .compact-filters select { min-height: 32px; padding: 6px 8px; }

  /* скрий „празния“ етикет-разделител при действията */
  .filter-actions > label { display: none; }
}

/* ===== ГРАФИК: Дата | от | до на един ред (мобилен) ===== */
@media (max-width: 768px) {
  .schedule-time-row {
    grid-template-columns: 1.1fr 0.85fr 0.85fr;
    gap: 6px;
  }

  .schedule-time-row .form-col {
    min-width: 0;
  }

  .schedule-time-row input {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }

  /* ===== НОВА УСЛУГА: симетрия на полето „Дата“ с останалите ===== */
  .service-main-row input,
  .service-second-row input,
  .service-main-row select,
  .service-second-row select {
    min-height: 36px;
    box-sizing: border-box;
  }

  input[type="date"],
  input[type="time"],
  input[type="month"] {
    min-height: 36px;
    box-sizing: border-box;
    line-height: normal;
  }
}

/* ===== Правен пакет: Абонамент + Правни документи ===== */
.subscription-block .subscription-overview {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.subscription-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.subscription-row .sub-label { color: var(--muted); }
.subscription-row .sub-value { font-weight: 600; color: #2a4b48; }
.sub-status-active { color: #2f7d4f; }

.subscription-modules {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.sub-modules-group h4 {
  margin: 0 0 4px;
  font-size: 12px;
  color: #356866;
}

.sub-modules-list {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  color: #3d4f4c;
}

.sub-modules-list li { margin: 1px 0; }

.subscription-note {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 8px;
  line-height: 1.4;
}

.legal-block .legal-intro {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 8px;
}

.legal-doc {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fbfdfc;
  margin-bottom: 6px;
  overflow: hidden;
}

.legal-doc > summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 11px;
  font-weight: 600;
  font-size: 13px;
  color: #2a4b48;
  display: flex;
  align-items: center;
  gap: 8px;
}

.legal-doc > summary::-webkit-details-marker { display: none; }

.legal-doc > summary::before {
  content: "▸";
  color: #6bb9b5;
  font-size: 11px;
  flex: 0 0 auto;
}

.legal-doc[open] > summary::before { content: "▾"; }

.legal-doc > summary:hover { background: #f1f7f5; }

.legal-meta {
  padding: 0 12px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.legal-content {
  padding: 0 12px 11px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #36474a;
}

.legal-content p { margin: 0 0 7px; }

.legal-register {
  margin: 4px 0 0;
  padding-left: 16px;
}

.legal-register li {
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

@media (max-width: 768px) {
  .subscription-modules { grid-template-columns: 1fr; gap: 6px; }
  .subscription-actions { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .subscription-actions button { width: auto; flex: 0 0 auto; min-height: 34px; padding: 7px 12px; }
  .legal-doc > summary { font-size: 12.5px; padding: 8px 10px; }
}

/* ===== Приемане на условия / изтриване на профил / заключени модули ===== */
.terms-overlay,
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 40, 38, 0.55);
}

.terms-overlay.hidden,
.modal-overlay.hidden {
  display: none;
}

.terms-overlay-card,
.modal-card {
  width: 100%;
  max-width: 460px;
  background: #ffffff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 18px 48px rgba(20, 40, 38, 0.28);
  max-height: 90vh;
  overflow-y: auto;
}

.terms-overlay-card h2,
.modal-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  color: #2a4b48;
}

.terms-overlay-text {
  font-size: 13px;
  color: #475e5a;
  line-height: 1.5;
  margin: 0 0 12px;
}

.terms-accept-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: #36474a;
  margin-bottom: 12px;
}

.terms-accept-check input {
  width: auto;
  margin-top: 2px;
  flex: 0 0 auto;
}

.terms-overlay-actions,
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal-warning {
  font-size: 13px;
  line-height: 1.5;
  color: #6d4a14;
  background: #fff8e8;
  border: 1px solid #e5c47b;
  border-radius: 9px;
  padding: 9px 11px;
  margin: 0 0 10px;
}

.danger-button {
  background: #c0563f;
}

.danger-text-button {
  color: #c0563f;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Заключен платен модул */
.tab-panel {
  position: relative;
}

.module-lock {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  background: rgba(248, 251, 249, 0.96);
  border-radius: 12px;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.tab-panel.is-locked .module-lock {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.module-lock-text {
  font-size: 14px;
  font-weight: 600;
  color: #2a4b48;
  max-width: 300px;
  line-height: 1.5;
}

.module-lock-icon {
  font-size: 28px;
}

@media (max-width: 768px) {
  .terms-overlay-card,
  .modal-card { padding: 14px; }
  .terms-overlay-card h2,
  .modal-card h2 { font-size: 16px; }
}

/* ===== STEP 1: мобилни и компактни UI поправки (без промяна на заключените логики) ===== */
#serviceMonthFilter,
#paymentReportMonth,
#paymentRequestDate,
#explanationLetterDate,
#paymentRequestsYearFilter,
#explanationsYearFilter,
#confirmationsYearFilter {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#outgoingNumberForm .two-cols {
  grid-template-columns: minmax(0, 110px);
}

#profileLastOutgoingNumber {
  width: 86px;
  max-width: 86px;
  text-align: center;
}

.monthly-report-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: end;
  gap: 6px;
}

.monthly-report-actions .monthly-report-button {
  flex: 0 0 auto;
  min-width: 98px;
  width: auto;
}

.monthly-export-icon {
  flex: 0 0 30px !important;
  min-width: 30px !important;
  width: 30px !important;
  height: 30px;
}

.plain-info-message,
.result-box.plain-info-message,
.confirmation-text-preview.plain-info-message {
  margin: 4px 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 600;
  white-space: normal;
}

#paymentPreviewBox.plain-info-message,
#explanationPreviewBox.plain-info-message,
#confirmationServicePreview.plain-info-message,
#confirmationTextPreview.plain-info-message {
  margin: 3px 0 6px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

#paymentPreviewBox:not(.plain-info-message),
#explanationPreviewBox:not(.plain-info-message),
#confirmationServicePreview:not(.plain-info-message),
#confirmationTextPreview:not(.plain-info-message) {
  white-space: normal;
}

.payment-main-row input,
.payment-main-row select,
.compact-filters input,
.compact-filters select,
.explanation-main-fields input,
.explanation-main-fields select,
.confirmation-top-fields input,
.confirmation-top-fields select,
.confirmation-participant-fields input,
.confirmation-participant-fields select {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.settings-table .compact-icon-cell {
  text-align: center;
  vertical-align: middle;
}

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

.signature-canvas {
  height: 80px;
}

#confirmationsBox,
#explanationsBox,
#servicesBox {
  white-space: normal;
}

@media (max-width: 768px) {
  #reportsTab .compact-filters,
  #monthlyReportSection .compact-filters {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    align-items: end;
  }

  #servicesReportSection .compact-filters {
    grid-template-columns: 1fr;
  }

  #servicesReportSection .filter-actions .button-row {
    justify-content: flex-start;
  }

  #servicesReportSection #loadServicesButton {
    min-width: 92px;
  }

  .monthly-report-actions {
    align-items: center;
  }

  .monthly-report-actions .monthly-report-button {
    min-width: 92px;
    min-height: 32px;
    padding: 6px 10px;
  }

  .monthly-export-icon {
    height: 32px;
  }

  .payment-main-row {
    grid-template-columns: 0.85fr 0.9fr 1.25fr;
    grid-template-areas:
      "out year month"
      "dsp dsp dsp"
      "date date date"
      "total total total";
    gap: 6px;
  }

  #paymentRequestDate,
  #explanationLetterDate {
    display: block;
  }

  #paymentPreviewBox.plain-info-message,
  #explanationPreviewBox.plain-info-message,
  #confirmationServicePreview.plain-info-message,
  #confirmationTextPreview.plain-info-message {
    font-size: 11px;
    margin: 2px 0 5px;
  }

  #servicesBox.result-box,
  #explanationsBox.result-box,
  #confirmationsBox.result-box {
    margin-top: 6px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  #servicesBox .table-wrap,
  #explanationsBox .table-wrap,
  #confirmationsBox .table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  table.cards-mobile {
    min-width: 0 !important;
    background: transparent;
  }

  table.cards-mobile tbody {
    display: block;
  }

  table.cards-mobile tr {
    margin-bottom: 6px;
    padding: 6px 8px;
    border-radius: 10px;
    background: #fbfdfc;
  }

  table.cards-mobile td {
    min-height: 0;
    padding: 2px 0;
    gap: 6px;
    font-size: 12px;
    line-height: 1.25;
  }

  table.cards-mobile td::before {
    flex: 0 0 34%;
    font-size: 11px;
  }

  table.cards-mobile td.card-title-cell {
    padding: 1px 0 2px;
    font-size: 13px;
    line-height: 1.25;
  }

  table.cards-mobile .compact-icon-cell .icon-button,
  table.cards-mobile .compact-icon-cell a,
  table.cards-mobile .compact-icon-cell button {
    min-width: 28px;
    width: 28px;
    height: 28px;
  }

  .payment-status-toggle {
    min-height: 28px;
    padding: 4px 7px;
  }

  .signature-canvas {
    height: 80px !important;
  }

  .signature-pad-block {
    margin-top: 4px;
  }

  .signature-head {
    margin-bottom: 3px;
  }

  .confirmation-text-preview:not(.plain-info-message) {
    margin: 5px 0;
    padding: 6px 8px;
    font-size: 12px;
  }

  .confirmations-filters.compact-filters,
  .explanation-filters.compact-filters,
  .payment-requests-filters.compact-filters {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  #outgoingNumberForm .two-cols {
    grid-template-columns: minmax(0, 96px);
  }

  #profileLastOutgoingNumber {
    width: 82px;
    max-width: 82px;
  }
}

/* ===== STEP 1 V3: поправки след мобилен тест ===== */
#reportMonth,
#paymentReportMonth,
#paymentRequestDate,
#explanationLetterDate,
#paymentRequestsYearFilter,
#explanationsYearFilter,
#confirmationsYearFilter {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#paymentRequestTab input,
#paymentRequestTab select,
#paymentRequestTab textarea,
#explanationTab input,
#explanationTab select,
#confirmationTab input,
#confirmationTab select,
#settingsTab input,
#settingsTab select {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#paymentRequestTab input,
#paymentRequestTab select {
  min-height: 38px;
  line-height: 1.25;
}

#paymentRequestDate,
#explanationLetterDate,
#reportMonth {
  -webkit-appearance: none;
  appearance: none;
  overflow: hidden;
}

.monthly-export-icon {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  color: var(--primary-dark);
}

.monthly-export-icon:hover {
  background: transparent !important;
  transform: none;
}

#outgoingNumberForm {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

#outgoingNumberForm .form-row.two-cols {
  margin: 0;
  flex: 0 0 auto;
}

#outgoingNumberForm .button-row.single-action-row {
  margin: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}

#outgoingNumberForm .compact-save-button {
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
}

.signature-canvas {
  height: 140px;
}

@media (max-width: 768px) {
  #monthlyReportSection .compact-filters {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    align-items: end;
  }

  #monthlyReportSection .form-col {
    min-width: 0;
  }

  #monthlyReportSection .filter-actions {
    min-width: 0;
  }

  #monthlyReportSection .filter-actions > label {
    display: block;
    visibility: hidden;
    height: 0;
    margin: 0;
  }

  .monthly-report-actions {
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
  }

  .monthly-report-actions .monthly-report-button {
    flex: 0 0 auto;
    min-width: 104px;
    max-width: 112px;
    min-height: 34px;
    padding: 7px 10px;
    white-space: nowrap;
  }

  .monthly-export-icon {
    flex: 0 0 28px !important;
    width: 28px !important;
    min-width: 28px !important;
    height: 34px;
  }

  .monthly-export-icon svg {
    width: 18px;
    height: 18px;
  }

  .payment-main-row {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 0.95fr) minmax(0, 1.25fr);
    grid-template-areas:
      "out year month"
      "dsp dsp dsp"
      "date date date"
      "total total total";
    gap: 6px;
  }

  #paymentRequestTab .payment-main-row input,
  #paymentRequestTab .payment-main-row select {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 13px;
  }

  #paymentRequestDate,
  #explanationLetterDate {
    display: block;
    width: 100%;
  }

  table.cards-mobile tr {
    position: relative;
  }

  table.cards-mobile td[data-label="Свали"] {
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    padding-top: 5px;
    padding-right: 84px;
    min-height: 34px;
  }

  table.cards-mobile td[data-label="Свали"]::before {
    flex: 0 0 auto;
    min-width: 0;
    margin: 0;
  }

  table.cards-mobile td[data-label="Свали"] .icon-button,
  table.cards-mobile td[data-label="Свали"] a,
  table.cards-mobile td[data-label="Свали"] button {
    margin-left: auto;
  }

  table.cards-mobile td.actions-cell[data-label=""] {
    position: absolute;
    right: 8px;
    bottom: 6px;
    display: flex;
    width: auto;
    padding: 0;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
  }

  table.cards-mobile td.actions-cell[data-label=""] .icon-button,
  table.cards-mobile td.actions-cell[data-label=""] button,
  table.cards-mobile td.actions-cell[data-label=""] a {
    flex: 0 0 30px;
    width: 30px;
    min-width: 30px;
    height: 30px;
  }

  .signature-canvas {
    height: 160px !important;
  }

  #outgoingNumberForm {
    flex-wrap: nowrap;
    align-items: flex-end;
  }

  #outgoingNumberForm .form-row.two-cols {
    grid-template-columns: minmax(0, 96px);
  }

  #profileLastOutgoingNumber {
    width: 96px;
    max-width: 96px;
  }

  #outgoingNumberForm .compact-save-button {
    flex-basis: 40px;
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }
}

/* ===== STEP 1 V4: настройки - номерация в два компактни реда ===== */
#outgoingNumberForm {
  display: grid !important;
  grid-template-columns: 112px 44px 44px;
  grid-template-areas:
    "outgoingLabel outgoingLabel outgoingLabel"
    "outgoingInput outgoingSave outgoingReset";
  justify-content: start;
  align-items: end;
  gap: 6px 8px;
  width: max-content;
  max-width: 100%;
  margin: 0;
}

#outgoingNumberForm .form-row.two-cols,
#outgoingNumberForm .form-col,
#outgoingNumberForm .button-row.single-action-row {
  display: contents !important;
  margin: 0 !important;
  padding: 0 !important;
}

#outgoingNumberForm label[for="profileLastOutgoingNumber"] {
  grid-area: outgoingLabel;
  white-space: nowrap;
  display: block;
  margin: 0;
  line-height: 1.2;
}

#profileLastOutgoingNumber {
  grid-area: outgoingInput;
  width: 112px !important;
  max-width: 112px !important;
  min-width: 112px !important;
  text-align: center;
}

#outgoingNumberForm .button-row.single-action-row button[type="submit"] {
  grid-area: outgoingSave;
}

#resetOutgoingNumberButton {
  grid-area: outgoingReset;
}

#outgoingNumberForm .compact-save-button {
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
  padding: 0 !important;
  justify-self: start;
}

@media (max-width: 768px) {
  #outgoingNumberForm {
    grid-template-columns: 112px 44px 44px;
    grid-template-areas:
      "outgoingLabel outgoingLabel outgoingLabel"
      "outgoingInput outgoingSave outgoingReset";
    justify-content: start;
    align-items: end;
    gap: 6px 8px;
    width: max-content;
    max-width: 100%;
  }

  #outgoingNumberForm label[for="profileLastOutgoingNumber"] {
    white-space: nowrap;
  }

  #profileLastOutgoingNumber {
    width: 112px !important;
    max-width: 112px !important;
    min-width: 112px !important;
  }
}

/* ===== STEP 1 V5: номерация - малки бутони/икони ===== */
#outgoingNumberForm {
  grid-template-columns: 112px 34px 34px !important;
  gap: 6px 6px !important;
}

#outgoingNumberForm .compact-save-button,
#outgoingNumberForm .button-row.single-action-row .compact-save-button,
#outgoingNumberForm .button-row.single-action-row button[type="submit"],
#resetOutgoingNumberButton {
  width: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  padding: 0 !important;
  border-radius: 10px !important;
  font-size: 16px !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#outgoingNumberForm .compact-save-button svg,
#resetOutgoingNumberButton svg {
  width: 16px !important;
  height: 16px !important;
}

@media (max-width: 768px) {
  #outgoingNumberForm {
    grid-template-columns: 112px 34px 34px !important;
    gap: 6px 6px !important;
  }

  #outgoingNumberForm .compact-save-button,
  #outgoingNumberForm .button-row.single-action-row .compact-save-button,
  #outgoingNumberForm .button-row.single-action-row button[type="submit"],
  #resetOutgoingNumberButton {
    flex: 0 0 34px !important;
    width: 34px !important;
    min-width: 34px !important;
    max-width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    font-size: 16px !important;
  }
}

/* ===== STEP 1 V6: заключени секции + довършване на останалите отворени полета ===== */
/* Искане за плащане: „Дата на искането | Обща сума“ на един ред в мобилен изглед */
@media (max-width: 768px) {
  .payment-main-row {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 0.95fr) minmax(0, 1.25fr) !important;
    grid-template-areas:
      "out year month"
      "dsp dsp dsp"
      "date date total" !important;
    gap: 6px !important;
  }

  .payment-main-row > .payment-date-col,
  .payment-main-row > .form-col:nth-child(5) {
    grid-area: date !important;
  }

  .payment-main-row > .payment-total-col,
  .payment-main-row > .form-col:nth-child(6) {
    grid-area: total !important;
  }

  #paymentTotalAmountDisplay {
    text-align: center;
    padding-left: 6px;
    padding-right: 6px;
  }

  #paymentRequestsYearFilter,
  #confirmationsYearFilter {
    appearance: auto;
    -webkit-appearance: menulist;
  }
}

/* Настройки > Ставки: първи ред 3 полета, втори ред бележка + вертикални икони вдясно */
#rateForm.rate-form-compact .rate-main-row {
  display: grid;
  grid-template-columns: minmax(76px, 0.75fr) minmax(130px, 1fr) minmax(150px, 1.1fr) 34px;
  grid-template-areas:
    "rateYear rateHour rateDate rateDate"
    "rateNote rateNote rateNote rateActions";
  align-items: end;
  gap: 8px;
  max-width: 760px;
}

#rateForm .rate-year-col { grid-area: rateYear; }
#rateForm .rate-hour-col { grid-area: rateHour; }
#rateForm .rate-date-col { grid-area: rateDate; }
#rateForm .rate-note-col { grid-area: rateNote; }
#rateForm .rate-actions-vertical { grid-area: rateActions; }

#rateForm .rate-actions-vertical {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  gap: 6px;
  margin: 0;
  padding: 0;
}

#rateForm .rate-actions-vertical .compact-save-button,
#rateForm .rate-actions-vertical button {
  flex: 0 0 34px !important;
  width: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  padding: 0 !important;
  border-radius: 10px !important;
  font-size: 16px !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#rateForm #rateYear,
#rateForm #hourlyRate,
#rateForm #rateValidFrom,
#rateForm #rateNote {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

#rateForm #rateYear,
#rateForm #hourlyRate,
#rateForm #rateValidFrom {
  text-align: center;
}

@media (max-width: 768px) {
  #rateForm.rate-form-compact .rate-main-row {
    grid-template-columns: minmax(0, 0.72fr) minmax(0, 0.92fr) minmax(0, 1.22fr) 34px;
    grid-template-areas:
      "rateYear rateHour rateDate rateDate"
      "rateNote rateNote rateNote rateActions";
    gap: 6px;
    max-width: 100%;
  }

  #rateForm.rate-form-compact label {
    line-height: 1.15;
  }

  #rateForm #rateYear,
  #rateForm #hourlyRate,
  #rateForm #rateValidFrom,
  #rateForm #rateNote {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 13px;
  }
}


/* ===== V13: НОВА УСЛУГА — само полето „Дата“ като полето „Остатък часове“ ===== */
@media (max-width: 640px) {
  .service-main-row > .form-col:nth-child(6) {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
  }

  .service-main-row > .form-col:nth-child(6) label {
    display: block;
    width: 100%;
  }

  #serviceDate {
    -webkit-appearance: none !important;
    appearance: none !important;
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    inline-size: 100% !important;
    min-inline-size: 0 !important;
    max-inline-size: 100% !important;
    height: 43px !important;
    min-height: 43px !important;
    max-height: 43px !important;
    box-sizing: border-box !important;
    padding: 8px 10px !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: 10px !important;
    background: #ffffff !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    text-align: center !important;
    overflow: hidden !important;
  }

  #serviceDate::-webkit-date-and-time-value {
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
  }

  #serviceDate::-webkit-calendar-picker-indicator {
    display: none !important;
  }
}



/* ===== ГРАФИК — мобилна форма „Нов ангажимент“: прибрани полета в контейнера ===== */
@media (max-width: 768px) {
  .schedule-form,
  .schedule-form .form-row,
  .schedule-form .form-col,
  .schedule-form .schedule-interpreting-fields,
  .schedule-form .schedule-interpreting-fields .form-row {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .schedule-form,
  .schedule-form .form-row,
  .schedule-form .schedule-interpreting-fields {
    overflow: hidden;
  }

  .schedule-form input,
  .schedule-form select,
  .schedule-form textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .schedule-time-row {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.82fr) minmax(0, 0.82fr) !important;
    gap: 4px;
    align-items: end;
  }

  .schedule-time-row .form-col,
  .schedule-time-row .compact-time-col {
    min-width: 0;
    max-width: 100%;
  }

  #scheduleDate,
  #scheduleStartTime,
  #scheduleEndTime {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding-left: 8px;
    padding-right: 8px;
    text-align: center;
  }

  .schedule-form textarea {
    max-width: 100%;
  }
}

/* ===== V14: НОВА УСЛУГА — само изравняване на височината на „Дата“ с „Часове преди“ ===== */
@media (max-width: 640px) {
  #serviceDate {
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
    line-height: 1 !important;
  }

  #serviceDate::-webkit-date-and-time-value {
    line-height: 1 !important;
  }
}


/* ===== ГРАФИК — мобилен „Нов ангажимент“: Дата / от / до без застъпване ===== */
@media (max-width: 768px) {
  .schedule-time-row {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.72fr) minmax(0, 0.72fr) !important;
    gap: 4px !important;
    width: 100%;
    max-width: 100%;
    align-items: end;
  }

  .schedule-time-row > .form-col,
  .schedule-time-row > .compact-time-col {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    overflow: hidden;
  }

  .schedule-time-row label {
    margin-bottom: 4px;
  }

  .schedule-time-row input[type="date"],
  .schedule-time-row input[type="time"] {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
    padding: 8px 6px !important;
    font-size: 15px !important;
    line-height: 1.2;
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
  }

  #scheduleDate {
    letter-spacing: 0;
  }

  #scheduleStartTime,
  #scheduleEndTime {
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
  }

  .schedule-time-row input[type="date"]::-webkit-date-and-time-value,
  .schedule-time-row input[type="time"]::-webkit-date-and-time-value {
    text-align: center;
  }
}


/* ===== Месечен отчет — мобилна таблица в контейнер със страничен скрол ===== */
@media (max-width: 768px) {
  #monthlyReportBox {
    max-width: 100%;
    overflow: hidden;
  }

  #monthlyReportBox .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
  }

  #monthlyReportBox .report-table {
    width: max-content;
    min-width: 760px;
    max-width: none;
  }

  #monthlyReportBox .report-table th,
  #monthlyReportBox .report-table td {
    white-space: nowrap;
  }
}


/* ===== Месечен отчет — мобилна компактна обобщаваща част над таблицата ===== */
@media (max-width: 768px) {
  #monthlyReportBox.result-box,
  #monthlyReportBox {
    padding: 12px 12px 14px;
    margin-top: 8px;
  }

  #monthlyReportBox > p {
    margin: 0 0 8px 0;
    padding: 0;
    font-size: 16px;
    line-height: 1.25;
  }

  #monthlyReportBox > p:last-of-type {
    margin-bottom: 10px;
  }

  #monthlyReportBox .table-wrap {
    margin-top: 8px;
  }
}


/* ===== Обяснения — мобилен ред: № на писмо от ДСП | Днешна дата ===== */
@media (max-width: 560px) {
  .explanation-main-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(112px, 128px) !important;
    grid-template-areas:
      "request request"
      "type type"
      "letter date" !important;
    gap: 8px 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
    align-items: end;
  }

  .explanation-field-request { grid-area: request; }
  .explanation-field-type { grid-area: type; }
  .explanation-field-letter { grid-area: letter; }
  .explanation-field-date { grid-area: date; }

  .explanation-main-fields .form-col,
  .explanation-main-fields input,
  .explanation-main-fields select {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .explanation-field-date input[type="date"] {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding-left: 5px !important;
    padding-right: 5px !important;
    font-size: 12px !important;
    line-height: 1.15 !important;
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
  }

  .explanation-field-date input[type="date"]::-webkit-date-and-time-value {
    text-align: center;
    margin: 0;
    padding: 0;
  }

  .explanation-field-letter input {
    width: 100% !important;
  }
}


/* ===== Настройки — мобилно поле „В сила от“ компактна дата ===== */
@media (max-width: 768px) {
  #settingsTab #rateForm.rate-form-compact .rate-main-row {
    display: grid;
    grid-template-columns: minmax(58px, 0.62fr) minmax(82px, 0.88fr) minmax(116px, 128px) 34px !important;
    grid-template-areas:
      "rateYear rateHour rateDate rateActions"
      "rateNote rateNote rateNote rateActions" !important;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  #settingsTab #rateForm .rate-date-col {
    min-width: 0;
    max-width: 128px;
    width: 100%;
    box-sizing: border-box;
    justify-self: end;
  }

  #settingsTab #rateForm #rateValidFrom {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 128px !important;
    box-sizing: border-box;
    padding-left: 5px !important;
    padding-right: 5px !important;
    font-size: 12px !important;
    line-height: 1.15 !important;
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
  }

  #settingsTab #rateForm #rateValidFrom::-webkit-date-and-time-value {
    text-align: center;
    margin: 0;
    padding: 0;
  }
}

/* fallback за копия/стари шаблони, където формата със ставки е four-cols */
@media (max-width: 768px) {
  #settingsTab #rateForm .form-row.four-cols {
    display: grid;
    grid-template-columns: minmax(58px, 0.62fr) minmax(82px, 0.88fr) minmax(116px, 128px) !important;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
    align-items: end;
  }

  #settingsTab #rateForm .form-row.four-cols > .form-col {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  #settingsTab #rateForm .form-row.four-cols > .form-col:nth-child(4) {
    grid-column: 1 / -1;
  }
}


/* ===== Настройки — мобилно „Ставки“: без Бележка/основание ===== */
@media (max-width: 768px) {
  #settingsTab #rateForm .rate-note-col,
  #settingsTab #rateForm #rateNote,
  #settingsTab #rateForm label[for="rateNote"] {
    display: none !important;
  }

  #settingsTab #rateForm.rate-form-compact .rate-main-row {
    display: grid;
    grid-template-columns: minmax(54px, 0.62fr) minmax(82px, 0.9fr) minmax(116px, 128px) 34px !important;
    grid-template-areas: "rateYear rateHour rateDate rateActions" !important;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
    align-items: end;
  }

  #settingsTab #rateForm .rate-actions-vertical {
    grid-area: rateActions;
    align-self: end;
  }

  #settingsTab #rateForm .rate-year-col,
  #settingsTab #rateForm .rate-hour-col,
  #settingsTab #rateForm .rate-date-col,
  #settingsTab #rateForm .rate-actions-vertical {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  #settingsTab #rateForm #rateYear,
  #settingsTab #rateForm #hourlyRate,
  #settingsTab #rateForm #rateValidFrom {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
}

/* fallback за копия/стари шаблони, където формата със ставки е four-cols */
@media (max-width: 768px) {
  #settingsTab #rateForm .form-row.four-cols > .form-col:nth-child(4) {
    display: none !important;
  }
}


/* ===== Настройки — мобилно „Ставки“: бутоните горе срещу заглавието ===== */
@media (max-width: 768px) {
  #settingsTab .settings-block:has(#rateForm) {
    position: relative;
  }

  #settingsTab .settings-block:has(#rateForm) > h3 {
    min-height: 34px;
    padding-right: 86px;
    display: flex;
    align-items: center;
  }

  #settingsTab #rateForm {
    position: relative;
  }

  #settingsTab #rateForm.rate-form-compact .rate-main-row {
    grid-template-columns: minmax(54px, 0.64fr) minmax(82px, 0.92fr) minmax(116px, 128px) !important;
    grid-template-areas: "rateYear rateHour rateDate" !important;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  #settingsTab #rateForm .rate-actions-vertical,
  #settingsTab #rateForm > .button-row.single-action-row {
    position: absolute !important;
    top: -40px !important;
    right: 0 !important;
    z-index: 3;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 6px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 80px !important;
    height: 34px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #settingsTab #rateForm .rate-actions-vertical .compact-save-button,
  #settingsTab #rateForm .rate-actions-vertical button,
  #settingsTab #rateForm > .button-row.single-action-row .compact-save-button,
  #settingsTab #rateForm > .button-row.single-action-row button {
    flex: 0 0 34px !important;
    width: 34px !important;
    min-width: 34px !important;
    max-width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    padding: 0 !important;
  }

  #settingsTab #rateForm .rate-year-col,
  #settingsTab #rateForm .rate-hour-col,
  #settingsTab #rateForm .rate-date-col {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  #settingsTab #rateForm .rate-date-col {
    justify-self: end;
  }
}


/* ===== Профил — мобилно: бутоните при снимката хоризонтално ===== */
@media (max-width: 640px) {
  #profileTab .profile-topline {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  #profileTab .profile-avatar-panel {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr) !important;
    align-items: center;
    justify-content: start;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  #profileTab .profile-avatar-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    width: auto;
    overflow: hidden;
  }

  #profileTab .profile-avatar-actions .icon-mini-button,
  #profileTab .profile-avatar-actions button,
  #profileTab .profile-avatar-actions label {
    flex: 0 0 30px;
    width: 30px;
    min-width: 30px;
    max-width: 30px;
    height: 30px;
    min-height: 30px;
    max-height: 30px;
    box-sizing: border-box;
  }
}


/* ===== Потвърждения — desktop подредба на формата ===== */
@media (min-width: 769px) {
  #confirmationsTab #confirmationForm {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.45fr);
    grid-template-areas:
      "top signature"
      "preview signature"
      "participant signature"
      "phone signature"
      "text signature"
      "online signature"
      "noteLabel noteLabel"
      "note note"
      "actions actions";
    gap: 8px 14px;
    align-items: start;
  }

  #confirmationsTab .confirmation-top-fields {
    grid-area: top;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, 0.55fr) minmax(160px, 0.55fr);
    grid-template-areas:
      "service service service"
      "comm method method";
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  #confirmationsTab .confirmation-service-field { grid-area: service; }
  #confirmationsTab .confirmation-top-fields > .form-col:nth-child(2) { grid-area: comm; }
  #confirmationsTab .confirmation-top-fields > .form-col:nth-child(3) { grid-area: method; }

  #confirmationsTab #confirmationServicePreview {
    grid-area: preview;
    margin: 0;
  }

  #confirmationsTab .confirmation-participant-fields {
    grid-area: participant;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #confirmationsTab .confirmation-phone-row {
    grid-area: phone;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
  }

  #confirmationsTab .confirmation-phone-row #confirmationParticipantPhone {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  #confirmationsTab #confirmationTextPreview {
    grid-area: text;
    margin: 0;
  }

  #confirmationsTab #confirmationOnlinePlaceholder {
    grid-area: online;
  }

  #confirmationsTab #signaturePadBlock {
    grid-area: signature;
    align-self: start;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin-top: 0;
  }

  #confirmationsTab #signaturePadBlock .signature-canvas,
  #confirmationsTab #confirmationSignatureCanvas {
    height: 70px;
    max-height: 70px;
  }

  #confirmationsTab label[for="confirmationNote"] {
    grid-area: noteLabel;
    margin-top: 2px;
  }

  #confirmationsTab #confirmationNote {
    grid-area: note;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  #confirmationsTab #confirmationForm > .button-row.single-action-row {
    grid-area: actions;
  }

  #confirmationsTab .confirmation-top-fields .form-col,
  #confirmationsTab .confirmation-participant-fields .form-col,
  #confirmationsTab .confirmation-top-fields select,
  #confirmationsTab .confirmation-participant-fields input,
  #confirmationsTab .confirmation-participant-fields select {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
}


/* ===== Потвърждения — desktop: по-голямо поле за подпис вдясно ===== */
@media (min-width: 769px) {
  #confirmationsTab #confirmationForm {
    grid-template-columns: minmax(0, 1fr) minmax(230px, 0.42fr);
  }

  #confirmationsTab #signaturePadBlock {
    justify-self: end;
    width: min(100%, 230px);
  }

  #confirmationsTab #signaturePadBlock .signature-canvas,
  #confirmationsTab #confirmationSignatureCanvas {
    height: 150px !important;
    max-height: 150px !important;
  }
}


/* ===== Потвърждения — desktop: подписът използва празното място вдясно ===== */
@media (min-width: 769px) {
  #confirmationsTab #confirmationForm {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 380px) !important;
  }

  #confirmationsTab #signaturePadBlock {
    justify-self: end;
    width: 100% !important;
    max-width: 380px !important;
    min-width: 340px !important;
  }

  #confirmationsTab #signaturePadBlock .signature-canvas,
  #confirmationsTab #confirmationSignatureCanvas {
    width: 100% !important;
    height: 180px !important;
    max-height: 180px !important;
    box-sizing: border-box;
  }
}


/* ===== Облик: готови цветови теми само за интерфейса ===== */
:root,
body.theme-classic {
  --page-top: #f5fbf8;
  --primary-dark: #4a7e7b;
  --input-bg: #ffffff;
  --danger: #b45c46;
  --success: #4b8d62;
}

body.theme-blue {
  --page-top: #f6f9fc;
  --bg: #edf3f8;
  --card: #ffffff;
  --card-soft: #f6f9fc;
  --border: #c7d6e4;
  --border-strong: #aebfd1;
  --text: #26384d;
  --muted: #65768a;
  --primary: #3f79a8;
  --primary-2: #6ea4c8;
  --primary-dark: #2f638f;
  --primary-soft: #e6f0f7;
  --accent: #4f89b5;
  --accent-soft: #edf5fb;
  --input-bg: #ffffff;
  --shadow: 0 6px 16px rgba(56, 91, 125, 0.12);
}

body.theme-purple {
  --page-top: #fbf8fd;
  --bg: #f1edf7;
  --card: #ffffff;
  --card-soft: #faf7fc;
  --border: #d9cde4;
  --border-strong: #c5b3d2;
  --text: #3e3447;
  --muted: #74667d;
  --primary: #7b5a9e;
  --primary-2: #a079b3;
  --primary-dark: #664882;
  --primary-soft: #f0e8f5;
  --accent: #8f6aa8;
  --accent-soft: #f6eef8;
  --input-bg: #ffffff;
  --shadow: 0 6px 16px rgba(105, 78, 125, 0.12);
}

body.theme-warm {
  --page-top: #fffaf2;
  --bg: #f4ecdf;
  --card: #ffffff;
  --card-soft: #fff8ed;
  --border: #dfcfbb;
  --border-strong: #cbb79d;
  --text: #493b31;
  --muted: #7d6d5f;
  --primary: #b67858;
  --primary-2: #c99a68;
  --primary-dark: #8f6048;
  --primary-soft: #f7eadf;
  --accent: #b7895e;
  --accent-soft: #fbf1e6;
  --input-bg: #ffffff;
  --shadow: 0 6px 16px rgba(126, 94, 66, 0.12);
}

body.theme-dark {
  --page-top: #1a222d;
  --bg: #111820;
  --card: #1d2732;
  --card-soft: #24303c;
  --border: #3a4856;
  --border-strong: #516171;
  --text: #e2e8ee;
  --muted: #aab6c2;
  --primary: #6f9fbd;
  --primary-2: #72b7aa;
  --primary-dark: #9bc7db;
  --primary-soft: #203647;
  --accent: #8ab79f;
  --accent-soft: #24372f;
  --input-bg: #17212b;
  --success-bg: #1f3c2c;
  --success-border: #3f7653;
  --error-bg: #3c2325;
  --error-border: #7a4c4f;
  --shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

body {
  background: linear-gradient(180deg, var(--page-top, #f5fbf8) 0%, var(--bg) 100%);
}

body.theme-blue .section-heading h2,
body.theme-purple .section-heading h2,
body.theme-warm .section-heading h2,
body.theme-dark .section-heading h2,
body.theme-blue h3,
body.theme-purple h3,
body.theme-warm h3,
body.theme-dark h3,
body.theme-blue label,
body.theme-purple label,
body.theme-warm label,
body.theme-dark label {
  color: var(--primary-dark);
}

body[class*="theme-"] input,
body[class*="theme-"] select,
body[class*="theme-"] textarea {
  background: var(--input-bg);
  color: var(--text);
  border-color: var(--border-strong);
}

body.theme-dark .app-card,
body.theme-dark .auth-card,
body.theme-dark .profile-mini-section,
body.theme-dark .table-wrap,
body.theme-dark .result-box,
body.theme-dark .confirmation-text-preview,
body.theme-dark .schedule-day,
body.theme-dark .theme-option-button {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

body.theme-dark .settings-table th,
body.theme-dark .report-table th,
body.theme-dark .services-table th {
  background: var(--card-soft);
  color: var(--primary-dark);
}

body.theme-dark .settings-table tbody tr:nth-child(even),
body.theme-dark .report-table tbody tr:nth-child(even),
body.theme-dark .services-table tbody tr:nth-child(even) {
  background: #1a2430;
}

body[class*="theme-"] .btn-primary,
body[class*="theme-"] button.btn-primary,
body[class*="theme-"] #generateProtocolButton {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #ffffff;
}

body[class*="theme-"] .btn-secondary,
body[class*="theme-"] button.btn-secondary {
  background: linear-gradient(135deg, var(--primary-2) 0%, var(--primary) 100%);
  color: #ffffff;
}

body[class*="theme-"] .btn-ghost,
body[class*="theme-"] button.btn-ghost {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.theme-settings-block {
  max-width: 760px;
}

.theme-picker-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(104px, 1fr));
  gap: 8px;
}

.theme-option-button {
  position: relative;
  min-height: 58px;
  padding: 8px 28px 8px 9px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  box-shadow: none;
  display: grid;
  gap: 5px;
  align-items: center;
  justify-items: start;
  text-align: left;
}

.theme-option-button:hover {
  border-color: var(--primary);
  background: var(--card-soft);
}

.theme-option-button.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.theme-option-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.theme-check {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.theme-option-button.active .theme-check {
  display: inline-flex;
}

.theme-preview-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.theme-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.08);
}

.classic-bg { background:#eef4f0; } .classic-primary { background:#7cc7c4; } .classic-button { background:#66b9c8; } .classic-text { background:#31433f; }
.blue-bg { background:#edf3f8; } .blue-primary { background:#3f79a8; } .blue-button { background:#6ea4c8; } .blue-text { background:#26384d; }
.purple-bg { background:#f1edf7; } .purple-primary { background:#7b5a9e; } .purple-button { background:#a079b3; } .purple-text { background:#3e3447; }
.warm-bg { background:#f4ecdf; } .warm-primary { background:#b67858; } .warm-button { background:#c99a68; } .warm-text { background:#493b31; }
.dark-bg { background:#111820; } .dark-primary { background:#6f9fbd; } .dark-button { background:#72b7aa; } .dark-text { background:#e2e8ee; }

.theme-result-box {
  margin-top: 8px;
}

@media (max-width: 768px) {
  .theme-settings-block {
    max-width: 100%;
  }

  .theme-picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .theme-option-button {
    min-height: 48px;
    padding: 7px 26px 7px 8px;
  }

  .theme-dot {
    width: 11px;
    height: 11px;
  }
}


/* ===== Облик: общи интерфейсни елементи през CSS променливи ===== */
body[class*="theme-"] .app-card,
body[class*="theme-"] .auth-card,
body[class*="theme-"] .profile-topline,
body[class*="theme-"] .profile-mini-section,
body[class*="theme-"] .schedule-day,
body[class*="theme-"] .table-wrap,
body[class*="theme-"] .client-mode-tabs,
body[class*="theme-"] .report-mode-tabs,
body[class*="theme-"] .theme-option-button {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

body[class*="theme-"] .settings-block {
  border-top-color: var(--border);
}

body[class*="theme-"] .result-box,
body[class*="theme-"] .confirmation-text-preview,
body[class*="theme-"] .schedule-warning-box,
body[class*="theme-"] .online-placeholder {
  background: var(--card-soft);
  color: var(--text);
  border-color: var(--border);
}

body[class*="theme-"] .services-table th,
body[class*="theme-"] .report-table th,
body[class*="theme-"] .settings-table th {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

body[class*="theme-"] .services-table tbody tr:nth-child(even),
body[class*="theme-"] .report-table tbody tr:nth-child(even),
body[class*="theme-"] .settings-table tbody tr:nth-child(even) {
  background: var(--card-soft);
}

body[class*="theme-"] .client-mode-button.active,
body[class*="theme-"] .report-mode-button.active {
  color: var(--primary-dark);
  border-color: var(--border);
}


/* ===== Облик — хедърът/горната лента също следва избраната тема ===== */
body[class*="theme-"] .app-header {
  background: linear-gradient(135deg, var(--primary-soft) 0%, var(--primary-2) 52%, var(--accent-soft) 100%);
  color: var(--text);
  border-color: color-mix(in srgb, var(--border) 65%, #ffffff 35%);
  box-shadow: var(--shadow);
}

body[class*="theme-"] .brand-text h1 {
  color: var(--text);
}

body[class*="theme-"] .brand-subtitle,
body[class*="theme-"] .brand-author-script {
  color: var(--muted);
}

body[class*="theme-"] .header-icon-button {
  background: color-mix(in srgb, var(--card) 78%, transparent);
  color: var(--primary-dark);
  border-color: color-mix(in srgb, var(--border) 75%, #ffffff 25%);
}

body[class*="theme-"] .header-icon-button:hover,
body[class*="theme-"] .header-icon-button.active {
  background: var(--card);
  color: var(--primary-dark);
}

body.theme-dark .app-header {
  background: linear-gradient(135deg, #182431 0%, #24384b 52%, #202f38 100%);
  border-color: var(--border);
}

body.theme-dark .header-icon-button {
  background: #22303d;
  color: var(--text);
  border-color: var(--border-strong);
}

body.theme-dark .header-icon-button:hover,
body.theme-dark .header-icon-button.active {
  background: #2c3b49;
  color: var(--primary-dark);
}


/* ===== Вход — тикче за запомняне на паролата ===== */
.auth-remember-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: max-content;
  max-width: 100%;
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.auth-remember-row input {
  width: 15px;
  height: 15px;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.auth-remember-row span {
  line-height: 1.2;
}
