/**
 * CliqueObras — Premium interface layer
 *
 * Esta camada concentra a nova linguagem visual sem alterar os contratos
 * estruturais usados pelos módulos JavaScript.
 */

:root {
  color-scheme: light;
  --blue: #18181b;
  --blue-hover: #27272a;
  --blue-soft: #f4f4f5;
  --green: #28a745;
  --green-soft: #edf9f0;
  --red: #ff3b30;
  --red-soft: #fff0ef;
  --amber: #ff9500;
  --amber-soft: #fff7e8;
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface2: #fafafa;
  --text: #27272a;
  --text2: #52525b;
  --text3: #71717a;
  --border: #e4e4e7;
  --border2: #e4e4e7;
  --shadow: 0 1px 2px rgba(15, 23, 42, .025), 0 8px 24px rgba(15, 23, 42, .045);
  --shadow-lg: 0 24px 70px rgba(15, 23, 42, .13);
  --glass: rgba(255, 255, 255, .88);
  --r: 20px;
  --sidebar-w: 248px;
  --rightbar-w: 292px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --blue: #0a84ff;
  --blue-hover: #2994ff;
  --blue-soft: #102a43;
  --green: #30d158;
  --green-soft: #10291a;
  --red: #ff453a;
  --red-soft: #381513;
  --amber: #ff9f0a;
  --amber-soft: #35230b;
  --bg: #0e0f12;
  --surface: #17181c;
  --surface2: #1e2025;
  --text: #f5f5f7;
  --text2: #a4a7ae;
  --text3: #747780;
  --border: #2b2d33;
  --border2: #23252a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 10px 28px rgba(0, 0, 0, .18);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, .44);
  --glass: rgba(23, 24, 28, .88);
}

html {
  font-size: 15px;
  background: var(--bg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", system-ui, sans-serif;
  font-feature-settings: "tnum" 1, "cv02" 1, "cv03" 1, "cv04" 1;
  letter-spacing: -.008em;
  background: var(--bg);
}

button, input, select, textarea {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 28%, transparent);
  outline-offset: 2px;
}

input,
select,
textarea {
  min-height: 46px;
  padding: 11px 14px;
  border-radius: 14px;
  border-color: var(--border);
  background: color-mix(in srgb, var(--surface) 94%, var(--bg));
  transition: border-color 200ms ease, box-shadow 200ms ease, background 200ms ease;
}

textarea {
  line-height: 1.55;
}

input:hover,
select:hover,
textarea:hover {
  border-color: color-mix(in srgb, var(--text3) 55%, var(--border));
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 11%, transparent);
}

label {
  margin-bottom: 7px;
  color: var(--text2);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .005em;
}

h1,
h2,
h3 {
  color: var(--text);
  letter-spacing: -.025em;
}

h1 { font-size: 2rem; font-weight: 620; }
h2 { font-size: 1.35rem; font-weight: 620; }
h3 { font-size: 1rem; font-weight: 620; }

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text3) 48%, transparent);
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* Application frame */
#app {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

main {
  background: transparent;
}

#content-wrap {
  grid-template-columns: minmax(0, 1fr) var(--rightbar-w);
}

#content {
  padding: 28px 30px 72px;
}

/* Navigation */
#sidebar {
  border-right-color: var(--border2);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 1px 0 0 rgba(255, 255, 255, .35);
}

.brand {
  width: calc(100% - 20px);
  min-height: 66px;
  margin: 10px;
  padding: 10px 10px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: var(--text);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 11px;
  transition: background 200ms ease, transform 200ms var(--ease);
}

.brand:hover {
  background: var(--surface2);
}

.brand:active {
  transform: scale(.985);
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--blue);
  box-shadow: none;
  overflow: hidden;
}

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

.brand > div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.brand b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .88rem;
  font-weight: 650;
  letter-spacing: -.015em;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--text3);
  font-size: .69rem;
}

.brand-chevron {
  width: 14px;
  height: 14px;
  color: var(--text3);
  opacity: 0;
  transform: translateX(-3px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.brand:hover .brand-chevron {
  opacity: 1;
  transform: none;
}

#nav {
  padding: 4px 12px 18px;
}

.nav-sep {
  padding: 18px 11px 7px;
  color: var(--text3);
  font-size: .64rem;
  font-weight: 650;
  letter-spacing: .105em;
}

.nav-item {
  position: relative;
  min-height: 42px;
  margin-bottom: 2px;
  padding: 9px 11px;
  border-radius: 11px;
  color: var(--text2);
  font-size: .86rem;
  font-weight: 480;
  transition: color 180ms ease, background 180ms ease, transform 180ms var(--ease);
}

.nav-item:hover {
  background: color-mix(in srgb, var(--text) 4%, transparent);
  color: var(--text);
}

.nav-item:active {
  transform: scale(.98);
}

.nav-item.active {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
  font-weight: 590;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 3px;
  background: var(--blue);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.7;
}

.nav-logout,
.nav-logout:hover {
  color: var(--red);
}

#sidebar-footer {
  padding: 15px 22px 18px;
  border-top-color: var(--border2);
  line-height: 1.75;
  font-size: .68rem;
}

#sidebar-footer kbd {
  display: none;
}

/* Top navigation */
#finance-ticker {
  height: 31px;
  border-bottom-color: var(--border2);
  background: color-mix(in srgb, var(--surface) 76%, transparent);
}

.ticker-item {
  height: 31px;
  padding: 0 19px;
  border-right-color: var(--border2);
  font-size: .7rem;
}

.ticker-item:hover {
  background: color-mix(in srgb, var(--text) 3%, transparent);
}

#topbar {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 520px) minmax(0, 1fr);
  min-height: 84px;
  padding: 18px 30px;
  gap: 11px;
  border-bottom: 0;
  background: transparent;
  backdrop-filter: none;
}

#page-title {
  font-size: 2rem;
  font-weight: 630;
  letter-spacing: -.035em;
}

#global-search-wrap {
  width: 100%;
  max-width: 520px;
  justify-self: center;
}

#global-search {
  height: 42px;
  min-height: 42px;
  padding-left: 38px;
  padding-right: 44px;
  border-color: var(--border2);
  border-radius: 13px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  font-size: .78rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .025);
}

#global-search::placeholder {
  color: var(--text3);
}

#search-results {
  top: calc(100% + 9px);
  border-color: var(--border2);
  border-radius: 16px;
  padding: 6px;
  box-shadow: var(--shadow-lg);
}

.sr-item {
  min-height: 42px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text2);
  transition: color 180ms ease, background 180ms ease, transform 180ms var(--ease);
}

.icon-btn:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--text) 5%, transparent);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(.94);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.7;
}

/* Premium primitives */
.btn {
  min-height: 44px;
  padding: 10px 16px;
  gap: 8px;
  border-radius: 14px;
  font-size: .84rem;
  font-weight: 580;
  transition: color 190ms ease, background 190ms ease, border-color 190ms ease,
    box-shadow 190ms ease, transform 190ms var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: scale(.975);
}

.btn-primary {
  background: var(--blue);
  box-shadow: none;
}

.btn-primary:hover {
  background: var(--blue-hover);
  filter: none;
  box-shadow: none;
}

.btn-ghost {
  border-color: var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.btn-ghost:hover {
  border-color: color-mix(in srgb, var(--text3) 44%, var(--border));
  background: var(--surface);
  color: var(--text);
}

.btn-danger {
  background: var(--red);
}

.btn-sm {
  min-height: 36px;
  padding: 7px 11px;
  border-radius: 11px;
  font-size: .76rem;
}

.card {
  padding: 20px 22px;
  border-color: var(--border2);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  animation: premiumEnter 360ms var(--ease) both;
  transition: border-color 200ms ease, box-shadow 220ms ease, transform 220ms var(--ease);
}

.card:hover {
  border-color: color-mix(in srgb, var(--text3) 25%, var(--border2));
  box-shadow: 0 1px 2px rgba(15, 23, 42, .02), 0 14px 34px rgba(15, 23, 42, .065);
}

@keyframes premiumEnter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.grid {
  gap: 16px;
}

.tag {
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: .68rem;
  font-weight: 620;
}

.dot {
  width: 8px;
  height: 8px;
}

.dot-green,
.dot-amber,
.dot-red {
  box-shadow: none;
}

.progress {
  height: 6px;
  background: color-mix(in srgb, var(--text3) 13%, transparent);
}

/* Executive dashboard */
.filters-bar {
  width: fit-content;
  max-width: 100%;
  margin: 0 0 22px;
  padding: 6px;
  gap: 6px;
  border-color: var(--border2);
  border-radius: 16px;
  box-shadow: none;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}

.filters-bar select,
.filters-bar input {
  min-width: 150px;
  min-height: 38px;
  height: 38px;
  padding: 7px 11px;
  border-color: transparent;
  border-radius: 11px;
  background: transparent;
  font-size: .76rem;
}

.filters-bar select:hover,
.filters-bar input:hover,
.filters-bar select:focus,
.filters-bar input:focus {
  background: var(--surface);
}

.kpi-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.kpi {
  position: relative;
  min-height: 108px;
  padding: 17px 18px 16px;
  overflow: hidden;
  border-color: var(--border2);
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: premiumEnter 360ms var(--ease) both;
  transition: border-color 200ms ease, box-shadow 220ms ease, transform 220ms var(--ease);
}

.kpi::after {
  content: "";
  position: absolute;
  inset: auto 16px 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
}

.kpi:nth-child(-n+4) {
  min-height: 128px;
  padding-top: 20px;
}

.kpi:nth-child(-n+4)::after {
  background: color-mix(in srgb, var(--blue) 58%, transparent);
}

.kpi:hover {
  border-color: color-mix(in srgb, var(--blue) 18%, var(--border2));
  box-shadow: 0 15px 35px rgba(15, 23, 42, .07);
}

.kpi .k-label {
  margin-bottom: 10px;
  color: var(--text2);
  font-size: .72rem;
  font-weight: 540;
}

.kpi .k-label svg {
  width: 15px;
  height: 15px;
  padding: 0;
  color: var(--text3);
  stroke-width: 1.8;
}

.kpi .k-value {
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 640;
  letter-spacing: -.035em;
}

.kpi:nth-child(-n+4) .k-value {
  font-size: 1.55rem;
}

.kpi .k-sub {
  max-width: 95%;
  margin-top: 7px;
  color: var(--text3);
  font-size: .68rem;
  line-height: 1.35;
}

.kpi.accent-blue .k-value { color: var(--blue); }
.kpi.accent-green .k-value { color: var(--green); }
.kpi.accent-red .k-value { color: var(--red); }
.kpi.accent-amber .k-value { color: var(--amber); }

.kpi-link:hover {
  transform: translateY(-3px);
}

.toolbar {
  gap: 6px;
  margin-bottom: 14px;
}

.toolbar > small {
  margin-right: 4px;
}

.tabs {
  gap: 3px;
  padding: 4px;
  border: 0;
  border-radius: 13px;
  background: color-mix(in srgb, var(--text) 5%, transparent);
}

.tab {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 9px;
  color: var(--text2);
  font-size: .74rem;
  font-weight: 540;
  transition: color 180ms ease, background 180ms ease, box-shadow 180ms ease, transform 180ms var(--ease);
}

.tab:hover {
  color: var(--text);
}

.tab:active {
  transform: scale(.97);
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .09);
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.two-col > .chart-card:first-child {
  grid-column: 1 / -1;
}

.chart-card {
  min-height: 300px;
}

.chart-card h3 {
  margin-bottom: 16px !important;
  font-size: .94rem;
}

.chart-box {
  height: 310px;
}

.chart-box.sm {
  height: 240px;
}

.section-title {
  margin: 34px 0 14px;
}

.section-title h2 {
  font-size: 1.2rem;
}

/* Future expenses */
#rightbar {
  padding: 24px 18px 40px;
  border-left-color: var(--border2);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

#rightbar > .rb-title {
  margin-bottom: 20px !important;
  color: var(--text) !important;
  font-size: .85rem !important;
  font-weight: 620;
  letter-spacing: -.01em;
  text-transform: none;
}

.rb-section {
  margin-bottom: 24px;
}

.rb-title {
  margin-bottom: 10px;
  color: var(--text3);
  font-size: .66rem;
  font-weight: 650;
  letter-spacing: .075em;
}

.rb-item {
  margin-bottom: 7px;
  padding: 11px 10px;
  border-color: transparent;
  border-radius: 12px;
  background: transparent;
  font-size: .75rem;
}

.rb-item:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--text) 5%, transparent);
}

.rb-item small {
  margin-top: 3px;
  font-size: .65rem;
}

.rb-item-value {
  font-size: .71rem;
}

/* Data tables */
.table-wrap {
  border-color: var(--border2);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

table {
  font-size: .79rem;
}

thead th {
  padding: 13px 16px;
  border-bottom-color: var(--border);
  background: color-mix(in srgb, var(--surface2) 78%, var(--surface));
  color: var(--text3);
  font-size: .65rem;
  font-weight: 620;
  letter-spacing: .055em;
}

tbody td {
  padding: 14px 16px;
  border-bottom-color: var(--border2);
}

tbody tr:hover {
  background: color-mix(in srgb, var(--blue) 3%, var(--surface));
}

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

/* Secondary components */
.drop-zone {
  padding: 42px 24px;
  border-width: 1.5px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface2) 75%, transparent);
}

.drop-zone:hover,
.drop-zone.drag {
  border-color: color-mix(in srgb, var(--blue) 65%, var(--border));
  background: var(--blue-soft);
}

.empty {
  padding: 56px 20px;
  line-height: 1.6;
}

.alert-item,
.check-item,
.planning-offset-box,
.project-dates > div {
  border-color: var(--border2);
  border-radius: 13px;
  background: color-mix(in srgb, var(--surface2) 76%, var(--surface));
}

.alert-item,
.check-item {
  padding: 12px 13px;
}

.cal-grid {
  gap: 7px;
}

.cal-day {
  min-height: 94px;
  padding: 8px;
  border-color: var(--border2);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface2) 78%, var(--surface));
}

.cal-day:hover {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--blue) 45%, var(--border));
  box-shadow: 0 9px 24px rgba(15, 23, 42, .06);
}

.cal-ev {
  padding: 3px 6px;
  border-radius: 7px;
}

/* Floating surfaces */
#modal-overlay {
  padding: 20px;
  background: rgba(12, 15, 20, .36);
  backdrop-filter: blur(10px) saturate(.9);
}

.modal {
  border-color: color-mix(in srgb, var(--border) 78%, transparent);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  animation: premiumModal 240ms var(--ease);
}

@keyframes premiumModal {
  from { opacity: 0; transform: translateY(12px) scale(.975); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  padding: 21px 24px;
  border-bottom-color: var(--border2);
}

.modal-body {
  padding: 22px 24px;
}

.modal-foot {
  padding: 16px 24px 20px;
  border-top-color: var(--border2);
}

.form-grid {
  gap: 16px;
}

#toasts {
  right: 24px;
  bottom: 24px;
}

.toast {
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: premiumToast 280ms var(--ease);
}

.toast.success { box-shadow: inset 3px 0 0 var(--green), var(--shadow-lg); }
.toast.error { box-shadow: inset 3px 0 0 var(--red), var(--shadow-lg); }
.toast.warn { box-shadow: inset 3px 0 0 var(--amber), var(--shadow-lg); }

@keyframes premiumToast {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.loading-overlay {
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(12px);
}

.spinner {
  width: 34px;
  height: 34px;
  border-width: 2px;
}

/* Authentication */
.cloud-login {
  background: var(--bg);
}

.cloud-auth-shell {
  width: min(1050px, 100%);
  min-height: 640px;
  border-color: color-mix(in srgb, var(--border) 75%, transparent);
  border-radius: 28px;
  box-shadow: 0 30px 90px rgba(15, 23, 42, .14);
}

.cloud-auth-hero {
  padding: 64px;
  background: #101d31;
}

.cloud-auth-hero::before,
.cloud-auth-hero::after {
  display: none;
}

.cloud-auth-logo {
  width: 54px;
  height: 54px;
  border-radius: 15px;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.cloud-auth-logo img,
.cloud-auth-mobile-brand img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cloud-auth-kicker {
  font-size: .68rem;
  font-weight: 620;
  letter-spacing: .13em;
}

.cloud-auth-hero h1 {
  margin: 9px 0 24px;
  color: #fff;
  font-size: 3.1rem;
  font-weight: 590;
  letter-spacing: -.05em;
}

.cloud-auth-hero > p {
  color: rgba(255, 255, 255, .7);
  font-size: 1rem;
  line-height: 1.75;
}

.cloud-auth-hero li {
  color: rgba(255, 255, 255, .85);
  font-size: .84rem;
  font-weight: 500;
}

.cloud-auth-hero li svg {
  color: #73b7ff;
}

.cloud-auth-panel {
  padding: 56px 62px;
}

.cloud-auth-heading h2 {
  margin-bottom: 9px;
  font-size: 2rem;
  font-weight: 620;
}

.cloud-auth-form {
  gap: 17px;
  margin-top: 28px;
}

.cloud-auth-form input {
  height: 48px;
  border-radius: 14px;
  background: var(--surface2);
}

.cloud-auth-submit,
.cloud-auth-secondary {
  min-height: 48px;
}

.cloud-login-card {
  padding: 32px;
  border-color: var(--border2);
  border-radius: 24px;
}

.profile-name-editor {
  max-width: 620px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border2);
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 6px;
}

.profile-name-row input {
  flex: 1;
  min-width: 220px;
}

.profile-name-editor > small {
  display: block;
  margin-top: 7px;
  color: var(--text3);
}

/* Configurações: hierarquia e alinhamento consistentes */
.settings-page {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.settings-card {
  grid-column: span 6;
  margin: 0 !important;
  max-width: none !important;
}

.settings-card-wide {
  grid-column: 1 / -1;
}

.settings-company {
  grid-column: span 6;
}

.settings-ticker {
  grid-column: 1 / -1;
}

#ticker-projects {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

#ticker-projects .check-item {
  min-width: 0;
  margin: 0;
}

#company-settings-card {
  grid-column: 1 / -1;
}

.company-settings-section {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.company-settings-heading {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.company-settings-heading > span {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
}

.company-settings-heading svg { width: 17px; height: 17px; }
.company-settings-heading small { display: block; margin-top: 3px; color: var(--text3); line-height: 1.45; }
.company-shift-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.letterhead-control { display: grid; grid-template-columns: minmax(220px, 420px) 1fr; align-items: center; gap: 14px; }
.letterhead-control > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
#cfg-letterhead-preview { display: grid; min-height: 112px; place-items: center; overflow: hidden; border: 1px dashed var(--border); border-radius: 12px; background: var(--surface2); color: var(--text3); }
#cfg-letterhead-preview img { display: block; width: 100%; max-height: 180px; object-fit: contain; background: #fff; }
#cfg-letterhead-preview span { display: flex; align-items: center; gap: 7px; font-size: .78rem; }
#cfg-letterhead-preview svg { width: 18px; height: 18px; }

.settings-account .account-summary small {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.settings-account .organization-chip {
  margin: 0;
}

/* Tablet */
@media (max-width: 1280px) {
  :root { --rightbar-w: 270px; }
  #content { padding-inline: 24px; }
  #topbar { padding-inline: 24px; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}

@media (max-width: 1440px) {
  #content-wrap { grid-template-columns: minmax(0, 1fr); }
  #rightbar { display: none; }
  #future-toggle { display: flex; }
}

@media (max-width: 1100px) {
  .two-col { grid-template-columns: 1fr; }
  .two-col > .chart-card:first-child { grid-column: auto; }
}

/* Mobile: purpose-built compact frame */
@media (max-width: 860px) {
  :root { --sidebar-w: 280px; }

  body {
    background: var(--bg);
  }

  #sidebar {
    width: min(var(--sidebar-w), 88vw);
    box-shadow: 26px 0 70px rgba(15, 23, 42, .2);
  }

  .brand {
    min-height: 70px;
  }

  #topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    position: relative;
    min-height: 60px;
    padding: 9px 12px 10px;
    gap: 5px;
  }

  #page-title {
    max-width: none;
    font-size: 1.28rem;
  }

  #global-search-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: none;
    margin-top: 4px;
  }

  #global-search {
    height: 44px;
    min-height: 44px;
    font-size: 16px;
  }

  .profile-name-row {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-name-row input {
    min-width: 0;
  }

  #content {
    height: 100%;
    padding: 13px 12px calc(84px + env(safe-area-inset-bottom));
  }

  .filters-bar {
    width: 100%;
    padding: 7px;
  }

  .filters-bar select,
  .filters-bar input {
    min-height: 44px;
    height: 44px;
  }

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

  .kpi,
  .kpi:nth-child(-n+4) {
    min-height: 110px;
    padding: 15px 14px;
  }

  .kpi .k-value,
  .kpi:nth-child(-n+4) .k-value {
    font-size: 1.12rem;
  }

  .card {
    padding: 16px;
    border-radius: 17px;
  }

  .chart-card {
    min-height: 260px;
  }

  .chart-box {
    height: 245px;
  }

  .chart-box.sm {
    height: 215px;
  }

  .section-title {
    margin-top: 28px;
  }

  .modal {
    border-radius: 24px 24px 0 0;
  }

  #modal-overlay {
    padding: 0;
  }

  .modal-head,
  .modal-body {
    padding-inline: 18px;
  }

  .modal-foot {
    padding-inline: 18px;
  }

  .cloud-auth-panel {
    padding: 38px 24px;
  }

  .settings-page {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .settings-card {
    width: 100%;
  }

  .settings-account > div:first-child {
    align-items: stretch !important;
    flex-direction: column;
  }

  .settings-account .account-summary {
    align-items: flex-start;
  }

  .settings-account .account-summary > svg {
    width: 34px;
    height: 34px;
  }

  .settings-account .account-summary small {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
    overflow-wrap: anywhere;
  }

  .settings-account > div:first-child > .btn {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .company-shift-grid { grid-template-columns: 1fr 1fr; }
  .letterhead-control { grid-template-columns: 1fr; }
  #ticker-projects { grid-template-columns: 1fr; }

  .cloud-auth-shell {
    width: 100%;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .cloud-auth-hero {
    display: none;
  }

  .cloud-auth-panel {
    padding: calc(28px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .company-shift-grid { grid-template-columns: 1fr; }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi,
  .kpi:nth-child(-n+4) {
    min-height: 98px;
  }

  .toolbar > small {
    flex-basis: 100%;
  }

  .tab {
    min-height: 38px;
  }

  .section-title h2 {
    font-size: 1.08rem;
  }
}

@media (max-width: 370px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
