﻿:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --line: #d5deeb;
  --line-strong: #c5d3e6;
  --text: #13253a;
  --text-soft: #51627a;
  --muted: #70839a;
  --ink: #0d2f55;
  --ink-2: #1f4b82;
  --primary: #1463b8;
  --primary-2: #0f4f93;
  --primary-soft: #e9f2ff;
  --surface-3: #f4f8ff;
  --accent: #0f7c89;
  --accent-2: #0c6470;
  --danger: #e04a4a;
  --danger-2: #c93e3e;
  --shadow-1: 0 10px 24px rgba(17, 51, 102, 0.08);
  --shadow-2: 0 18px 38px rgba(17, 51, 102, 0.10);
  --radius-xl: 18px;
  --radius-lg: 12px;
  --radius-sm: 8px;
  --sidebar-width: 270px;
  --header-h: 72px;
  --ring: 0 0 0 3px rgba(20, 99, 184, 0.2);
}

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Source+Sans+3:wght@400;500;600;700&display=swap');

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Manrope', 'Source Sans 3', 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 580px at 0% -14%, rgba(20, 99, 184, 0.10), transparent 60%),
    radial-gradient(900px 420px at 100% 8%, rgba(15, 124, 134, 0.10), transparent 62%),
    linear-gradient(155deg, #f0f5fc 0%, #f8fbff 38%, #f3f6fb 100%);
}

#app {
  width: 100%;
  max-width: none;
  padding: 14px 16px 22px;
}

body.sidebar-compact {
  --sidebar-width: 88px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(130deg, #0f356a, #1a5d9e);
  color: #fff;
  min-height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 10px 24px rgba(8, 31, 66, 0.22);
}

header .brand {
  max-width: calc(100% - 190px);
}

header h1 {
  margin: 0;
  letter-spacing: 0.2px;
  font-size: 1.26rem;
}

.brand p {
  margin: 4px 0 0;
  opacity: 0.9;
  color: #dbe9ff;
  font-size: 0.89rem;
}

#userBox {
  margin: 0;
  color: #ecf3ff;
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.35;
}

.sidebarToggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  min-height: 38px;
  border-radius: 999px;
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

.sidebarToggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sidebarToggle span:last-child {
  font-size: 0.98rem;
  line-height: 1;
}

.activeViewBadge {
  margin-left: auto;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #ecf4ff;
  font-weight: 700;
  font-size: 0.86rem;
  min-width: 210px;
  max-width: 40%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activeViewBadge small {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  color: #d4e8ff;
  font-weight: 500;
}

.appShell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: 14px;
  align-items: start;
  min-height: calc(100vh - 130px);
  transition: grid-template-columns 0.24s ease;
}

#sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  min-height: calc(100vh - 132px);
  padding: 14px;
  background: linear-gradient(178deg, #175ba3, #124d84);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.sidebarHeader {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebarHeader h2 {
  margin: 0 0 4px;
  color: #f0f6ff;
  font-size: 1.05rem;
}

.sidebarHeader p {
  margin: 0;
  color: #d9e9ff;
  font-size: 0.82rem;
}

body.sidebar-compact #sidebar .sidebarHeader h2,
body.sidebar-compact #sidebar .sidebarHeader p {
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  margin: 0;
}

.sidebarSearchWrap {
  margin-top: 4px;
}

.sidebarSearchWrap input {
  width: 100%;
  margin: 0;
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.16);
  color: #f5fbff;
}

.sidebarSearchWrap input::placeholder {
  color: rgba(245, 251, 255, 0.75);
}

nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

nav button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: flex-start;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(9, 54, 108, 0.28);
  color: #fff;
  font-weight: 700;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.14s ease, box-shadow 0.2s ease;
}

nav button span.label {
  transition: opacity 0.18s ease, width 0.18s ease;
}

body.sidebar-compact nav button {
  justify-content: center;
}

body.sidebar-compact nav button span.label {
  width: 0;
  opacity: 0;
  overflow: hidden;
}

nav button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 18px rgba(13, 43, 84, 0.24);
}

nav button.active {
  background: linear-gradient(135deg, #0f7b9a, #0f6cbf);
  border-color: #0e4d86;
}

nav button#logoutBtn {
  background: #2a364a;
  border-color: #1e2a3b;
}

nav button#logoutBtn:hover {
  background: #1f2d43;
}

#appMain {
  width: 100%;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 18px;
  margin: 0;
  position: relative;
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
}

.card + .card {
  margin-top: 12px;
}

section.view.card > .list,
section.view.card > .scrollTable {
  background: #fff;
  border: 1px solid #deebff;
  border-radius: 12px;
  padding: 8px 10px;
  margin: 0;
  min-height: 140px;
  max-height: 360px;
}

section.view.card .msg {
  min-height: 22px;
  margin: 0;
}

.card:hover {
  box-shadow: var(--shadow-2);
}

#appMain {
  width: 100%;
}

.appContent {
  display: grid;
  gap: 16px;
}

.sectionHeader {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.sectionHeader h2,
.sectionHeader .sectionTitle,
.sectionHeader p {
  margin: 0;
}

.sectionSubtitle {
  color: var(--text-soft);
  font-size: 0.9rem;
  margin: 2px 0 0;
  line-height: 1.35;
}

.view.card {
  padding: 20px;
  display: grid;
  gap: 14px;
}

.view.card > h2 {
  margin: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5eefc;
  display: inline-flex;
  width: fit-content;
  min-width: min(100%, 460px);
}

.view.card > h2::after {
  content: '';
  align-self: flex-end;
  flex: 1;
  height: 1px;
  margin-left: 12px;
  width: 42px;
}

section.view.card > button {
  justify-self: start;
}

.hidden {
  display: none !important;
}

h2 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 1.16rem;
  letter-spacing: 0.15px;
}

h3 {
  margin: 2px 0;
  color: var(--text-soft);
  font-size: 0.94rem;
  letter-spacing: 0.14px;
  text-transform: uppercase;
  font-weight: 700;
}

.row,
.inline {
  display: grid;
  gap: 10px;
  margin: 0;
}

section.view.card .inline,
section.view.card .row {
  background: linear-gradient(160deg, #f8fbff 0%, #f2f7ff 100%);
  border: 1px solid #d5e1f2;
  border-radius: var(--radius-lg);
  padding: 14px;
  margin: 0;
  position: relative;
}

section.view.card .inline::before,
section.view.card .row::before {
  content: '';
  position: absolute;
  inset: 0 auto auto 0;
  height: 3px;
  width: 34px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
}

.panel {
  background: linear-gradient(160deg, #f8fbff 0%, #f2f7ff 100%);
  border: 1px solid #d5e1f2;
  border-radius: var(--radius-lg);
  padding: 14px;
  position: relative;
  box-shadow: 0 8px 20px rgba(16, 59, 112, 0.06);
}

.panel::before {
  content: '';
  position: absolute;
  inset: 0 auto auto 0;
  height: 3px;
  width: 34px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
}

.clientsWorkspace {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(330px, 440px) 1fr;
  align-items: start;
}

.clientsWorkspace .panel h3 {
  margin: 2px 0 12px;
}

.clientsWorkspace .panel .inline {
  background: transparent;
  border: 0;
  padding: 0;
}

.clientsWorkspace .panel .inline::before {
  display: none;
}

.clientsWorkspace .list {
  margin-top: 4px;
  max-height: 530px;
}

.inline {
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  align-items: end;
}

.row {
  grid-template-columns: 1fr;
  margin-bottom: 0;
}

label {
  color: var(--text-soft);
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 0.9rem;
}

input,
select,
textarea,
button {
  min-height: 40px;
  font: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: 10px 11px;
  color: var(--text);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--ring);
}

button {
  cursor: pointer;
  border-color: var(--primary);
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: #fff;
  letter-spacing: 0.15px;
  font-weight: 700;
}

button:hover {
  background: linear-gradient(180deg, #1a71bf, #0e4b88);
}

button:active {
  transform: translateY(1px);
}

button.danger {
  background: linear-gradient(180deg, #e95d5d, #c93f3f);
  border-color: #be3e3e;
}

button.danger:hover {
  background: linear-gradient(180deg, #da5454, #a93636);
}

button.secondary {
  background: #fff;
  color: var(--primary-2);
  border-color: #a8c9ee;
}

button.secondary:hover {
  background: #edf4ff;
}

button:focus-visible,
nav button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  box-shadow: var(--ring);
}

#loginCard {
  max-width: 460px;
  margin: 28px auto 0;
  backdrop-filter: blur(1.5px);
}

#loginCard h2 {
  margin-bottom: 14px;
}

#loginCard .row {
  margin-bottom: 10px;
}

.msg {
  margin: 8px 0 0;
  color: var(--danger-2);
  min-height: 20px;
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
}

.kpi {
  background: linear-gradient(150deg, #f4f9ff 0%, #ecf5ff 100%);
  border: 1px solid #d8e8fb;
  border-radius: 12px;
  padding: 12px;
}

.kpi h3 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: var(--text-soft);
}

.kpi p {
  margin: 0;
  font-weight: 800;
  font-size: 1.46rem;
}

.list,
.scrollTable {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  max-height: 360px;
  overflow: auto;
  background: #fff;
}

.item {
  border-bottom: 1px solid #e8f1fc;
  padding: 12px 10px;
  display: grid;
  gap: 6px;
  line-height: 1.35;
}

.item:hover {
  background: #fbfdff;
}

.item:last-child {
  border-bottom: 0;
}

.itemActions {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.itemActions .actionLink,
.actionLink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary-2);
  text-decoration: none;
  font-weight: 700;
}

.itemActions .actionLink:hover,
.actionLink:hover {
  background: #edf5ff;
}

.badge {
  display: inline-block;
  margin-right: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #deedff;
  color: #1b4d87;
  font-weight: 700;
  font-size: 0.72rem;
}

.small {
  font-size: 0.84rem;
  color: var(--muted);
}

.skipLink {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 999;
  transform: translateY(-150%);
  background: #0d2f55;
  color: #fff;
  padding: 9px 12px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 700;
  transition: transform 0.18s ease;
}

.skipLink:focus {
  transform: translateY(0);
}

#toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10000;
  padding: 10px 14px;
  border-radius: 10px;
  max-width: min(86vw, 430px);
  background: #0d2f55;
  color: #fff;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: var(--shadow-2);
}

#toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#toast.success {
  background: #0f7d89;
  border: 1px solid rgba(13, 150, 130, 0.75);
}

#toast.error {
  background: #e04a4a;
  border: 1px solid rgba(215, 74, 74, 0.8);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #ecf2fa;
  border-radius: 10px;
}

*::-webkit-scrollbar-thumb {
  background: #abc2df;
  border-radius: 10px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #86a8d2;
}

nav button[aria-current='page'] {
  outline: 2px solid rgba(255, 255, 255, 0.95);
  outline-offset: -6px;
}

nav button.search-hidden,
nav button#logoutBtn.search-hidden {
  display: none !important;
}

@media (max-width: 900px) {
  #app {
    padding: 10px 8px 16px;
  }

  .appShell {
    grid-template-columns: 1fr;
  }

  .sidebarToggle {
    display: inline-flex;
  }

  #sidebar {
    position: static;
    width: 100%;
    max-width: 100%;
    min-height: auto;
    max-height: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    transition: max-height 0.2s ease;
  }

  body.sidebar-open #sidebar {
    max-height: 1600px;
  }

  #sidebar nav {
    padding: 8px 0 0;
    display: none;
  }

  body.sidebar-open #sidebar nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body.sidebar-open #sidebar button {
    white-space: normal;
    text-align: center;
  }

  body.sidebar-open #sidebar nav button span.label {
    width: auto;
    opacity: 1;
    overflow: visible;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .card {
    padding: 14px;
  }

  .view.card {
    padding: 16px;
    gap: 12px;
  }

  .clientsWorkspace {
    grid-template-columns: 1fr;
  }

  .sectionHeader {
    align-items: start;
  }

  .panel {
    padding: 12px;
  }
}

@media (max-width: 560px) {
  .activeViewBadge {
    display: none;
  }

  header {
    gap: 10px;
  }

  .inline {
    grid-template-columns: 1fr;
  }

  .row {
    grid-template-columns: 1fr;
  }

  section.view.card {
    gap: 10px;
  }

  section.view.card .inline,
  section.view.card .row {
    padding: 12px;
  }

  .itemActions {
    flex-direction: column;
    align-items: stretch;
  }

  .itemActions .actionLink {
    width: 100%;
    justify-content: flex-start;
  }
}

body.sidebar-open::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 3;
  background: rgba(11, 28, 50, 0.5);
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
