:root {
  --iflow-orange: #ff6633;
  --iflow-orange-dark: #d94e22;
  --iflow-grey: #666666;
  --iflow-grey-dark: #2f3234;
  --iflow-grey-soft: #f1f2f2;
  --surface: #ffffff;
  --line: #dedede;
  --line-strong: #c9c9c9;
  --text: #25282a;
  --muted: #6f7477;
  --success: #34855f;
  --warning-bg: #fff4ed;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #e9ebec;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--iflow-orange-dark);
  text-decoration: none;
  font-weight: 600;
}

a:hover { color: var(--iflow-orange); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  min-height: 68px;
  background: var(--iflow-grey-dark);
  border-bottom: 5px solid var(--iflow-orange);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(47, 50, 52, 0.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand:hover { color: #ffffff; }

.brand-name {
  color: #ffffff;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.brand-i {
  color: var(--iflow-orange);
  font-style: italic;
}

.brand-subtitle {
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  color: #d9d9d9;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.main-nav a {
  color: #ffffff;
  padding: 9px 11px;
  border-radius: 6px;
  font-size: 14px;
}

.main-nav a:hover {
  background: var(--iflow-orange);
  color: #ffffff;
}

.inline-form { display: inline; }

button, .button {
  border: 1px solid var(--iflow-orange);
  background: var(--iflow-orange);
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.primary, .button:hover, button:hover {
  background: var(--iflow-orange-dark);
  border-color: var(--iflow-orange-dark);
  color: #ffffff;
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px;
  background: #ffffff;
  min-height: calc(100vh - 73px);
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

h1, h2, h3 { margin: 0 0 10px; color: var(--iflow-grey-dark); }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

.page-head p, .card p, .news-item p { margin: 0; color: var(--muted); }

.quarter-selector {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 6px;
}
.quarter-selector a {
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--iflow-grey-dark);
}
.quarter-selector a:hover {
  border-color: var(--iflow-orange);
  color: var(--iflow-orange-dark);
}
.quarter-selector a.active {
  background: var(--iflow-orange);
  border-color: var(--iflow-orange);
  color: #ffffff;
}

.section { margin-top: 24px; }

.card, .client-block, .mapping-card, .form-panel, .login-panel, .news-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.client-block, .mapping-card { margin-bottom: 18px; }

.client-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.client-title span, .news-date {
  color: var(--iflow-grey);
  font-size: 13px;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid #ececec;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--iflow-grey-dark);
  color: #ffffff;
  border-bottom-color: var(--iflow-orange);
  border-bottom-width: 2px;
  border-bottom-style: solid;
  font-size: 13px;
  font-weight: 800;
}

tr:hover td { background: #fffaf7; }

.total-row td {
  font-weight: 800;
  background: #f7f7f7;
}

.project-row td {
  background: #fff4ed;
  font-weight: 700;
}

dialog {
  width: min(1000px, 92vw);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .25);
}

dialog::backdrop { background: rgba(0, 0, 0, .38); }

dialog form { margin-top: 16px; text-align: right; }

.progress {
  width: 160px;
  height: 10px;
  background: #dddddd;
  border-radius: 999px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--success);
}

.progress.over-plan {
  box-shadow: 0 0 0 1px var(--iflow-orange) inset;
}

.progress.over-plan span { background: var(--iflow-orange); }

.progress-label {
  margin-left: 8px;
  font-size: 13px;
  color: var(--iflow-grey);
  font-weight: 700;
}

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

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 18px 0;
}

.form-panel { max-width: 720px; }
.form-panel p { display: grid; gap: 6px; }

input, select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--iflow-orange);
  outline: 2px solid rgba(255, 102, 51, 0.18);
}

.wide-input { min-width: 100%; }

.message {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--iflow-orange);
}

.message.warning {
  background: var(--warning-bg);
  border-color: #ffd2c0;
  border-left-color: var(--iflow-orange);
}

.message.success {
  background: #eef8f3;
  border-color: #b8dcc9;
  border-left-color: var(--success);
}

.mapping-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

.mapping-edit {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.mapping-select {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.mapping-select input { width: auto; }

.bulk-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.bulk-toolbar.bottom { margin-top: 4px; }

.search-panel {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.tabs a {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--iflow-grey-dark);
  padding: 8px 12px;
  border-radius: 6px;
}

.tabs a:hover {
  border-color: var(--iflow-orange);
  color: var(--iflow-orange-dark);
}

.region-panel { scroll-margin-top: 86px; }
.dashboard-tabs { margin-top: 22px; }

.tab-labels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 22px;
  padding: 6px;
  background: var(--iflow-grey-dark);
  border: 1px solid var(--iflow-grey-dark);
  border-radius: 8px;
}

.tab-labels a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid transparent;
  background: #ffffff;
  color: var(--iflow-grey-dark);
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
}

.tab-labels a:hover {
  color: var(--iflow-orange-dark);
  border-color: var(--iflow-orange);
}

.tab-labels a.active {
  background: var(--iflow-orange);
  border-color: var(--iflow-orange);
  color: #ffffff;
}

.tab-content { display: block; }

.calculation-note {
  margin: 0 0 16px;
  padding: 11px 14px;
  background: #fff7f3;
  border: 1px solid #ffd8c9;
  border-left: 4px solid var(--iflow-orange);
  border-radius: 6px;
  color: var(--iflow-grey-dark);
  font-size: 13px;
  line-height: 1.45;
}

.news-list {
  display: grid;
  gap: 14px;
  max-width: 900px;
}

.news-item {
  border-left: 4px solid var(--iflow-orange);
}

.news-item h2 { margin-top: 4px; }

pre {
  white-space: pre-wrap;
  margin: 0;
}

@media (max-width: 760px) {
  .topbar, .page-head, .client-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar { padding: 12px 18px; }
  nav, .actions { gap: 8px; }
  .page { padding: 18px; }
  h1 { font-size: 25px; }
  table { display: block; overflow-x: auto; }
  .mapping-edit, .search-panel { grid-template-columns: 1fr; }
  .tab-labels { grid-template-columns: 1fr; }
}
