:root {
  --app-bg: #eef3f8;
  --app-surface: #ffffff;
  --app-surface-soft: #f7f9fc;
  --app-text: #0f172a;
  --app-muted: #526074;
  --app-border: #d9e2ec;
  --app-shadow: 0 20px 42px rgba(15, 23, 42, 0.08);
  --app-shadow-soft: 0 10px 22px rgba(15, 23, 42, 0.06);
  --app-accent: #0f6cbd;
  --app-accent-soft: #e7f2ff;
  --app-danger-soft: #fff1f1;
  --app-danger: #c53030;
  --app-radius: 14px;
  --app-header-height: 62px;
  --app-header-offset: 12px;
  --sidebar-collapsed: 84px;
  --sidebar-expanded: 248px;
  --mobile-nav-height: 76px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  font-family: "Inter", sans-serif;
  color: var(--app-text);
  background:
    radial-gradient(circle at top right, rgba(15, 108, 189, 0.09), transparent 28%),
    radial-gradient(circle at bottom left, rgba(15, 108, 189, 0.08), transparent 30%),
    var(--app-bg);
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;
  width: var(--sidebar-collapsed);
  height: 100vh;
  padding: 14px 10px 16px;
  background: linear-gradient(185deg, #102339 0%, #112d49 100%);
  border-right: 1px solid rgba(217, 226, 236, 0.26);
  box-shadow: 0 18px 34px rgba(2, 6, 23, 0.25);
  transition: width 0.28s ease;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #f8fafc;
  min-height: 50px;
  padding: 0 10px;
}

.logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text {
  font-size: 1.04rem;
  letter-spacing: 0.02em;
  font-weight: 700;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
}

.logo-separator {
  height: 1px;
  margin: 12px 8px 16px;
  background: rgba(217, 226, 236, 0.24);
}

.sidebar-rail-toggle {
  position: absolute;
  top: 98px;
  right: -14px;
  width: 28px;
  height: 52px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-left-color: rgba(217, 226, 236, 0.6);
  background: linear-gradient(180deg, #f9fcff 0%, #eef4fb 100%);
  color: #334155;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.14);
  z-index: 1060;
}

.sidebar-rail-toggle i {
  font-size: 0.76rem;
}

.sidebar-rail-toggle:hover {
  background: linear-gradient(180deg, #ffffff 0%, #e9f2ff 100%);
  color: #0f6cbd;
}

body.app-shell--rail-pinned .sidebar-rail-toggle i {
  transform: rotate(180deg);
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.sidebar-nav li.logout {
  margin-top: auto;
}

.sidebar-nav li a {
  text-decoration: none;
  color: #d7e2ee;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 7px 9px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background-color 0.22s ease, border-color 0.22s ease, color 0.22s ease, transform 0.22s ease;
}

.sidebar-nav li a:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(217, 226, 236, 0.28);
  color: #ffffff;
  transform: translateY(-1px);
}

.sidebar-nav li.active a {
  background: rgba(231, 242, 255, 0.2);
  color: #ffffff;
  border-color: rgba(176, 212, 255, 0.62);
}

.sidebar-nav li.logout a {
  background: rgba(197, 48, 48, 0.08);
}

.sidebar-nav li.logout a:hover {
  border-color: rgba(250, 190, 190, 0.55);
  color: #ffe4e4;
}

.nav-icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.02rem;
  flex-shrink: 0;
}

.nav-label {
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
  font-size: 0.94rem;
  font-weight: 500;
}

.header {
  position: fixed;
  top: var(--app-header-offset);
  left: calc(var(--sidebar-collapsed) + 14px);
  z-index: 1030;
  width: calc(100% - var(--sidebar-collapsed) - 28px);
  height: var(--app-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border: 1px solid rgba(217, 226, 236, 0.9);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07);
  transition: left 0.28s ease, width 0.28s ease;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
}

.header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--app-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-toggle {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--app-border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--app-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-toggle:hover {
  border-color: #b8c8d9;
  color: var(--app-text);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.1);
}

.nav-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-pill {
  background: var(--app-accent-soft);
  color: #0d5089;
  border: 1px solid #c6e0ff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-btn {
  text-decoration: none;
  font-family: "Inter", sans-serif;
  background: linear-gradient(160deg, #0f6cbd, #0b5fa8);
  color: #ffffff;
  border: 1px solid transparent;
  padding: 9px 17px;
  font-size: 0.89rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.login-btn:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(15, 108, 189, 0.24);
}

.content {
  margin-left: var(--sidebar-collapsed);
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(var(--app-header-height) + var(--app-header-offset) + 14px);
  background: transparent;
  transition: margin-left 0.28s ease;
  display: flex;
  flex-direction: column;
}

@media screen and (min-width: 901px) {
  .sidebar:hover,
  body.app-shell--rail-pinned .sidebar {
    width: var(--sidebar-expanded);
  }

  .sidebar:hover .brand-text,
  .sidebar:hover .nav-label,
  body.app-shell--rail-pinned .brand-text,
  body.app-shell--rail-pinned .nav-label {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
  }

  body.app-shell--rail-pinned .content {
    margin-left: var(--sidebar-expanded);
  }

  body.app-shell--rail-pinned .header {
    left: calc(var(--sidebar-expanded) + 14px);
    width: calc(100% - var(--sidebar-expanded) - 28px);
  }
}

.footer {
  background: linear-gradient(180deg, #13263a 0%, #101f30 100%);
  color: #f5f8fc;
  padding: 18px clamp(18px, 3vw, 34px) 12px;
  font-size: 0.86rem;
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.08);
  border-top: 1px solid rgba(217, 226, 236, 0.2);
}

.content > .footer {
  margin-top: auto;
}

.footer-main {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-brand-logos {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-logo {
  height: 46px;
  object-fit: contain;
}

.footer-brand-copy {
  margin: 0;
  color: #b6c7d9;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.footer-contact {
  color: #d6e0eb;
  line-height: 1.6;
  min-width: 0;
}

.footer-address {
  margin: 0 0 4px;
  word-break: break-word;
}

@media screen and (max-width: 1180px) {
  .footer-main {
    grid-template-columns: 1fr;
    gap: 12px;
    text-align: center;
  }

  .footer-brand-logos,
  .footer-social {
    justify-content: center;
  }
}

.footer-link {
  color: #ffffff;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  padding-bottom: 1px;
}

.footer-social {
  display: flex;
  gap: 10px;
  justify-self: end;
}

.social-link {
  font-size: 1rem;
  text-decoration: none;
  color: #eff4fa;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(215, 226, 238, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.social-link:hover {
  background-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.footer-bottom {
  text-align: center;
  font-size: 0.74rem;
  color: #9cb0c4;
  border-top: 1px solid rgba(217, 226, 236, 0.16);
  margin-top: 12px;
  padding-top: 10px;
}

.footer-bottom p {
  margin: 0;
}

.sidebar a:focus-visible,
.nav-toggle:focus-visible,
.login-btn:focus-visible,
.footer a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #8ec5ff;
  outline-offset: 2px;
}

.table-container {
  width: calc(100% - 40px);
  margin: 0 auto 20px;
  background-color: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  box-shadow: var(--app-shadow-soft);
  overflow: auto;
  max-height: 60vh;
}

.table-container table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  line-height: 1.45;
}

.table-container thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--app-surface-soft);
  color: var(--app-muted);
  border-bottom: 2px solid var(--app-border);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.table-container th,
.table-container td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--app-border);
  vertical-align: top;
}

.table-container tbody tr:nth-child(even) {
  background-color: var(--app-surface-soft);
}

.table-container tbody tr:hover {
  background-color: var(--app-accent-soft);
}

.table-container tbody tr:last-child td {
  border-bottom: none;
}

.table-container td a,
.table-container th a {
  color: var(--app-accent);
}

.table-container .button-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.table-container .button-cell form {
  margin: 0;
}

@media screen and (max-width: 900px) {
  .sidebar {
    top: auto;
    bottom: 0;
    width: 100%;
    height: var(--mobile-nav-height);
    border-right: none;
    border-top: 1px solid var(--app-border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 26px rgba(15, 23, 42, 0.12);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: none;
  }

  .sidebar:hover,
  body.app-shell--rail-pinned .sidebar {
    width: 100%;
  }

  .sidebar .brand-text,
  .sidebar .nav-label {
    transform: none;
  }

  .sidebar-brand,
  .logo-separator {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    align-items: stretch;
    gap: 6px;
  }

  .sidebar-nav li {
    flex: 1;
    margin-top: 0;
  }

  .sidebar-nav li.logout {
    margin-top: 0;
  }

  .sidebar-nav li a {
    min-height: 100%;
    border-radius: 12px;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    padding: 8px 4px;
    color: #3c4b5f;
  }

  .sidebar-nav li.active a {
    color: #0f6cbd;
    background: #eef6ff;
    border-color: #d2e7ff;
  }

  .sidebar-nav li.logout a {
    background: transparent;
  }

  .nav-icon {
    width: auto;
    height: auto;
    font-size: 1rem;
  }

  .nav-label {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    font-size: 0.67rem;
    line-height: 1.1;
    letter-spacing: 0;
    font-weight: 600;
    color: inherit;
  }

  .header {
    top: 0;
    left: 0;
    width: 100%;
    height: 66px;
    padding: 0 14px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    transition: none;
  }

  .header h1 {
    font-size: 1rem;
  }

  .nav-toggle {
    display: none;
  }

  .content,
  body.app-shell--rail-pinned .content {
    margin-left: 0;
    padding-top: 66px;
    padding-bottom: calc(var(--mobile-nav-height) + 8px + env(safe-area-inset-bottom));
    transition: none;
  }

  body.app-shell--rail-pinned .header {
    left: 0;
    width: 100%;
  }

  .role-pill {
    padding: 6px 10px;
    font-size: 0.66rem;
  }

  .login-btn {
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  .footer {
    padding: 16px 14px 10px;
  }

  .footer-main {
    grid-template-columns: 1fr;
    gap: 12px;
    text-align: center;
  }

  .footer-logo {
    height: 40px;
  }

  .footer-brand-logos,
  .footer-social {
    justify-content: center;
  }

  .table-container {
    width: calc(100% - 20px);
    margin: 0 10px 16px;
    max-height: none;
  }

  .table-container th,
  .table-container td {
    padding: 10px 12px;
    font-size: 0.82rem;
  }
}
