:root {
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-border: #e3e7f0;
  --color-text: #1f2433;
  --color-text-muted: #6b7280;
  --color-primary: #4f46e5;
  --color-primary-dark: #4338ca;
  --color-primary-light: #eef0fb;
  --color-danger: #dc2626;
  --color-danger-dark: #b91c1c;
  --color-success-bg: #ecfdf5;
  --color-success-text: #047857;
  --color-error-bg: #fef2f2;
  --color-error-text: #b91c1c;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 12px 28px -4px rgba(79, 70, 229, 0.15);
  --navbar-height: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; margin: 0 0 1.25rem; }
h2 { font-size: 1.15rem; margin: 0 0 1rem; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

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

/* ---------------------------------------------------------- Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, var(--color-primary), #6d28d9);
  box-shadow: var(--shadow);
}

.navbar-inner {
  max-width: 960px;
  margin: 0 auto;
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.25rem;
}

.navbar-brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
}
.navbar-brand:hover { text-decoration: none; opacity: 0.9; }

.navbar-toggle {
  display: none;
  margin-left: auto;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.navbar-nav a {
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
  padding: 0.4rem 0;
  border-bottom: 2px solid transparent;
}
.navbar-nav a:hover { color: #fff; text-decoration: none; }
.navbar-nav a.active { color: #fff; border-bottom-color: #fff; }

.navbar-user {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.navbar-logout {
  background: rgba(255, 255, 255, 0.15);
  padding: 0.35rem 0.85rem !important;
  border-radius: 999px;
  border-bottom: none !important;
}
.navbar-logout:hover { background: rgba(255, 255, 255, 0.28); }

/* ---------------------------------------------------------- Portal Cards */
.portal-header {
  margin-bottom: 2rem;
}
.portal-welcome h1 {
  margin-bottom: 0.4rem;
  font-size: 1.75rem;
}
.portal-welcome p {
  margin: 0;
  font-size: 0.95rem;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.portal-card {
  display: flex;
  align-items: flex-start;
  gap: 1.1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  color: var(--color-text);
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.portal-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: #cbd5e1;
  text-decoration: none;
}
.portal-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--color-primary);
  opacity: 0;
  transition: opacity 0.2s;
}
.portal-card:hover::after {
  opacity: 1;
}

.portal-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border-radius: 10px;
  border: 1px solid var(--color-border);
  transition: transform 0.2s;
}
.portal-card:hover .portal-icon {
  transform: scale(1.08);
}

.portal-content {
  flex: 1;
  min-width: 0;
}

.portal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.portal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: var(--color-text);
}

.portal-external-icon {
  font-size: 1rem;
  color: var(--color-text-muted);
  transition: transform 0.2s, color 0.2s;
}
.portal-card:hover .portal-external-icon {
  transform: translate(2px, -2px);
  color: var(--color-primary);
}

.portal-url {
  font-size: 0.78rem;
  color: var(--color-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  margin-bottom: 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-desc {
  font-size: 0.86rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.45;
}

/* ---------------------------------------------------------- Standard Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* ---------------------------------------------------------- Forms */
.form-group { margin-bottom: 1rem; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  align-items: end;
}
.form-group-checkbox { display: flex; align-items: center; padding-bottom: 0.6rem; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}
.form-group-checkbox label { display: flex; align-items: center; gap: 0.4rem; font-weight: 500; }

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fbfcfe;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ---------------------------------------------------------- Buttons */
.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.82rem; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); text-decoration: none; color: #fff; }

.btn-secondary { background: #eef0fb; color: var(--color-primary-dark); }
.btn-secondary:hover { background: #e0e3fa; text-decoration: none; }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: var(--color-danger-dark); text-decoration: none; color: #fff; }

.btn-outline-danger {
  background: transparent;
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}
.btn-outline-danger:hover { background: var(--color-error-bg); text-decoration: none; }

/* ---------------------------------------------------------- Alerts */
.alert {
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
}
.alert-success { background: var(--color-success-bg); color: var(--color-success-text); }
.alert-error { background: var(--color-error-bg); color: var(--color-error-text); }

/* ---------------------------------------------------------- Auth page */
.auth-page {
  min-height: calc(100vh - var(--navbar-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.auth-title { text-align: center; margin-bottom: 1.5rem; }

/* ---------------------------------------------------------- Tables */
.info-table { width: 100%; border-collapse: collapse; }
.info-table th, .info-table td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.92rem;
}
.info-table th { color: var(--color-text-muted); width: 40%; font-weight: 600; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}
.data-table th { color: var(--color-text-muted); font-weight: 600; }
.data-table tbody tr:hover { background: #fafbff; }

/* ---------------------------------------------------------- Badges */
.badge {
  display: inline-block;
  background: #eef0fb;
  color: var(--color-primary-dark);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  vertical-align: middle;
}
.badge-current { background: var(--color-success-bg); color: var(--color-success-text); }

/* ---------------------------------------------------------- Sessions */
.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.page-header h1 { margin: 0; }

.session-list { display: flex; flex-direction: column; gap: 0.9rem; }

.session-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
}
.session-card-current { border-color: #a7f3d0; background: #f7fffb; }

.session-title { font-weight: 700; margin-bottom: 0.4rem; }

.session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

/* ---------------------------------------------------------- Responsive */
@media (max-width: 720px) {
  .navbar-toggle { display: block; }
  .navbar-nav {
    display: none;
    position: absolute;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    background: var(--color-primary-dark);
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1.25rem 1.5rem;
    gap: 0.85rem;
  }
  .navbar-nav.open { display: flex; }
  .navbar-user { border-left: none; padding-left: 0; }
  .session-card { flex-direction: column; align-items: flex-start; }
}
