:root {
  --color-primary: #1a365d;
  --color-primary-light: #2c5282;
  --color-accent: #3182ce;
  --color-accent-hover: #2b6cb0;
  --color-bg: #f0f4f8;
  --color-surface: #ffffff;
  --color-border: #cbd5e0;
  --color-text: #2d3748;
  --color-text-muted: #718096;
  --color-header-bg: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --max-width: 1100px;
  --font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px 32px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header */
.site-header {
  margin-bottom: 24px;
}

.banner img {
  width: 100%;
  border-radius: var(--radius) var(--radius) 0 0;
}

.institution-nav {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  background: var(--color-header-bg);
  padding: 8px;
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius) var(--radius);
}

.institution-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  text-align: center;
  text-decoration: none;
  background: linear-gradient(
    180deg,
    #4a8fd4 0%,
    #5aa3e8 35%,
    #5aa3e8 65%,
    #3d7fc8 100%
  );
  border: 1px solid #2e6db5;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: filter 0.15s, box-shadow 0.15s;
}

.institution-btn:hover {
  filter: brightness(1.12);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.45), 0 2px 5px rgba(0, 0, 0, 0.35);
  text-decoration: none;
  color: #fff;
}

/* Main layout */
.main-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-items: start;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--color-accent);
}

.section-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-source {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.section-source a {
  font-weight: 600;
}

/* News section */
.news-section,
.quick-menu-section,
.market-section,
.search-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.news-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.news-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fafbfc;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.news-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
}

.news-card-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 4px;
}

.news-card-body {
  min-width: 0;
}

.news-card-title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
}

.news-card-title a {
  color: var(--color-primary);
  text-decoration: none;
}

.news-card-title a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.news-card-excerpt {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-card-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.loading,
.error-message {
  text-align: center;
  color: var(--color-text-muted);
  padding: 24px;
  font-style: italic;
}

.error-message {
  color: #c53030;
}

/* Buttons */
.btn-primary,
.btn-secondary {
  display: inline-block;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

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

.btn-primary:hover {
  background: var(--color-accent-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  margin-top: 16px;
  width: 100%;
}

.btn-secondary:hover {
  background: var(--color-accent);
  color: #fff;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.luca-btn {
  display: block;
  margin-bottom: 16px;
  padding: 11px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, #f06b96 0%, #f06b96 48%, #d4145a 52%, #c91356 100%);
  border: 1px solid #a81048;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.28);
  text-align: center;
  text-decoration: none;
  transition: filter 0.15s, box-shadow 0.15s;
}

.luca-btn:hover {
  filter: brightness(1.06);
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.32);
  text-decoration: none;
  color: #fff;
}

.quick-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-category {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.menu-category summary {
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-primary);
  background: #e8f4fc;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s;
}

.menu-category summary::-webkit-details-marker {
  display: none;
}

.menu-category summary::after {
  content: '+';
  float: right;
  font-weight: 700;
  color: var(--color-accent);
}

.menu-category[open] summary::after {
  content: '−';
}

.menu-category summary:hover {
  background: #d6ebfa;
}

.menu-links {
  margin: 0;
  padding: 8px 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  background: #fafbfc;
}

.menu-links li a {
  display: block;
  padding: 5px 14px;
  font-size: 0.8rem;
  color: var(--color-text);
  text-decoration: none;
}

.menu-links li a:hover {
  background: #edf2f7;
  color: var(--color-accent);
  text-decoration: none;
}

/* Market */
.market-frame {
  background: #fafbfc;
  border-radius: var(--radius);
  padding: 12px;
  min-height: auto;
}

.market-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.market-table th,
.market-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.market-table thead th {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #edf2f7;
}

.market-table thead th:nth-child(2),
.market-table thead th:nth-child(3) {
  text-align: right;
}

.market-table tbody tr:nth-child(even) {
  background: #f7fafc;
}

.market-table tbody th {
  font-weight: 700;
  color: var(--color-primary);
  width: 35%;
}

.market-table tbody td {
  font-weight: 600;
  color: var(--color-text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.market-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.market-source {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-align: center;
}

.market-error {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 16px;
  font-style: italic;
}

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

.news-page-info {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.news-page-btn {
  width: auto;
  min-width: 100px;
  margin-top: 0;
}

.news-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Search */
.search-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-form input[type='search'] {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
}

.search-form input[type='search']:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.15);
}

/* Footer */
.site-footer {
  margin-top: 32px;
  padding: 28px 20px;
  background: var(--color-primary);
  color: #fff;
  text-align: center;
  border-radius: var(--radius);
}

.site-footer p {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.site-footer a {
  color: #bee3f8;
}

.site-footer a:hover {
  color: #fff;
}

/* Responsive */
@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }

  .news-section {
    order: 1;
  }

  .institution-nav {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .page {
    padding: 0 12px 24px;
  }

  .institution-nav {
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    padding: 6px;
  }

  .institution-btn {
    min-height: 36px;
    font-size: 0.68rem;
    padding: 8px 6px;
  }

  .news-card {
    grid-template-columns: 1fr;
  }

  .news-card-icon {
    width: 40px;
    height: 40px;
  }

  .news-section,
  .quick-menu-section,
  .market-section,
  .search-section {
    padding: 16px;
  }
}
