:root {
  --ui-bg: #d8e9f7;
  --ui-surface: #ffffff;
  --ui-surface-soft: #f8fafc;
  --ui-text: #111827;
  --ui-muted: #64748b;
  --ui-border: #dbe3ee;
  --ui-primary: #0f766e;
  --ui-primary-dark: #115e59;
  --ui-blue: #2563eb;
  --ui-sky: #0ea5e9;
  --ui-amber: #f59e0b;
  --ui-rose: #e11d48;
  --ui-violet: #7c3aed;
  --ui-shadow: 0 24px 66px rgba(8, 37, 73, 0.16);
  --ui-shadow-sm: 0 14px 34px rgba(8, 37, 73, 0.11);
  --ui-glass: rgba(255, 255, 255, 0.76);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  color: var(--ui-text);
  font-family: Inter, "Segoe UI", Arial, sans-serif !important;
  background:
    radial-gradient(circle at 14% 0%, rgba(56, 189, 248, 0.30), transparent 28%),
    radial-gradient(circle at 92% 8%, rgba(14, 116, 144, 0.24), transparent 30%),
    radial-gradient(circle at 52% 100%, rgba(37, 99, 235, 0.18), transparent 36%),
    linear-gradient(135deg, #0f2742 0%, #1d5f8f 44%, #b9ddf4 100%) !important;
  background-attachment: fixed;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  right: clamp(18px, 5vw, 70px);
  bottom: clamp(18px, 5vw, 70px);
  width: min(42vw, 430px);
  aspect-ratio: 1;
  background: url("logo.png") center / contain no-repeat;
  opacity: 0.045;
  pointer-events: none;
  z-index: 0;
  filter: saturate(0.9) contrast(1.05);
}

body:not(:has(.container)):not(:has(.login-box)) {
  padding: 32px !important;
}

body:not(:has(.container)):not(:has(.login-box)) > *,
body:has(.login-box) > * {
  position: relative;
  z-index: 1;
}

h1,
h2 {
  color: var(--ui-text);
  letter-spacing: 0;
}

h2 {
  margin: 0 auto 20px;
  width: min(100%, 1180px);
  font-size: 28px;
  font-weight: 900;
}

body:not(:has(.container)):not(:has(.login-box)) > h2:first-of-type {
  position: relative;
  padding: 24px 28px;
  border: 1px solid rgba(219, 227, 238, 0.82);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(239, 246, 255, 0.90)),
    #fff;
  box-shadow: var(--ui-shadow-sm);
  overflow: hidden;
}

body:not(:has(.container)):not(:has(.login-box)) > h2:first-of-type::after {
  content: "";
  position: absolute;
  inset: auto 24px 0 24px;
  height: 4px;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(90deg, var(--ui-primary), var(--ui-blue), var(--ui-amber));
}

.form-box,
.login-box {
  width: min(100%, 1180px) !important;
  border: 1px solid rgba(219, 227, 238, 0.76);
  border-radius: 8px !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.94)),
    var(--ui-glass) !important;
  box-shadow: var(--ui-shadow) !important;
  backdrop-filter: blur(14px);
}

.form-box {
  margin: 0 auto 30px;
  padding: 30px !important;
}

.login-box {
  max-width: 440px !important;
  padding: 34px !important;
}

.login-box h1 {
  font-size: 30px;
  font-weight: 900;
}

.login-box h1::after {
  content: "";
  display: block;
  width: 72px;
  height: 4px;
  margin-top: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ui-primary), var(--ui-blue));
}

label {
  color: #334155;
  font-size: 12px;
  font-weight: 750 !important;
  letter-spacing: 0.01em;
}

input,
select,
textarea {
  min-height: 46px;
  border: 1px solid var(--ui-border) !important;
  border-radius: 8px !important;
  background: rgba(255, 255, 255, 0.94) !important;
  color: var(--ui-text);
  font: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.75) !important;
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.16);
}

input[readonly] {
  background: #f8fafc !important;
  color: #475569;
}

button {
  min-height: 46px;
  padding-inline: 20px !important;
  border-radius: 8px !important;
  background: linear-gradient(135deg, #0f766e, #2563eb) !important;
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.22);
  font-weight: 800 !important;
  letter-spacing: 0;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 36px rgba(37, 99, 235, 0.28);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.65;
  transform: none;
}

hr {
  border: 0;
  border-top: 1px solid var(--ui-border);
  margin: 20px 0;
}

table {
  overflow: hidden;
  border: 1px solid var(--ui-border) !important;
  border-radius: 8px;
  box-shadow: var(--ui-shadow-sm) !important;
  background: rgba(255, 255, 255, 0.96) !important;
}

th {
  background: linear-gradient(180deg, #eef6ff, #f8fafc) !important;
  color: #1e293b;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

td,
th {
  border-color: #e5eaf2 !important;
  padding-block: 11px !important;
}

tbody tr:nth-child(even) {
  background: #f8fafc;
}

.container {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 8% 0%, rgba(56, 189, 248, 0.30), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(14, 116, 144, 0.23), transparent 30%),
    radial-gradient(circle at 48% 100%, rgba(37, 99, 235, 0.18), transparent 36%),
    linear-gradient(135deg, #0f2742 0%, #1d5f8f 46%, #b9ddf4 100%) !important;
}

.container::before {
  content: "";
  position: fixed;
  right: clamp(24px, 5vw, 76px);
  bottom: clamp(24px, 5vw, 76px);
  width: min(42vw, 440px);
  aspect-ratio: 1;
  background: url("logo.png") center / contain no-repeat;
  opacity: 0.055;
  pointer-events: none;
  z-index: 0;
  filter: saturate(0.88) contrast(1.05);
}

.sidebar {
  position: relative;
  z-index: 2;
  width: 272px !important;
  border-right: 1px solid rgba(219, 227, 238, 0.72);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(232, 244, 255, 0.88)) !important;
  box-shadow: 18px 0 52px rgba(8, 37, 73, 0.13);
  backdrop-filter: blur(18px);
}

.sidebar h2 {
  position: relative;
  color: var(--ui-text);
  font-size: 24px;
  font-weight: 950;
  padding-bottom: 18px;
}

.sidebar h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 88px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ui-primary), var(--ui-blue), var(--ui-amber));
}

.sidebar a {
  margin: 8px 0 !important;
  padding: 12px 13px;
  border-radius: 8px;
  color: #334155 !important;
  font-weight: 800;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.sidebar a:hover {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.10), rgba(37, 99, 235, 0.10));
  color: #0f766e !important;
  transform: translateX(2px);
  box-shadow: inset 4px 0 0 var(--ui-primary);
}

.document-expiry-sidebar {
  display: none;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  background: rgba(255, 251, 235, 0.92);
  color: #78350f;
  font-size: 12px;
  line-height: 1.4;
}

.document-expiry-sidebar strong {
  display: block;
  margin-bottom: 8px;
  color: #92400e;
  font-size: 13px;
}

.document-expiry-item {
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid rgba(245, 158, 11, 0.28);
}

.document-expiry-item:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

.main {
  position: relative;
  z-index: 1;
  padding: 36px !important;
}

.header-row {
  position: relative;
  margin-bottom: 22px !important;
  padding: 26px 28px;
  border: 1px solid rgba(219, 227, 238, 0.78);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(239, 246, 255, 0.93)),
    #fff;
  box-shadow: 0 18px 42px rgba(8, 37, 73, 0.13);
  overflow: hidden;
}

.header-row::after {
  content: "";
  position: absolute;
  right: -64px;
  top: -80px;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.16), transparent 65%);
}

.header {
  font-size: 34px !important;
  font-weight: 950 !important;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  position: relative;
  min-height: 118px;
  padding: 20px;
  border: 1px solid rgba(219, 227, 238, 0.82);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(248, 250, 252, 0.94)),
    #fff;
  box-shadow: 0 16px 38px rgba(8, 37, 73, 0.12);
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--ui-primary), var(--ui-blue));
}

.stat-card span {
  display: block;
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  color: var(--ui-text);
  font-size: 25px;
  font-weight: 950;
}

.stat-card small {
  display: block;
  margin-top: 8px;
  color: var(--ui-muted);
  line-height: 1.4;
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
  gap: 20px !important;
}

.card {
  position: relative;
  min-height: 158px;
  border: 1px solid rgba(219, 227, 238, 0.9);
  border-radius: 8px !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(248, 250, 252, 0.94)),
    #fff !important;
  box-shadow: 0 16px 38px rgba(8, 37, 73, 0.12) !important;
  border-top: 0 !important;
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  right: -38px;
  bottom: -44px;
  width: 130px;
  height: 130px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.10), transparent 68%);
}

.card:nth-child(3n + 1) {
  border-left: 5px solid var(--ui-primary);
}

.card:nth-child(3n + 2) {
  border-left: 5px solid var(--ui-blue);
}

.card:nth-child(3n) {
  border-left: 5px solid var(--ui-amber);
}

.card h3 {
  position: relative;
  font-size: 19px !important;
  color: var(--ui-text);
  z-index: 1;
}

.card p {
  position: relative;
  color: var(--ui-muted) !important;
  line-height: 1.45;
  z-index: 1;
}

.logout-button {
  width: auto !important;
  padding-inline: 16px !important;
}

.grid {
  gap: 18px !important;
}

.summary div,
.history-card {
  border: 1px solid var(--ui-border) !important;
  border-radius: 8px !important;
  box-shadow: var(--ui-shadow-sm);
  background: rgba(255, 255, 255, 0.96) !important;
}

.history-panel {
  border-radius: 8px !important;
}

.ok {
  color: var(--ui-primary-dark) !important;
}

.warn {
  color: #b45309 !important;
}

.bad,
.error {
  color: var(--ui-rose) !important;
}

@media (max-width: 860px) {
  body:not(:has(.container)):not(:has(.login-box)) {
    padding: 18px !important;
  }

  .container {
    display: block !important;
  }

  .sidebar {
    width: 100% !important;
    min-height: auto !important;
    height: auto !important;
  }

  .sidebar a {
    display: inline-block !important;
    margin-right: 6px !important;
  }

  .main {
    padding: 20px !important;
  }

  .header-row {
    align-items: flex-start !important;
    flex-direction: column;
    padding: 22px;
  }

  .form-box {
    padding: 20px !important;
  }
}

@media (max-width: 560px) {
  h2 {
    font-size: 21px;
  }

  button {
    width: 100%;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
