:root {
  /* Base - Deep Black */
  --color-bg-primary: #0a0a0a;
  --color-bg-secondary: #141414;
  --color-bg-tertiary: #1e1e1e;
  --color-bg-card: #1a1a1a;

  /* Gold Accents */
  --color-gold-primary: #d4af37;
  --color-gold-light: #f4d160;
  --color-gold-dark: #a67c00;
  --color-gold-muted: rgba(212, 175, 55, 0.15);

  /* Text */
  --color-text-primary: #f5f5f5;
  --color-text-secondary: #a0a0a0;
  --color-text-muted: #666666;

  /* Status */
  --color-danger: #dc3545;
  --color-warning: #f4d160;
  --color-success: #28a745;

  /* Effects */
  --shadow-gold: 0 0 20px rgba(212, 175, 55, 0.3);
  --border-gold: 1px solid rgba(212, 175, 55, 0.3);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(212, 175, 55, 0.08), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(212, 175, 55, 0.05), transparent 30%),
    var(--color-bg-primary);
  color: var(--color-text-primary);
  min-height: 100vh;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cpath fill='%23d4af3715' d='M0 0h20v1H0zM0 20h1v20H0zM20 20h20v1H20zM20 0h1v20h-1z'/%3E%3C/svg%3E");
  opacity: 0.4;
  pointer-events: none;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3 {
  font-family: "Playfair Display", "Noto Sans JP", serif;
  letter-spacing: 0.5px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(90deg, rgba(20, 20, 20, 0.95), rgba(10, 10, 10, 0.85));
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  letter-spacing: 1px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: radial-gradient(circle at 30% 30%, var(--color-gold-light), var(--color-gold-dark));
  box-shadow: var(--shadow-gold);
  display: grid;
  place-items: center;
  color: #0a0a0a;
  font-family: "Playfair Display", serif;
}

.top-nav {
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 14px;
}

.top-nav a {
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--color-text-secondary);
  transition: all 0.2s ease;
}

.top-nav a:hover,
.top-nav a.active {
  color: var(--color-text-primary);
  background: var(--color-gold-muted);
  box-shadow: var(--shadow-gold);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 70px);
}

.sidebar {
  padding: 22px 16px;
  background: linear-gradient(180deg, #101010 0%, #0c0c0c 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-link {
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--color-text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.side-link:hover,
.side-link.active {
  color: var(--color-text-primary);
  border-color: rgba(212, 175, 55, 0.4);
  background: rgba(212, 175, 55, 0.06);
  box-shadow: var(--shadow-gold);
}

.content {
  padding: 26px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.01) 0%, transparent 35%),
    var(--color-bg-secondary);
}

.page-title {
  margin: 0 0 14px;
  font-size: 24px;
}

.muted {
  color: var(--color-text-muted);
  font-size: 14px;
}

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

.grid.columns-3 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid.columns-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.card {
  background: var(--color-bg-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  animation: rise 0.35s ease forwards;
}

.card:hover {
  border-color: rgba(212, 175, 55, 0.3);
  box-shadow: var(--shadow-gold);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-gold-light);
  margin: 6px 0 2px;
}

.stat-label {
  color: var(--color-text-secondary);
  font-size: 13px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  color: var(--color-text-primary);
}

.table thead {
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
}

.table th,
.table td {
  padding: 12px 10px;
  text-align: left;
  font-size: 14px;
}

.table tbody tr {
  transition: background 0.2s ease, border 0.2s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.table tbody tr:hover {
  background: rgba(212, 175, 55, 0.06);
}

.warn-row {
  border-left: 3px solid var(--color-danger);
  background: rgba(220, 53, 69, 0.08);
}

.over-row {
  border-left: 3px solid var(--color-warning);
  background: rgba(244, 209, 96, 0.08);
}

.expiry-near {
  position: relative;
}

.expiry-near::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 1px dashed var(--color-warning);
  border-radius: 4px;
}

.expiry-expired {
  position: relative;
}

.expiry-expired::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 1px dashed var(--color-danger);
  border-radius: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
  letter-spacing: 0.2px;
}

.btn:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: var(--shadow-gold);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(120deg, var(--color-gold-light), var(--color-gold-dark));
  color: #0a0a0a;
}

.btn-secondary {
  background: transparent;
  color: var(--color-gold-light);
  border: 1px solid rgba(212, 175, 55, 0.5);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.input,
.select {
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  font-size: 14px;
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select:focus {
  border-color: rgba(212, 175, 55, 0.8);
  box-shadow: var(--shadow-gold);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.2);
  color: var(--color-gold-light);
  font-weight: 600;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--color-bg-card);
  border: var(--border-gold);
  color: var(--color-text-primary);
  min-width: 240px;
  box-shadow: var(--shadow-gold);
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.toast.danger {
  border-color: rgba(220, 53, 69, 0.6);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  z-index: 20;
  animation: fade 0.2s ease;
}

.modal {
  background: var(--color-bg-card);
  border: var(--border-gold);
  border-radius: 14px;
  padding: 18px;
  width: min(480px, 92vw);
  box-shadow: var(--shadow-gold);
  animation: pop 0.2s ease;
}

.badge {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  color: #0a0a0a;
  font-weight: 700;
}

.badge.success {
  background: var(--color-success);
}

.badge.warning {
  background: var(--color-warning);
}

.badge.danger {
  background: var(--color-danger);
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-secondary);
  font-size: 12px;
}

.table-actions {
  display: flex;
  gap: 8px;
}

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

.justify-between {
  justify-content: space-between;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.auth-page .layout {
  display: block;
}

.auth-page .sidebar,
.auth-page .top-nav,
.auth-page #logout-btn,
.auth-page .pill {
  display: none;
}

.auth-page .top-bar {
  justify-content: center;
}

.auth-page .content {
  padding: 0 18px 60px;
}

.auth-card {
  max-width: 420px;
  margin: 80px auto;
  padding: 28px;
  text-align: center;
  border: var(--border-gold);
}

.subtle {
  color: var(--color-text-secondary);
  font-size: 13px;
}

.empty {
  padding: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  text-align: center;
  color: var(--color-text-secondary);
}

.pulse-danger {
  position: relative;
}

.pulse-danger::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 12px;
  border: 1px solid rgba(220, 53, 69, 0.5);
  animation: pulse 1.4s ease infinite;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pop {
  from {
    transform: scale(0.95);
  }
  to {
    transform: scale(1);
  }
}

@keyframes pulse {
  0% {
    opacity: 0.8;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.1);
  }
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 70px;
    z-index: 5;
  }

  .top-bar {
    flex-wrap: wrap;
    gap: 10px;
  }
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .top-nav {
    width: 100%;
    justify-content: space-between;
  }
}
