:root {
  --mc4-black: #080a0d;
  --mc4-black-soft: #11151a;
  --mc4-black-panel: #171c22;
  --mc4-blue: #009fe3;
  --mc4-sky: #6dc8f2;
  --mc4-blue-dark: #0078a9;
  --mc4-orange: #ea671f;
  --ink: #151a20;
  --muted: #687381;
  --line: #e1e6eb;
  --line-strong: #cbd3da;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --bg: #f2f4f5;
  --danger: #a92832;
  --success: #187246;
  --warning: #8b5b00;
  font-family: Aptos, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 0 18px 20px;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: #090b0e;
  border-right: 1px solid rgba(255,255,255,.06);
  overflow: hidden;
  z-index: 30;
}

.sidebar::before { display: none; }

.sidebar-brand {
  position: relative;
  padding: 30px 8px 22px;
  border-bottom: 1px solid rgba(255,255,255,.09);
}

.brand {
  display: block;
  width: fit-content;
  color: #fff;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 188px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.brand-product {
  display: grid;
  gap: 2px;
  margin-top: 18px;
}

.brand-product span,
.nav-label,
.topbar-heading span,
.auth-kicker,
.auth-form-kicker {
  color: var(--mc4-sky);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.brand-product strong {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -.015em;
}

.brand-product small {
  color: #8e9aa7;
  font-size: 12px;
}

.brand-accent,
.auth-brand-accent { display: none !important; }


.nav-label {
  padding: 25px 13px 8px;
  color: #6f7b87;
}

.main-nav {
  display: grid;
  gap: 5px;
  padding: 0;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 11px 13px;
  color: #aeb8c2;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 680;
  transition: color .18s, background .18s, border-color .18s, transform .18s;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.05);
  transform: translateX(2px);
}

.nav-link.active {
  color: #fff;
  background: rgba(255,255,255,.065);
  border-color: rgba(255,255,255,.08);
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--mc4-blue);
}

.nav-dot {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: currentColor;
  opacity: .65;
}

.nav-link.active .nav-dot {
  color: var(--mc4-blue);
  opacity: 1;
}

.sidebar-user {
  margin-top: auto;
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 18px 7px 0;
  border-top: 1px solid rgba(255,255,255,.09);
}

.sidebar-user .avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #ffffff;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(109,200,242,.38);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 850;
}

.sidebar-user strong,
.sidebar-user small { display: block; }
.sidebar-user strong { font-size: 13px; }
.sidebar-user small { margin-top: 3px; color: #8f9aa5; font-size: 11px; }
.sidebar-user a {
  color: #9eabb7;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.sidebar-user a:hover { color: var(--mc4-sky); }

.content-shell {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 32px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar::after { display: none; }

.topbar-heading {
  display: grid;
  gap: 4px;
}

.topbar-heading h1 {
  margin: 0;
  color: var(--mc4-black);
  font-size: 23px;
  line-height: 1.08;
  letter-spacing: -.025em;
}

.logout-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 9px 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}
.logout-link:hover { border-color: var(--mc4-black); }

.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 22px;
}

.page-content {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  padding: 30px 32px 48px;
  flex: 1;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 38px;
  color: #7c8792;
  background: #fff;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.flash {
  position: relative;
  padding: 14px 17px 14px 20px;
  margin: 0 0 22px;
  border: 1px solid;
  border-radius: 8px;
  font-weight: 650;
}
.flash::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}
.flash-success { color: #135d37; background: #eef9f3; border-color: #bfe2ce; }
.flash-success::before { background: var(--success); }
.flash-error { color: #8a2028; background: #fff1f2; border-color: #ecc5c9; }
.flash-error::before { background: var(--danger); }
.flash-warning { color: #754d00; background: #fff8e9; border-color: #ead49f; }
.flash-warning::before { background: var(--mc4-orange); }

.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.page-actions h2 {
  color: var(--mc4-black);
  font-size: 22px;
  letter-spacing: -.02em;
}

.button,
button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 41px;
  padding: 10px 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font: inherit;
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s, transform .18s;
}
.button:hover { border-color: var(--mc4-black); transform: translateY(-1px); }
.button.primary {
  color: #fff;
  background: var(--mc4-blue);
  border-color: var(--mc4-blue);
}
.button.primary:hover { color: #fff; background: var(--mc4-blue-dark); border-color: var(--mc4-blue-dark); }
.button.danger { color: var(--danger); border-color: #e7bfc3; }
.button.small { min-height: 34px; padding: 7px 11px; font-size: 12px; }
.button[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

.grid { display: grid; gap: 20px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 28px; }

.stat-card,
.card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 8px 28px rgba(12, 20, 28, .035);
}

.stat-card {
  min-height: 150px;
  padding: 23px;
  overflow: hidden;
}

.stat-card::after { display: none; }

.stat-card small,
.stat-card strong,
.stat-card span { position: relative; z-index: 1; display: block; }
.stat-card small { color: #687481; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .065em; }
.stat-card strong { margin-top: 14px; color: var(--mc4-black); font-size: clamp(25px, 2.2vw, 34px); line-height: 1; letter-spacing: -.035em; }
.stat-card span { margin-top: 10px; color: var(--muted); font-size: 12px; }
.stat-card.kpi-blue,
.stat-card.kpi-orange { border-top: 1px solid var(--line); }

.card { padding: 25px; }
.card h2,
.card h3 { margin-top: 0; color: var(--mc4-black); letter-spacing: -.02em; }
.two-column { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }

.table-wrap {
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(12,20,28,.025);
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #edf0f2;
}

.data-table th {
  color: #5e6975;
  background: #f7f9fa;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.data-table tbody tr { transition: background .16s; }
.data-table tbody tr:hover { background: #fbfcfd; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table a { color: #087eae; font-weight: 800; text-decoration: none; }
.data-table a:hover { color: var(--mc4-orange); }

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

.status,
.role-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .025em;
}
.status { color: #52606c; background: #edf1f4; }
.status-accepted { color: #17633a; background: #e7f6ed; }
.status-sent { color: #10688f; background: #e5f5fc; }
.status-rejected,
.status-cancelled { color: #92252d; background: #fff0f1; }
.status-draft { color: #59636d; background: #eff2f4; }
.role-pill { color: #115d7d; background: #e9f6fb; }

.form-card { max-width: 1040px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 19px; }
.form-grid .full { grid-column: 1 / -1; }
.form-group { display: grid; gap: 8px; }
.form-group label { color: #29313a; font-size: 13px; font-weight: 800; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  min-height: 43px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd3da;
  border-radius: 7px;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover { border-color: #aab5bf; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--mc4-blue);
  box-shadow: 0 0 0 3px rgba(0,159,227,.11);
}
.form-group textarea { min-height: 112px; resize: vertical; }
.form-group small { color: var(--muted); font-size: 12px; }
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 21px;
  border-top: 1px solid var(--line);
}
.checkbox { display: flex; align-items: center; gap: 9px; font-weight: 680; }
.checkbox input { width: auto; }

.empty-state {
  padding: 58px 24px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed #bfc8cf;
  border-radius: 12px;
}
.empty-state h2 { color: var(--mc4-black); }

.detail-list { display: grid; grid-template-columns: 180px 1fr; gap: 10px 18px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 700; }

.offer-head { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.offer-head h2 { margin: 0; }
.offer-total-box {
  min-width: 270px;
  padding: 19px;
  text-align: right;
  color: #fff;
  background: var(--mc4-black);
  border-radius: 10px;
  border-bottom: 4px solid var(--mc4-sky);
}
.offer-total-box small,
.offer-total-box strong { display: block; }
.offer-total-box small { color: #aab6c0; }
.offer-total-box strong { margin-top: 7px; color: var(--mc4-sky); font-size: 28px; }
.offer-total-box span { color: #8d99a4; font-size: 12px; }

.offer-meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.offer-meta-grid > div { padding: 14px; background: #f7f9fa; border: 1px solid var(--line); border-radius: 8px; }
.offer-meta-grid small,
.offer-meta-grid strong { display: block; }
.offer-meta-grid small { margin-bottom: 5px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }

.auth-page {
  min-height: 100vh;
  margin: 0;
  background: #fff;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 1.05fr) minmax(420px, .95fr);
}

.auth-brand-panel {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(38px, 6vw, 78px);
  color: #fff;
  background: #090b0e;
  overflow: hidden;
}

.auth-brand-panel::after { display: none; }

.auth-brand-content,
.auth-brand-footer { position: relative; z-index: 1; }
.login-brand-logo {
  display: block;
  width: min(330px, 78%);
  max-width: 330px;
  height: auto;
  margin: 0;
  padding: 0;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.auth-brand-accent { width: 118px; height: 5px; margin: 27px 0 52px; }
.auth-kicker { display: block; margin-bottom: 17px; }
.auth-brand-content h1 {
  max-width: 700px;
  margin: 0;
  color: #fff;
  font-size: clamp(42px, 4vw, 62px);
  line-height: .98;
  letter-spacing: -.045em;
}
.auth-brand-content > p {
  max-width: 610px;
  margin: 28px 0 0;
  color: #aeb7c0;
  font-size: 17px;
  line-height: 1.55;
}
.auth-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 35px;
}
.auth-points span {
  padding: 8px 11px;
  color: #cdd5dc;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}
.auth-brand-footer { color: #717d88; font-size: 12px; }

.auth-form-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px;
  background: #fff;
}

.auth-card {
  width: min(100%, 470px);
  padding: 10px 0;
}
.auth-form-kicker { display: block; margin-bottom: 15px; }
.auth-card h2 {
  margin: 0 0 9px;
  color: var(--mc4-black);
  font-size: 42px;
  line-height: 1;
  letter-spacing: -.035em;
}
.auth-card > p { margin: 0 0 30px; color: var(--muted); }
.auth-card .form-group { margin-bottom: 18px; }
.auth-card .form-group input { min-height: 49px; }
.auth-card .button { width: 100%; min-height: 49px; margin-top: 5px; }
.auth-card .flash { margin-bottom: 20px; }
.login-footer { margin-top: 24px; color: #8a949d; font-size: 12px; text-align: center; }

.role-matrix { width: 100%; border-collapse: collapse; }
.role-matrix th,
.role-matrix td { padding: 10px; text-align: center; border: 1px solid var(--line); }
.role-matrix th:first-child,
.role-matrix td:first-child { text-align: left; }

.service-editor { display: grid; gap: 14px; }
.service-edit-row {
  display: grid;
  grid-template-columns: 36px 1.3fr 1fr 115px 115px 90px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.service-edit-row input,
.service-edit-row select { width: 100%; padding: 9px; border: 1px solid #ccd4db; border-radius: 6px; }
.service-edit-row .service-name { display: grid; gap: 5px; }
.service-edit-row .service-name small { color: var(--muted); }

.settings-section { margin-bottom: 24px; }
.settings-section h2 { margin-bottom: 17px; }
.logo-preview { display: flex; align-items: center; gap: 24px; }
.logo-preview-stage {
  min-width: 310px;
  min-height: 116px;
  display: grid;
  place-items: center;
  padding: 22px;
  background: var(--mc4-black);
  border-radius: 10px;
}
.logo-preview-stage img {
  display: block;
  max-width: 260px;
  max-height: 80px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.account-banner { display: flex; align-items: center; gap: 18px; }
.account-banner .avatar {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--mc4-black);
  border: 1px solid #29313a;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 850;
}
.account-banner h2 { margin: 0 0 5px; }
.account-banner p { margin: 0; color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.inline-form { display: inline; }
.price-table input { min-width: 95px; }
.price-table .service-title strong,
.price-table .service-title small { display: block; }
.price-table .service-title small { margin-top: 3px; color: var(--muted); }
.price-warning { margin-top: 4px; color: #965900; font-size: 12px; font-weight: 750; }
.price-below-min { background: #fff9ed !important; border-color: #dc8e16 !important; }

.hint-box,
.warning-box {
  padding: 15px 17px;
  border-radius: 8px;
  border-left-width: 4px;
  border-left-style: solid;
}
.hint-box { color: #245e76; background: #eef9fd; border: 1px solid #c6e7f4; border-left: 4px solid var(--mc4-blue); }
.warning-box { color: #7e5500; background: #fff8e8; border: 1px solid #ecd29f; border-left: 4px solid var(--mc4-orange); }

.customer-selector {
  margin-bottom: 18px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.customer-selector label { display: grid; gap: 7px; font-weight: 800; }
.customer-selector select { width: 100%; padding: 11px; background: #fff; border: 1px solid var(--line-strong); border-radius: 7px; }
.save-result { font-size: 13px; font-weight: 750; }
.permissions-grid td:nth-child(n+2) { font-weight: 800; }
.money-positive { color: var(--success); }
.money-negative { color: var(--danger); }
.accent-line { display: none; }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-column { grid-template-columns: 1fr; }
  .service-edit-row { grid-template-columns: 30px 1fr 1fr 100px 100px; }
  .service-edit-row > :last-child { grid-column: 2 / -1; }
}

@media (max-width: 920px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: -300px; width: 270px; transition: left .22s ease; box-shadow: 20px 0 50px rgba(0,0,0,.25); }
  .sidebar.open { left: 0; }
  .topbar { padding: 14px 18px; }
  .menu-toggle { display: inline-grid; place-items: center; }
  .page-content { padding: 26px 18px 44px; }
  .offer-meta-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand-panel { min-height: auto; padding: 38px 28px 42px; }
  .auth-brand-content h1 { font-size: clamp(42px, 10vw, 62px); }
  .auth-brand-content > p { font-size: 15px; }
  .auth-brand-accent { margin-bottom: 35px; }
  .auth-brand-footer { margin-top: 38px; }
  .auth-form-panel { min-height: auto; padding: 52px 28px; }
}

@media (max-width: 680px) {
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .page-actions,
  .offer-head { align-items: flex-start; flex-direction: column; }
  .offer-total-box { width: 100%; min-width: 0; text-align: left; }
  .app-footer { padding: 17px 18px; flex-direction: column; gap: 8px; }
  .detail-list { grid-template-columns: 1fr; gap: 3px; }
  .detail-list dd { margin-bottom: 10px; }
  .service-edit-row { grid-template-columns: 30px 1fr; }
  .service-edit-row > * { grid-column: auto; }
  .service-edit-row > :not(:first-child) { grid-column: 2; }
  .offer-meta-grid { grid-template-columns: 1fr; }
  .logo-preview { align-items: stretch; flex-direction: column; }
  .logo-preview-stage { min-width: 0; }
  .topbar-heading h1 { font-size: 21px; }
  .logout-link { padding: 8px 10px; }
  .auth-card h2 { font-size: 36px; }
}

@media print {
  .sidebar,
  .topbar,
  .app-footer,
  .page-actions,
  .no-print { display: none !important; }
  .app-shell { display: block; }
  .page-content { max-width: none; padding: 0; }
  .card,
  .table-wrap { border: 0; box-shadow: none; }
  .content-shell { display: block; }
}
