:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fafd;
  --line: #e3e7ee;
  --line-strong: #d3dae6;
  --frame-line: #dfe4ec;
  --frame-line-strong: #d3dae6;
  --text: #202124;
  --muted: #5f6368;
  --primary: #1a73e8;
  --primary-hover: #185abc;
  --primary-soft: #e8f0fe;
  --danger-bg: #fff1f2;
  --danger-border: #fecdd3;
  --danger-text: #9f1239;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg) !important;
  color: var(--text) !important;
  font-family: "Segoe UI", Arial, sans-serif !important;
  position: relative;
}

body::before {
  content: none !important;
  display: none !important;
}

h1,
h2,
h3,
h4,
h5,
h6,
.tab-service-head,
.service-head,
.users-service-head,
.edit-service-head {
  color: var(--text) !important;
  font-family: "Segoe UI", Arial, sans-serif !important;
}

a,
.links a {
  color: #334155;
}

.top,
.top-inner,
.card,
.tab-service,
.service-panel,
.hero-card,
.users-service,
.edit-service {
  background: var(--surface) !important;
  border: 1px solid var(--frame-line) !important;
  box-shadow:
    0 1px 1px rgba(32, 33, 36, 0.08),
    0 1px 3px rgba(32, 33, 36, 0.06) !important;
}

.tab-service-head,
.edit-service-head,
.users-service-head {
  background: var(--surface-soft) !important;
  border-color: var(--line) !important;
}

.tab-service-actions,
.edit-service-actions,
.users-service-actions,
.tab-service-body,
.edit-service-body,
.users-service-body {
  background: var(--surface) !important;
  border-color: var(--line) !important;
}

input,
select,
textarea {
  border: 1px solid var(--line-strong) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
}

input::placeholder,
textarea::placeholder {
  color: #92a0b2 !important;
  opacity: 1 !important;
  font-style: italic;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #8aa0be !important;
  box-shadow: 0 0 0 3px rgba(59, 91, 135, 0.14);
}

button,
input[type="button"],
input[type="submit"],
.btn,
.btn2,
.tab,
.tab-btn,
.btn-accent,
.gear,
.tool-btn {
  border: 1px solid var(--line-strong) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  box-shadow: none !important;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

button:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
.btn:hover,
.btn2:hover,
.tab:hover,
.tab-btn:hover,
.btn-accent:hover,
.gear:hover {
  background: var(--surface-soft) !important;
  border-color: #b4bfcd !important;
  color: var(--text) !important;
  filter: none;
}

.btn-primary,
.submit-bottom,
button[type="submit"]:not(.btn):not(.btn2):not(.tab):not(.tab-btn):not(.btn-accent):not(.btn-danger):not(.icon-btn-danger),
input[type="submit"] {
  border-color: #d2e3fc !important;
  background: #e8f0fe !important;
  color: #174ea6 !important;
}

.btn-primary strong,
.submit-bottom strong {
  color: #174ea6 !important;
}

.btn-primary:hover,
.submit-bottom:hover,
button[type="submit"]:not(.btn):not(.btn2):not(.tab):not(.tab-btn):not(.btn-accent):not(.btn-danger):not(.icon-btn-danger):hover,
input[type="submit"]:hover {
  border-color: #b9d0fb !important;
  background: #dce8fd !important;
  color: #174ea6 !important;
}

.btn.is-active,
.btn2.is-active,
.tab.is-active,
.tab-btn.is-active,
.tool-btn.is-active,
.nav-btn.active,
.page-actions .btn2.active {
  border-color: #c3d4fb !important;
  background: #dce8fd !important;
  color: #174ea6 !important;
  font-weight: 700 !important;
}

.btn:disabled,
.btn2:disabled,
.tool-btn:disabled,
.tab:disabled,
.tab-btn:disabled,
button:disabled,
input[type="submit"]:disabled,
input[type="button"]:disabled {
  opacity: 0.72 !important;
  color: #7b8794 !important;
  border-color: #cdd5e1 !important;
  background: #edf1f5 !important;
  font-weight: 600 !important;
  cursor: not-allowed !important;
  filter: none !important;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.12) !important;
  transform: translateY(1px);
}

.btn.is-pressed:disabled,
.btn2.is-pressed:disabled,
.tool-btn.is-pressed:disabled,
.tab.is-pressed:disabled,
.tab-btn.is-pressed:disabled,
button.is-pressed:disabled,
input[type="submit"].is-pressed:disabled,
input[type="button"].is-pressed:disabled {
  color: #1f4f9f !important;
  border-color: #9fbef9 !important;
  background: #dde9ff !important;
  font-weight: 800 !important;
}

.btn.is-pressed:disabled,
.btn2.is-pressed:disabled,
.tool-btn.is-pressed:disabled,
.tab.is-pressed:disabled,
.tab-btn.is-pressed:disabled,
button.is-pressed:disabled {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn.is-pressed:disabled::before,
.btn2.is-pressed:disabled::before,
.tool-btn.is-pressed:disabled::before,
.tab.is-pressed:disabled::before,
.tab-btn.is-pressed:disabled::before,
button.is-pressed:disabled::before {
  content: "●";
  color: #1a73e8;
  font-size: 10px;
  line-height: 1;
}

.btn.is-save-done:disabled,
.btn2.is-save-done:disabled,
.tool-btn.is-save-done:disabled,
button.is-save-done:disabled,
input[type="submit"].is-save-done:disabled,
input[type="button"].is-save-done:disabled {
  border-color: #d8b07b !important;
  background: #fff4e5 !important;
  color: #8a4b08 !important;
  font-weight: 800 !important;
}

.btn.is-save-done:disabled::before,
.btn2.is-save-done:disabled::before,
.tool-btn.is-save-done:disabled::before,
button.is-save-done:disabled::before {
  color: #c06b00 !important;
}

.btn.is-editing,
.btn2.is-editing,
.tool-btn.is-editing,
.btn.is-editing:disabled,
.btn2.is-editing:disabled,
.tool-btn.is-editing:disabled {
  border-color: #d8b07b !important;
  background: #fff4e5 !important;
  color: #8a4b08 !important;
  font-weight: 800 !important;
}

.btn.is-editing:disabled::before,
.btn2.is-editing:disabled::before,
.tool-btn.is-editing:disabled::before {
  content: "●";
  color: #c06b00;
  font-size: 10px;
  line-height: 1;
}

.tab.active,
.tab-btn.active {
  border-color: #d2e3fc !important;
  background: #e8f0fe !important;
  color: #174ea6 !important;
}

.btn-danger,
.icon-btn-danger {
  border: 1px solid var(--danger-border) !important;
  background: var(--danger-bg) !important;
  color: var(--danger-text) !important;
}

.btn-danger:hover,
.icon-btn-danger:hover {
  border-color: #e58a9a !important;
  background: #ffecef !important;
  color: #881337 !important;
}

.msg,
.topmsg {
  background: #ffffff !important;
  border-color: var(--frame-line) !important;
  border-left: 3px solid #bdc9da !important;
  color: var(--text) !important;
}

.toast-msg {
  position: fixed !important;
  right: 16px !important;
  bottom: 16px !important;
  margin: 0 !important;
  min-width: 260px;
  max-width: min(440px, calc(100vw - 24px));
  padding: 11px 40px 11px 13px !important;
  border-radius: 12px !important;
  box-shadow:
    0 8px 24px rgba(15, 23, 42, 0.2),
    0 1px 2px rgba(15, 23, 42, 0.14) !important;
  z-index: 5200 !important;
  pointer-events: auto;
  overflow: hidden;
  animation:
    toast-enter 220ms ease-out 1,
    toast-exit 460ms ease-in 5.6s forwards;
}

.toast-msg-text {
  display: block;
  padding-right: 2px;
}

.toast-close-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #c8d4e3 !important;
  background: #ffffff !important;
  color: #5f6b7a !important;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none !important;
}

.toast-close-btn:hover {
  border-color: #adbed3 !important;
  background: #f5f8fc !important;
  color: #2f3d52 !important;
}

.toast-close-btn:focus-visible {
  outline: 2px solid #8aa0be;
  outline-offset: 1px;
}

.toast-msg:hover {
  animation-play-state: paused;
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-exit {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
  }
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
    visibility: hidden;
    pointer-events: none;
  }
}

@media (max-width: 700px) {
  .toast-msg {
    right: 10px !important;
    left: 10px !important;
    bottom: 10px !important;
    min-width: 0;
    max-width: none;
  }
}

.err,
.error {
  background: var(--danger-bg) !important;
  border-color: var(--danger-border) !important;
  color: var(--danger-text) !important;
}

.muted {
  color: var(--muted) !important;
}

table th {
  background: var(--surface-soft);
  color: var(--text);
}

table th,
table td {
  border-color: #e6ebf1 !important;
}

.role,
.status-tag {
  background: var(--surface-soft) !important;
  border-color: var(--line) !important;
  color: #334155 !important;
}

.loading-wrap {
  background: #e8edf3 !important;
}

.loading-bar {
  background: var(--primary) !important;
}

.page-head {
  background: var(--surface) !important;
  border: 1px solid var(--frame-line) !important;
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(32, 33, 36, 0.08);
}

.page-crumbs {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  margin: 0;
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.page-crumbs a {
  text-decoration: none;
  color: #1f3a66;
  font-weight: 600;
}

.page-crumbs span {
  color: var(--muted);
}

.page-head-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 12px;
  align-items: center;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text) !important;
}

.page-subtitle {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}

.session-user {
  display: inline-flex;
  align-items: center;
  max-width: 320px;
  padding: 8px 12px;
  border: 1px solid #d6deea !important;
  border-radius: 999px;
  background: #ffffff !important;
  color: #3c4043 !important;
  font-size: 14px;
  font-weight: 600;
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-icon-btn {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.list-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #e7ebf1;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.list-table th,
.list-table td {
  padding: 11px 12px !important;
  vertical-align: top;
}

.list-table thead th {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #5f6368 !important;
  background: #f8fafd !important;
  border-bottom: 1px solid #e4e8ef !important;
}

.list-table tbody td {
  border-bottom: 1px solid #edf1f6 !important;
}

.list-table tbody tr:last-child td {
  border-bottom: none !important;
}

.list-title {
  display: block;
  max-width: 900px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: #202124;
}

.list-meta,
.list-note {
  display: block;
  max-width: 980px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted) !important;
}

.list-note {
  font-size: 13px;
}

.tab-content.active,
.users-content {
  border: 1px solid var(--frame-line);
  border-radius: 16px;
  padding: 12px 12px 14px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(32, 33, 36, 0.08);
}

.list-table tbody tr:hover td {
  background: #f5f9ff;
}

.list-table tbody tr:focus,
.list-table tbody tr:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.list-table tbody tr.active-row td {
  background: #fff !important;
  border-top: 1px solid #8ab4f8 !important;
  border-bottom: 1px solid #8ab4f8 !important;
}

.list-table tbody tr.active-row td:first-child {
  border-left: 1px solid #8ab4f8 !important;
}

.list-table tbody tr.active-row td:last-child {
  border-right: 1px solid #8ab4f8 !important;
}

.list-table tbody tr.active-row .list-title {
  font-weight: 800 !important;
}

.list-table tbody tr.row-action td {
  padding-top: 24px !important;
}

.list-table tbody tr.row-action td:first-child {
  position: relative;
}

.list-table tbody tr.row-action td:first-child::before {
  content: attr(data-row-action);
  position: absolute;
  top: 4px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid #d8b07b;
  background: #fff4e5;
  color: #8a4b08;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.list-table tbody tr.row-action.row-action-done td:first-child::before {
  border-color: #9ac39a;
  background: #ecf9ec;
  color: #2f6b2f;
}

.list-table tbody tr.editing-row td {
  background: #fff9f0 !important;
  border-top: 1px solid #d8b07b !important;
  border-bottom: 1px solid #d8b07b !important;
}

.list-table tbody tr.editing-row td:first-child {
  border-left: 1px solid #d8b07b !important;
}

.list-table tbody tr.editing-row td:last-child {
  border-right: 1px solid #d8b07b !important;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

.tab,
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px !important;
  border: 1px solid #dde3ed !important;
  padding: 8px 14px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #3c4043 !important;
  background: #fff !important;
  text-decoration: none !important;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  min-width: 16px;
  height: 16px;
  margin-right: 2px;
  color: #516a8f;
  line-height: 1;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab:hover,
.tab-btn:hover {
  border-color: #ccd3df !important;
  background: #f7f9fc !important;
}

.tab-count {
  display: inline-flex;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid #d2d8e2;
  background: #f1f4f9;
  color: #3c4043;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
}

.tab.active .tab-count,
.tab-btn.active .tab-count {
  border-color: #c3d4fb;
  background: #dce8fd;
  color: #174ea6;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 700;
  color: #202124 !important;
}

.counter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #dde3ed;
  background: #f7f9fc;
  color: #4a4f56;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.counter-pill strong {
  color: #202124;
  font-weight: 700;
}

.gmail-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 10px;
}

.gmail-toolbar-main,
.gmail-toolbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-tag,
.role {
  border-radius: 999px !important;
  padding: 4px 10px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border: 1px solid #d8dde6 !important;
  background: #f7f9fc !important;
  color: #3c4043 !important;
}

.status-tag.blocked {
  border-color: #f2c7cc !important;
  background: #fff2f4 !important;
  color: #9b2c42 !important;
}

.status-tag.disabled {
  border-color: #e2e6ec !important;
  background: #f3f4f6 !important;
  color: #5f6368 !important;
}

.status-tag.pending {
  border-color: #cbdcf8 !important;
  background: #edf3fe !important;
  color: #174ea6 !important;
}

.tab-service-head,
.users-service-head,
.edit-service-head,
.service-head {
  background: #f8fafd !important;
  color: #202124 !important;
  border-bottom: 1px solid #e4e8ef !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
}

.tab-service-actions,
.users-service-actions,
.edit-service-actions {
  background: #fff !important;
}

.readonly-hint {
  display: none;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid #d7e2f3;
  border-radius: 8px;
  background: #f6f9ff;
  color: #58719a;
  font-size: 13px;
}

form.form-readonly .readonly-hint {
  display: block;
}

form.form-readonly input:not([type="hidden"]),
form.form-readonly select,
form.form-readonly textarea,
form.form-readonly button {
  background: #f2f5fb !important;
  border-color: #d4deed !important;
  color: #60738f !important;
}

form.form-readonly input[type="checkbox"] {
  accent-color: #9fb5d8;
}

.tab-save-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 8px;
  margin-top: 2px;
  border-top: 1px solid #dce7f6;
}

.tab-save-note {
  font-size: 12px;
  color: #59739a;
  padding: 2px 8px;
  border: 1px solid #d5e2f5;
  border-radius: 999px;
  background: #f4f8ff;
}

.tab-save-row .btn:not(:disabled),
.tab-save-row .btn2:not(:disabled) {
  font-weight: 600 !important;
}

.service-toggle-btn {
  border-radius: 999px !important;
}

.search input {
  border-radius: 24px !important;
  padding-left: 14px !important;
}

.img-modal-card {
  border: 1px solid #dfe4ec !important;
  border-radius: 14px !important;
}

.portal-layout {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.portal-layout .wrap,
.portal-layout .top-inner {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  box-sizing: border-box;
  padding-left: 16px !important;
  padding-right: 16px !important;
}

.portal-layout .invoice-main,
.portal-layout .tab-main,
.portal-layout .users-main {
  min-width: 0;
}

.portal-service-brand {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid #e1e8f3;
  background: #fff;
}

.portal-service-brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  padding: 8px;
  border: 1px solid #d8e2f1;
  border-radius: 12px;
  background: #fbfdff;
}

.portal-service-brand-logo img {
  max-width: 100%;
  max-height: 68px;
  object-fit: contain;
}

.portal-service-brand-title {
  text-align: center;
  font-size: 14px;
  line-height: 1.3;
  font-weight: 700;
  color: #173c70;
  word-break: break-word;
}

.portal-service-section-title {
  padding: 8px 12px 6px;
  font-size: 15px !important;
  line-height: 1.3;
  font-weight: 700 !important;
  color: #183e72 !important;
  text-align: left;
  background: #fff !important;
  border-bottom: 1px solid #e1e8f3 !important;
}

.portal-service-panel .invoice-side-tab-btn,
.portal-service-panel .org-service-tag,
.portal-service-panel .team-service-tag,
.portal-service-panel .service-pane-tab {
  font-family: "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
}

.portal-service-panel .invoice-side-tab-icon,
.portal-service-panel .service-pane-tab-icon {
  margin-right: 4px !important;
}

@media (min-width: 1101px) {
  .portal-layout .portal-service-panel {
    position: sticky;
    top: 8px;
    align-self: start;
    max-height: calc(100vh - 98px);
    overflow-x: hidden;
  }
}

@media (max-width: 1100px) {
  .page-head-row {
    grid-template-columns: 1fr;
    row-gap: 8px;
  }

  .page-crumbs {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    flex-wrap: wrap;
  }

  .page-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    white-space: normal;
  }

  .session-user {
    max-width: 100%;
  }

  .gmail-toolbar {
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .portal-layout .wrap,
  .portal-layout .top-inner {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}
