:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --ink: #17211d;
  --muted: #627069;
  --line: #d9e2dd;
  --green: #1f6f5b;
  --green-dark: #15513f;
  --teal: #287c8e;
  --amber: #f2c14e;
  --amber-dark: #9d6b16;
  --red: #b84a44;
  --blue: #365f91;
  --shadow: 0 16px 40px rgba(34, 47, 40, 0.12);
  --sidebar: 296px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a,
.link-button {
  color: var(--green-dark);
}

.screen {
  min-height: 100vh;
}

.auth-screen,
.company-screen {
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-panel,
.company-panel {
  width: min(980px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-panel {
  display: grid;
  grid-template-columns: 0.88fr 1.12fr;
  min-height: 560px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 40px;
  background: #203d34;
  color: #f7fbf8;
}

.logo-placeholder {
  display: grid;
  place-items: center;
  width: 148px;
  height: 92px;
  border: 1px dashed rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.82);
  font-weight: 700;
}

.brand-logo {
  display: block;
  width: min(260px, 100%);
  height: auto;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
}

.auth-brand h1,
.company-panel h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.55rem);
  line-height: 1.05;
  font-weight: 800;
}

.auth-brand p {
  margin: 18px 0 0;
  color: #c8dbd2;
  line-height: 1.55;
}

.sync-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #f7fbf8;
  font-size: 0.82rem;
  font-weight: 700;
}

.auth-form-wrap {
  padding: 44px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-form-wrap h2,
.panel-title h2,
.content-title h2 {
  margin: 0;
  font-size: 1.8rem;
}

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

.form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label,
.filter-field label {
  color: #34463d;
  font-size: 0.82rem;
  font-weight: 750;
}

.field input,
.filter-field input,
.filter-field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.field input:focus,
.filter-field input:focus,
.filter-field select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 111, 91, 0.16);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  border-radius: 6px;
  font-weight: 800;
}

.primary-button {
  background: var(--green);
  color: #fff;
  padding: 0 18px;
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  background: #e6f0eb;
  color: var(--green-dark);
  padding: 0 16px;
}

.ghost-button {
  background: transparent;
  color: var(--green-dark);
  padding: 0 12px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.form-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin-top: 16px;
}

.link-button {
  background: none;
  padding: 0;
  min-height: auto;
  font-weight: 750;
}

.server-config {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
}

.server-config summary {
  padding: 12px 14px;
  color: var(--green-dark);
  cursor: pointer;
  font-weight: 850;
}

.server-config-form {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
}

.notice,
.error {
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 0.92rem;
  line-height: 1.4;
}

.notice {
  background: #edf6f1;
  color: #1e5a49;
  border: 1px solid #cce4da;
}

.error {
  background: #fff0ee;
  color: #8d302b;
  border: 1px solid #f2c2bd;
}

.company-panel {
  padding: 38px;
}

.company-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 28px;
}

.company-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px;
}

.company-card {
  display: grid;
  gap: 8px;
  min-height: 110px;
  text-align: left;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.company-card:hover {
  border-color: var(--green);
  box-shadow: 0 10px 24px rgba(31, 111, 91, 0.12);
}

.company-card strong {
  font-size: 1.02rem;
}

.company-card span {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: #203d34;
  color: #f7fbf8;
  padding: 22px 18px;
}

.profile-section {
  display: grid;
  gap: 12px;
}

.avatar {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f2c14e;
  color: #203d34;
  font-size: 1.65rem;
  font-weight: 900;
}

.user-name {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 9px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 850;
}

.company-name {
  margin: 0;
  color: #c9dbd3;
  font-size: 0.92rem;
  line-height: 1.35;
}

.profile-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin-top: 4px;
}

.mini-button {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #f7fbf8;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 800;
}

.mini-button:hover {
  background: rgba(242, 193, 78, 0.2);
}

.sidebar-separator {
  height: 1px;
  margin: 22px 0;
  background: rgba(255, 255, 255, 0.2);
}

.menu-section-title {
  margin: 18px 0 9px;
  color: #a9c4b9;
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.accordion-button,
.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border-radius: 6px;
  background: transparent;
  color: #f7fbf8;
  text-align: left;
  font-weight: 800;
}

.accordion-button:hover,
.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.12);
}

.accordion-items {
  display: grid;
  gap: 4px;
  margin: 4px 0 8px 10px;
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
}

.sub-link {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 6px;
  background: transparent;
  color: #dce9e3;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 700;
}

.submenu-title {
  margin: 10px 0 3px;
  color: #f2c14e;
  font-size: 0.73rem;
  font-weight: 900;
  text-transform: uppercase;
}

.sub-link:hover,
.sub-link.active {
  background: rgba(242, 193, 78, 0.18);
  color: #fff;
}

.main-area {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.mobile-menu {
  display: none;
  width: auto;
  padding: 0 12px;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.dot.offline {
  background: var(--amber-dark);
}

.content-panel {
  min-width: 0;
}

.content-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.content-title p,
.panel-title p {
  max-width: 820px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.compact-summary {
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  max-width: 520px;
}

.summary-card {
  min-height: 132px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.summary-card.primary {
  background: #203d34;
  color: #fff;
}

.summary-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.summary-card.primary .summary-label {
  color: #bdd4ca;
}

.summary-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-size: 2rem;
  line-height: 1;
  font-weight: 900;
}

.summary-unit {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 750;
}

.summary-card.primary .summary-unit {
  color: #dce9e3;
}

.trend {
  display: inline-flex;
  margin-top: 16px;
  color: #dce9e3;
  font-weight: 800;
}

.trend.positive {
  color: #d9f5e8;
}

.trend.negative {
  color: #ffddd8;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(128px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 18px;
}

.filter-actions {
  display: flex;
  grid-column: 1 / -1;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.filter-actions button {
  white-space: nowrap;
}

.data-form-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 18px;
}

.record-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.table-toolbar strong {
  display: block;
}

.table-toolbar span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1360px;
  border-collapse: collapse;
}

.compact-table {
  min-width: 820px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf1ee;
  text-align: left;
  vertical-align: top;
  font-size: 0.88rem;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f5f2;
  color: #30473d;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #fbfcf7;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 850;
}

.status.available {
  background: #e5f5ec;
  color: #1f6f5b;
}

.status.processed {
  background: #eef0f7;
  color: var(--blue);
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.page-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.page-button {
  min-width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.page-button.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.empty-state,
.module-placeholder {
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}

.drawer-backdrop {
  display: none;
}

@media (max-width: 1180px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .filter-bar {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .record-form {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .filter-actions {
    justify-content: flex-start;
  }

  .record-form button {
    width: fit-content;
  }
}

@media (max-width: 860px) {
  .auth-panel {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: 260px;
  }

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

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 5;
    width: min(310px, 86vw);
    transform: translateX(-102%);
    transition: transform 160ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 4;
    display: block;
    background: rgba(23, 33, 29, 0.42);
  }

  .mobile-menu {
    display: inline-grid;
  }

  .main-area {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .auth-screen,
  .company-screen {
    padding: 14px;
  }

  .auth-brand,
  .auth-form-wrap,
  .company-panel {
    padding: 24px;
  }

  .company-header,
  .content-title,
  .table-toolbar,
  .pagination,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-grid,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .record-form {
    grid-template-columns: 1fr;
  }

  .summary-card {
    min-height: 118px;
  }

  .filter-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-actions button {
    width: 100%;
  }

  .record-form button {
    width: 100%;
  }
}
