:root {
  --office-bg: #f3f7fb;
  --office-bg-soft: #f8fbfe;
  --office-surface: #ffffff;
  --office-surface-blue: #eef6fd;
  --office-surface-red: #fdf1f2;
  --office-blue: #4f83bb;
  --office-blue-strong: #285f98;
  --office-blue-dark: #17395f;
  --office-red: #d77b86;
  --office-red-strong: #b95764;
  --office-green: #4c9870;
  --office-amber: #b3833e;
  --office-text: #1d3553;
  --office-muted: #6c7f96;
  --office-border: #dbe6f0;
  --office-border-soft: #e8eef5;
  --office-shadow: 0 10px 30px rgba(35, 68, 105, 0.07);
  --office-shadow-soft: 0 4px 16px rgba(35, 68, 105, 0.05);
  --office-radius-xl: 18px;
  --office-radius-lg: 14px;
  --office-radius-md: 10px;
  --office-sidebar: 252px;
  color-scheme: light;
}

html {
  background: var(--office-bg);
}

body {
  color: var(--office-text);
  background:
    radial-gradient(circle at 85% 5%, rgba(100, 159, 216, 0.08), transparent 26rem),
    linear-gradient(180deg, #f8fbfe 0, var(--office-bg) 18rem, var(--office-bg) 100%);
}

body:not(.login-page) {
  padding-left: var(--office-sidebar);
}

a {
  color: var(--office-blue-strong);
}

a:hover {
  color: var(--office-blue-dark);
  text-decoration: none;
}

/* ===== Office sidebar ===== */
.topbar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1000;
  width: var(--office-sidebar);
  min-height: 100vh;
  height: 100vh;
  padding: 20px 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  overflow-y: auto;
  color: var(--office-text);
  background: rgba(252, 254, 255, 0.97);
  border-right: 1px solid var(--office-border);
  box-shadow: 6px 0 24px rgba(35, 68, 105, 0.04);
  backdrop-filter: blur(10px);
}

.topbar > div:first-child {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  min-height: 62px;
  padding: 3px 5px 14px;
  border-bottom: 1px solid var(--office-border-soft);
}

.topbar > div:first-child::before {
  content: "";
  grid-row: 1 / 3;
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: #fff url('/static/favicon/favicon.svg') center / 46px 46px no-repeat;
  box-shadow: 0 6px 16px rgba(35, 68, 105, 0.10);
}

.topbar > div:first-child strong {
  align-self: end;
  color: var(--office-blue-dark);
  font-size: 1.03rem;
  line-height: 1.08;
  letter-spacing: -0.01em;
}

.topbar > div:first-child span {
  align-self: start;
  margin-top: 4px;
  color: var(--office-muted);
  font-size: 0.75rem;
  line-height: 1.25;
}

.admin-nav {
  display: flex !important;
  flex: 1 0 auto;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
  margin: 16px 0 12px;
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #425d7d;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.1;
  transition: 140ms ease;
}

.admin-nav a:hover {
  color: var(--office-blue-dark);
  background: #f0f6fc;
  border-color: #e0ebf6;
}

.admin-nav a.admin-nav-active,
.admin-nav a[aria-current="page"] {
  color: #1d5f9f;
  background: #deedfb;
  border-color: #cfe3f7;
  box-shadow: inset 3px 0 0 #5a92c9;
}

.admin-nav-icon {
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  color: #6884a4;
}

.admin-nav-active .admin-nav-icon {
  color: #2d74b5;
}

.admin-nav-icon svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
}

.topbar-actions {
  width: 100%;
  display: flex !important;
  flex-direction: column;
  gap: 8px !important;
  align-items: stretch !important;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--office-border-soft);
}

.topbar-actions > a {
  display: none !important;
}

.topbar-actions form,
.topbar > form {
  width: 100%;
  margin: 0;
}

.topbar-actions form button,
.topbar > form button {
  width: 100%;
  min-height: 38px;
  color: #60738a;
  border-color: var(--office-border);
  background: #f7fafc;
}

/* ===== Main canvas ===== */
.container,
.form-container,
.prompt-container,
.pronunciation-container,
.censorship-container,
.taxomet-container {
  width: min(1380px, calc(100% - 52px));
  max-width: 1380px;
  margin: 28px auto 56px;
}

.page-heading,
.addresses-heading,
.behavior-heading,
.prompt-editor-heading,
.pronunciation-editor-heading,
.censorship-editor-heading,
.taxomet-section-heading,
.appeal-summary {
  margin-bottom: 22px;
}

.page-heading h1,
.addresses-heading h1,
.behavior-heading h1,
main h1 {
  color: var(--office-blue-dark);
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(1.65rem, 2.2vw, 2.25rem);
}

h2,
h3 {
  color: #244564;
}

.muted,
.field-help {
  color: var(--office-muted);
}

/* ===== Cards ===== */
.form-card,
.table-card,
.empty-state,
.apply-status-card,
.address-search-card,
.address-history-card,
.address-toggle-zone,
.appeal-table-card,
.appeal-details,
.behavior-editor-card,
.behavior-test-card,
.behavior-history-card,
.behavior-active-preview,
.prompt-editor-card,
.prompt-preview-card,
.prompt-sidebar,
.pronunciation-editor-card,
.pronunciation-sidebar,
.censorship-editor-card,
.censorship-sidebar,
.censorship-guide-card,
.taxomet-services-card,
.taxomet-service-new,
.login-card,
.danger-zone,
.prompt-danger-zone,
.pronunciation-danger-zone,
.censorship-danger-zone {
  border: 1px solid var(--office-border) !important;
  border-radius: var(--office-radius-xl) !important;
  background: rgba(255, 255, 255, 0.96) !important;
  box-shadow: var(--office-shadow-soft);
}

.form-card,
.table-card,
.apply-status-card,
.address-search-card,
.appeal-table-card,
.behavior-editor-card,
.behavior-test-card,
.behavior-history-card,
.prompt-editor-card,
.pronunciation-editor-card,
.censorship-editor-card,
.taxomet-services-card {
  padding: 22px;
}

.form-card h2,
.table-card h2,
.apply-status-card h2 {
  color: #254969;
}

/* ===== Inputs ===== */
input,
select,
textarea {
  min-height: 42px;
  border: 1px solid #cfdce9;
  border-radius: var(--office-radius-md);
  color: var(--office-text);
  background: #fbfdff;
  box-shadow: inset 0 1px 2px rgba(35, 68, 105, 0.025);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b8cee2;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #76a8d6;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(91, 148, 201, 0.15);
}

label {
  color: #36536f;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: #4f83bb;
}

/* ===== Buttons ===== */
button,
.button {
  min-height: 40px;
  padding-inline: 16px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(180deg, #5e92c5, #477db2);
  box-shadow: 0 4px 10px rgba(56, 109, 162, 0.16);
  transition: transform 100ms ease, box-shadow 100ms ease, opacity 100ms ease;
}

button:hover,
.button:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(56, 109, 162, 0.20);
}

.button-secondary,
button.button-secondary {
  color: #496078;
  background: #f8fbfd;
  border: 1px solid #d5e1ec;
  box-shadow: none;
}

.button-danger,
.danger-zone button,
.prompt-danger-zone button,
.pronunciation-danger-zone button,
.censorship-danger-zone button {
  background: linear-gradient(180deg, #d98690, #c86d79);
  box-shadow: 0 4px 10px rgba(190, 86, 99, 0.15);
}

.button-apply {
  background: linear-gradient(180deg, #5f9b7b, #4b896b);
}

.link-button {
  color: var(--office-blue-strong);
  background: transparent;
  box-shadow: none;
}

.link-danger {
  color: var(--office-red-strong);
}

/* ===== Tables ===== */
.table-card,
.appeal-table-card {
  overflow: hidden;
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

th {
  padding: 11px 13px;
  color: #607791;
  background: #f6f9fc;
  border-bottom: 1px solid var(--office-border);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

td {
  padding: 12px 13px;
  color: #36516e;
  border-bottom: 1px solid #edf2f7;
}

tbody tr {
  transition: background 100ms ease;
}

tbody tr:hover {
  background: #f7fbff;
}

tbody tr:last-child td {
  border-bottom: 0;
}

/* ===== Statuses / alerts ===== */
.status,
.behavior-active-badge,
.pronunciation-entry-status {
  border-radius: 999px !important;
  font-weight: 700;
}

.status-on,
.apply-status-success {
  color: #357b58 !important;
  background: #e8f5ee !important;
}

.status-off,
.apply-status-error,
.alert-error {
  color: #aa4b58 !important;
  background: #fbecee !important;
  border-color: #f0cdd2 !important;
}

.apply-status-pending {
  color: #926a2f !important;
  background: #fff6df !important;
}

.alert-success {
  color: #357b58;
  background: #eaf7f0;
  border-color: #cce8da;
}

.alert {
  border-radius: 12px;
}

/* ===== Provider form tabs ===== */
.provider-compact-summary {
  background: linear-gradient(135deg, #f8fbff, #fdf7f8);
  border-color: var(--office-border) !important;
  box-shadow: var(--office-shadow-soft);
}

.provider-settings-tabs {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--office-border);
  box-shadow: var(--office-shadow-soft);
}

.provider-settings-tab {
  color: #63788f;
}

.provider-settings-tab:hover {
  color: var(--office-blue-strong);
  background: #f2f7fc;
}

.provider-settings-tab.is-active {
  color: #235f98;
  background: #deedfb;
}

.provider-sticky-actions {
  border-color: var(--office-border) !important;
  background: rgba(248, 251, 254, 0.95) !important;
  box-shadow: 0 -6px 20px rgba(35, 68, 105, 0.06);
}

.voice-option {
  border-color: var(--office-border) !important;
  background: #fbfdff !important;
}

.voice-option-selected {
  border-color: #8cb8de !important;
  background: #edf6fe !important;
  box-shadow: 0 0 0 2px rgba(79, 131, 187, 0.10);
}

/* ===== Specialized workspaces ===== */
.prompt-workspace,
.pronunciation-workspace,
.censorship-workspace,
.behavior-workspace,
.appeal-grid {
  gap: 18px !important;
}

.prompt-sidebar,
.pronunciation-sidebar,
.censorship-sidebar {
  overflow: hidden;
}

.prompt-section-item,
.pronunciation-entry-item,
.censorship-entry-item,
.behavior-version {
  border-color: #e3ebf3 !important;
  background: #fbfdff !important;
}

.prompt-section-item:hover,
.pronunciation-entry-item:hover,
.censorship-entry-item:hover,
.behavior-version:hover {
  background: #f2f7fc !important;
}

.prompt-section-item-active,
.pronunciation-entry-item-active,
.censorship-entry-item-active,
.behavior-version-active {
  border-color: #bcd7ef !important;
  background: #eaf4fd !important;
}

.address-suggestion,
.address-synonym-tag,
.appeal-turn,
.taxomet-service-row {
  border-color: var(--office-border-soft) !important;
  background: #fbfdff !important;
}

.appeal-turn-ai {
  background: #eef6fd !important;
}

.censorship-warning,
.address-synonym-warning {
  border-color: #efd6da !important;
  background: #fcf1f3 !important;
  color: #9e5360 !important;
}

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  padding: 28px;
  background:
    radial-gradient(circle at 18% 20%, rgba(93, 151, 206, 0.16), transparent 28rem),
    radial-gradient(circle at 82% 76%, rgba(219, 122, 134, 0.12), transparent 24rem),
    #f4f8fc;
}

.login-card {
  max-width: 430px;
  padding: 34px 36px 36px;
  box-shadow: 0 22px 54px rgba(35, 68, 105, 0.12);
}

.brand-mark {
  width: 70px;
  height: 70px;
  border-radius: 18px;
  color: transparent !important;
  background: #fff url('/static/favicon/favicon.svg') center / 68px 68px no-repeat !important;
  box-shadow: 0 8px 20px rgba(35, 68, 105, 0.12);
  overflow: hidden;
  user-select: none;
}

.login-card h1 {
  color: var(--office-blue-dark);
}

/* ===== Scrollbars ===== */
* {
  scrollbar-width: thin;
  scrollbar-color: #c4d7e9 transparent;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-thumb {
  background: #c4d7e9;
  border: 2px solid transparent;
  border-radius: 10px;
  background-clip: padding-box;
}

/* ===== Responsive ===== */
@media (max-width: 980px) {
  :root {
    --office-sidebar: 82px;
  }

  .topbar {
    padding-inline: 10px;
  }

  .topbar > div:first-child {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    padding-inline: 0;
  }

  .topbar > div:first-child::before {
    grid-row: auto;
  }

  .topbar > div:first-child strong,
  .topbar > div:first-child span,
  .admin-nav a span:not(.admin-nav-icon) {
    display: none;
  }

  .admin-nav a {
    justify-content: center;
    padding-inline: 4px;
  }

  .admin-nav-icon {
    flex-basis: 28px;
  }

  .topbar-actions button {
    overflow: hidden;
    color: transparent !important;
    font-size: 0;
  }

  .topbar-actions button::after {
    content: "↪";
    color: #60738a;
    font-size: 1.1rem;
  }

  .container,
  .form-container,
  .prompt-container,
  .pronunciation-container,
  .censorship-container,
  .taxomet-container {
    width: min(100% - 28px, 1380px);
  }
}

@media (max-width: 680px) {
  body:not(.login-page) {
    padding-left: 0;
    padding-bottom: 74px;
  }

  .topbar {
    inset: auto 0 0 0;
    width: 100%;
    height: 66px;
    min-height: 66px;
    padding: 8px 10px;
    overflow: visible;
    flex-direction: row;
    border-top: 1px solid var(--office-border);
    border-right: 0;
    box-shadow: 0 -6px 20px rgba(35, 68, 105, 0.06);
  }

  .topbar > div:first-child,
  .topbar-actions {
    display: none !important;
  }

  .admin-nav {
    display: flex !important;
    flex: 1 1 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 3px;
    margin: 0;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .admin-nav a {
    flex: 0 0 58px;
    min-width: 58px;
    min-height: 48px;
    padding: 5px;
    justify-content: center;
  }


  .container,
  .form-container,
  .prompt-container,
  .pronunciation-container,
  .censorship-container,
  .taxomet-container {
    width: calc(100% - 20px);
    margin-top: 18px;
  }

  .form-card,
  .table-card,
  .address-search-card,
  .appeal-table-card,
  .behavior-editor-card,
  .behavior-test-card,
  .behavior-history-card,
  .prompt-editor-card,
  .pronunciation-editor-card,
  .censorship-editor-card,
  .taxomet-services-card {
    padding: 16px;
    border-radius: 14px !important;
  }
}

/* Users */
.users-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.user-card {
  padding: 20px;
  border: 1px solid var(--office-border, #dbe4f0);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 28px rgb(35 65 105 / 6%);
}

.user-card-disabled {
  opacity: .68;
}

.user-card-head,
.user-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.user-card h3 {
  margin: 0 0 4px;
}

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

.user-meta div {
  padding: 12px;
  border-radius: 12px;
  background: #f6f9fd;
}

.user-meta dt {
  margin-bottom: 4px;
  color: #74839a;
  font-size: .78rem;
}

.user-meta dd {
  margin: 0;
  color: #263b5b;
  font-weight: 600;
}

.user-access-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.user-access-form input {
  min-width: 160px;
  margin: 0;
}

@media (max-width: 900px) {
  .users-grid {
    grid-template-columns: 1fr;
  }
  .user-card-actions,
  .user-access-form {
    align-items: stretch;
    flex-direction: column;
  }
  .user-access-form input,
  .user-access-form button,
  .user-card-actions form,
  .user-card-actions > form > button {
    width: 100%;
  }
}
