/* GFood Dashboard Styles */

:root {
    --color-primary: #1a3a5c;
    --color-accent: #e8503a;
    --color-bg: #f5f4f0;
    --color-card: #ffffff;
    --color-text: #2c3e50;
    --color-text-muted: #6c757d;
    --color-border: #dee2e6;
    --shadow-card: 0 1px 4px rgba(0,0,0,0.08);
    --font-main: 'Golos Text', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

/* Header */
.header {
    background: var(--color-primary);
    color: white;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.2rem;
}

.logo-icon {
    font-size: 1.5rem;
}

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

.nav-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-link:hover, .nav-link.active {
    color: white;
}

.nav-user {
    color: rgba(255,255,255,0.6);
    font-size: 0.85rem;
}

.nav-logout {
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
}

/* Main */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Cards */
.card {
    background: var(--color-card);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-primary);
}

/* Contract cards */
.contract-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.contract-card {
    background: var(--color-card);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

.contract-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.contract-school {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--color-primary);
}

.contract-number {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.contract-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.stat {
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 500;
}

.contract-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-completed {
    background: #e9ecef;
    color: #6c757d;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-primary);
}

.data-table tr:hover td {
    background: rgba(26, 58, 92, 0.03);
}

.data-table .num {
    font-family: var(--font-mono);
    text-align: right;
}

/* Login page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
}

.login-box {
    background: var(--color-card);
    padding: 48px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    font-size: 1.8rem;
    color: var(--color-primary);
    margin-bottom: 8px;
}

.login-box .subtitle {
    color: var(--color-text-muted);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--color-text);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    width: 100%;
    padding: 14px;
}

.btn-primary:hover {
    background: #152d4a;
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: #e9ecef;
}

/* Report page */
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.report-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-primary);
}

/* Footer */
.footer {
    text-align: center;
    padding: 32px;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .contract-grid {
        grid-template-columns: 1fr;
    }
    
    .contract-stats {
        grid-template-columns: 1fr;
    }
    
    .nav {
        gap: 16px;
    }
    
    .nav-link:not(.nav-logout) {
        display: none;
    }
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 24px;
}

.contract-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.detail-section h3 {
    font-size: 1rem;
    color: var(--color-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

.detail-section h4 {
    font-size: 0.9rem;
    color: var(--color-text);
}

@media (max-width: 768px) {
    .contract-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* ── New dashboard layout ─────────────────────────────── */

/* Summary bar */
.summary-bar {
  background: var(--color-primary);
  color: white;
  padding: 14px 24px;
  margin: -32px -24px 0;
}

.summary-stats {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.summary-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  opacity: 0.65;
}

.summary-value {
  font-size: 1.1rem;
  font-weight: 600;
}

.summary-value.mono {
  font-family: var(--font-mono);
}

.summary-warn .summary-value {
  color: #ffd166;
}

.summary-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.summary-progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  overflow: hidden;
  max-width: 400px;
}

.summary-progress-fill {
  height: 100%;
  background: #4ecdc4;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.summary-progress-label {
  font-size: 0.85rem;
  opacity: 0.8;
  white-space: nowrap;
}

/* Workspace: table + chat */
.workspace {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0;
  height: calc(100vh - 60px - 88px); /* minus header and summary */
  margin: 0 -24px -32px;
  overflow: hidden;
}

/* Sheet panel (table) */
.sheet-panel {
  overflow-y: auto;
  padding: 0;
  border-right: 1px solid var(--color-border);
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.sheet-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.sheet-table th {
  background: #f0eff0;
  color: var(--color-text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-bottom: 2px solid var(--color-border);
  text-align: left;
  white-space: nowrap;
}

.sheet-row {
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.1s;
}

.sheet-row:hover {
  background: rgba(26, 58, 92, 0.04);
}

.sheet-row.row-problem {
  background: #fffbf0;
}

.sheet-row.row-problem:hover {
  background: #fff3d0;
}

.sheet-table td {
  padding: 10px 12px;
  vertical-align: middle;
}

.col-warn { width: 28px; padding: 0 4px 0 12px !important; }
.col-name { min-width: 140px; max-width: 200px; font-weight: 500; color: var(--color-primary); }
.col-num  { width: 160px; }
.col-money { width: 130px; text-align: right !important; }
.col-progress { width: 160px; }

.mono { font-family: var(--font-mono); }

.warn-icon {
  color: #e8503a;
  font-size: 0.9rem;
}

/* Cell progress bar */
.cell-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cell-progress-bar {
  flex: 1;
  height: 5px;
  background: #e9ecef;
  border-radius: 3px;
  overflow: hidden;
}

.cell-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
}

.row-problem .cell-progress-fill {
  background: #e8503a;
}

.cell-progress-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  min-width: 36px;
}

/* Chat panel */
.chat-panel {
  display: flex;
  flex-direction: column;
  background: #f7f8fa;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--color-primary);
  color: white;
  flex-shrink: 0;
}

.chat-avatar {
  font-size: 1.4rem;
  background: rgba(255,255,255,0.15);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.chat-status {
  font-size: 0.75rem;
  opacity: 0.65;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
}

.chat-msg.user {
  align-items: flex-end;
}

.chat-msg.bot {
  align-items: flex-start;
}

.chat-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.45;
}

.chat-msg.bot .chat-bubble {
  background: white;
  color: var(--color-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.chat-msg.user .chat-bubble {
  background: var(--color-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-time {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: white;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
}

.chat-input:focus {
  border-color: var(--color-primary);
}

.chat-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: #152d4a;
}

/* Responsive */
@media (max-width: 768px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    height: auto;
  }
  .sheet-panel {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    max-height: 60vh;
  }
  .chat-panel {
    height: 40vh;
  }
  .summary-bar {
    margin: -32px -24px 0;
  }
}

/* ========== Contracts Page (v2) ========== */

/* Metrics Bar */
.metrics-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.metric-card {
  flex: 1;
  min-width: 140px;
  background: white;
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888780;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1B2E4B;
}

.metric-value.mono {
  font-family: var(--font-mono);
}

.metric-card.metric-danger .metric-value {
  color: #E24B4A;
}

.metric-card.metric-success .metric-value {
  color: #1D9E75;
}

/* Main Layout */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  min-height: calc(100vh - 200px);
}

/* Table Panel */
.table-panel {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}

.contracts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.contracts-table thead {
  background: #f5f4f0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.contracts-table th {
  padding: 12px 10px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888780;
  border-bottom: 2px solid #dee2e6;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.contracts-table th:hover {
  background: #ebe9e4;
}

.th-num { width: 40px; text-align: center; }
.th-name { min-width: 180px; }
.th-money { width: 120px; text-align: right; }
.th-progress { width: 140px; text-align: center; }
.th-detodays { width: 100px; text-align: right; }
.th-status { width: 80px; text-align: center; }

.sort-icon {
  font-size: 0.7rem;
  opacity: 0.5;
  margin-left: 4px;
}

.table-row {
  border-bottom: 1px solid #f5f5f5;
  cursor: pointer;
  transition: background 0.1s;
}

.table-row:hover {
  background: rgba(27, 46, 75, 0.03);
}

.table-row.row-warning {
  background: #fffbf0;
}

.table-row.row-warning:hover {
  background: #fff3d0;
}

.contracts-table td {
  padding: 10px 10px;
  vertical-align: middle;
}

.td-num { text-align: center; }
.td-name { font-weight: 500; color: #1B2E4B; }
.td-money { text-align: right; }
.td-progress { text-align: center; }
.td-detodays { text-align: right; }
.td-status { text-align: center; }

.mono { font-family: var(--font-mono); }
.small { font-size: 0.8rem; }
.text-muted { color: #888780; }

.warn-icon {
  color: #E24B4A;
  margin-right: 4px;
}

/* Progress Bar */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: #e9ecef;
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.progress-fill.progress-danger { background: #E24B4A; }
.progress-fill.progress-warning { background: #EF9F27; }
.progress-fill.progress-success { background: #1D9E75; }

.progress-label {
  font-size: 0.75rem;
  color: #888780;
  min-width: 38px;
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 500;
}

.status-active {
  background: #d4edda;
  color: #155724;
}

.status-completed {
  background: #e9ecef;
  color: #6c757d;
}

/* AI Panel */
.ai-panel {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-header {
  background: #1B2E4B;
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.ai-online {
  width: 8px;
  height: 8px;
  background: #1D9E75;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Insight Blocks */
.insight-block {
  padding: 14px 16px;
  border-bottom: 1px solid #f0eff0;
}

.insight-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888780;
  margin-bottom: 10px;
}

.risks-list,
.insights-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.risk-item {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 0;
}

.risk-critical { color: #E24B4A; }
.risk-warning { color: #EF9F27; }
.risk-ok { color: #1D9E75; }

.risk-link {
  display: block;
  font-size: 0.8rem;
  color: #1B2E4B;
  padding: 4px 0 4px 12px;
  text-decoration: none;
}

.risk-link:hover {
  text-decoration: underline;
}

.insight-item {
  display: flex;
  gap: 8px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #1B2E4B;
}

.insight-icon {
  flex-shrink: 0;
}

/* Chat Section */
.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-section .insight-title {
  padding: 12px 16px 8px;
  margin-bottom: 0;
  border-top: none;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
}

.chat-msg.user { align-items: flex-end; }
.chat-msg.bot { align-items: flex-start; }

.chat-bubble {
  max-width: 90%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.chat-msg.bot .chat-bubble {
  background: #f5f4f0;
  color: #1B2E4B;
  border-bottom-left-radius: 4px;
}

.chat-msg.user .chat-bubble {
  background: #1B2E4B;
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-time {
  font-size: 0.65rem;
  color: #888780;
  margin-top: 2px;
  padding: 0 4px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #f0eff0;
}

.chat-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #dee2e6;
  border-radius: 16px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}

.chat-input:focus {
  border-color: #1B2E4B;
}

.chat-send-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1B2E4B;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-send-btn:hover {
  background: #152540;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-state h2 {
  color: #1B2E4B;
  margin-bottom: 8px;
}

.empty-state p {
  color: #888780;
  margin-bottom: 24px;
}

.error-banner {
  background: #f8d7da;
  color: #721c24;
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 20px;
}

/* Responsive */
@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  
  .ai-panel {
    order: 2;
  }
  
  .table-panel {
    order: 1;
    overflow-x: auto;
  }
  
  .contracts-table {
    min-width: 700px;
  }
}

@media (max-width: 768px) {
  .metrics-bar {
    gap: 12px;
  }
  
  .metric-card {
    min-width: 120px;
    padding: 12px 14px;
  }
  
  .metric-value {
    font-size: 1.1rem;
  }
  
  .table-panel {
    overflow-x: auto;
  }
  
  .contracts-table {
    min-width: 800px;
  }
}
