* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #D14747;
  --green-dark: #8B1E1E;
  --gray-text: #595959;
  --dark: #1f1f1f;
  --error: #D14747;
  --success: #D14747;
}

html, body { 
  height: 100%; 
  font-family: 'Segoe UI', -apple-system, sans-serif; 
  color: var(--dark);
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.excel-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #ffffff;
  display: none;
  flex-direction: column;
}

.excel-bg.visible {
  display: flex;
}

.excel-ribbon {
  background: #FFFFFF;
  border-bottom: 1px solid #d0d0d0;
  padding: 0;
}

.ribbon-menu {
  display: flex;
  gap: 2px;
  background: white;
  padding: 4px 8px;
  border-bottom: 1px solid #ddd;
}

.menu-item {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #FFFFFF;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s;
}

.menu-item:hover {
  background: #e8e8e8;
}

.menu-item.active {
  background: white;
  color: var(--green);
  border: 1px solid #d0d0d0;
  border-bottom: 2px solid var(--green);
}

.ribbon-toolbar {
  display: flex;
  gap: 12px;
  padding: 6px 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0 8px;
  border-right: 1px solid #ddd;
}

.toolbar-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 1px solid #ddd;
  border-radius: 2px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: #666;
}

.toolbar-btn:hover {
  background: #f0f0f0;
  border-color: #bbb;
}

.toolbar-label {
  font-size: 10px;
  color: #999;
  white-space: nowrap;
}

.formula-bar-section {
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid #ddd;
  background: white;
  align-items: center;
}

.cell-ref {
  padding: 4px 8px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 2px;
  font-size: 11px;
  width: 70px;
  color: #333;
}

.formula-input {
  flex: 1;
  padding: 4px 8px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 2px;
  font-size: 11px;
  color: #333;
}

.excel-tabs {
  display: flex;
  gap: 2px;
  background: #f5f5f5;
  padding: 0 8px 2px 8px;
  border-top: 1px solid #ddd;
  height: 28px;
  align-items: flex-end;
  margin-top: auto;
}

.excel-tab {
  padding: 4px 12px;
  background: #FFFFFF;
  border: 1px solid #ccc;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  font-size: 11px;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
}

.excel-tab.active {
  background: white;
  color: var(--green);
  font-weight: 600;
  border-color: #ddd;
}

.excel-wrapper {
  position: relative;
  flex: 1;
  filter: blur(3px);
  opacity: 0.9;
  overflow: hidden;
}

.excel-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #fff;
  padding: 20px;
  overflow: auto;
  font-family: 'Calibri', Arial, sans-serif;
  font-size: 11px;
}

.excel-table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 20px;
}

.excel-table td {
  border: 1px solid #d0d0d0;
  padding: 10px;
  height: auto;
  vertical-align: middle;
}

.excel-table th {
  border: 1px solid #d0d0d0;
  padding: 10px;
  height: 32px;
  background: #d9d9d9;
  font-weight: bold;
  color: #000;
}

.excel-table .header-row {
  background: #d9d9d9;
  font-weight: bold;
}

.excel-table .data-row {
  background: #fff;
  min-height: 200px;
}

.excel-table .total-row {
  background: #f2f2f2;
  font-weight: bold;
}

.excel-table .amount {
  text-align: right;
}

.excel-table td {
  word-wrap: break-word;
  word-break: break-word;
  line-height: 1.4;
}

.excel-image-cell {
  width: 120px;
  height: 120px;
  padding: 5px;
}

.excel-image-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid #999;
  filter: blur(14px);
}

.excel-row {
  display: flex;
  width: 100%;
}

.excel-cell {
  display: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: linear-gradient(135deg, rgba(209,71,71,0.25) 0%, rgba(139,30,30,0.35) 100%);
  pointer-events: none;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: #fff;
  pointer-events: none;
}

.boot-splash {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  background: linear-gradient(135deg, #D14747 0%, #8B1E1E 100%);
  padding: 48px 120px;
  border-radius: 8px;
  pointer-events: all;
  box-shadow: 0 20px 60px rgba(209,71,71,0.4);
}

.excel-title {
  font-size: 56px;
  font-weight: 300;
  letter-spacing: 6px;
  color: #FFFFFF;
  margin: 0;
  animation: fadeInDown 0.6s ease-out;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.dot-loader {
  display: flex;
  justify-content: center;
  gap: 12px;
  height: 10px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(209,71,71,0.8);
  animation: dotFlow 1.8s infinite;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.3s; }
.dot:nth-child(3) { animation-delay: 0.6s; }
.dot:nth-child(4) { animation-delay: 0.9s; }

@keyframes dotFlow {
  0%, 50%, 100% {
    opacity: 0.3;
    transform: translateX(0);
  }
  25% {
    opacity: 1;
    transform: translateX(10px);
  }
}

.boot-status {
  font-size: 13px;
  color: rgba(255, 255, 255, 1);
  letter-spacing: 1px;
  animation: fadeInUp 0.8s ease-out 0.3s both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-wrapper {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-wrapper.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 20px 40px rgba(209,71,71,0.1);
  overflow: hidden;
  position: relative;
  z-index: 51;
}

.auth-header {
  padding: 32px 28px 22px;
  text-align: center;
  background: linear-gradient(to bottom, rgba(209,71,71,0.02), transparent);
}

.auth-logo {
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, #D14747 0%, #8B1E1E 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  box-shadow: 0 8px 16px rgba(209,71,71,0.18);
}

.auth-logo svg { 
  width: 32px; 
  height: 32px; 
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.auth-subtitle {
  font-size: 12px;
  color: #999;
  line-height: 1.5;
  font-weight: 400;
}

.auth-body {
  padding: 24px 28px 28px;
}

.doc-info {
  background: linear-gradient(135deg, rgba(209,71,71,0.06), rgba(139,30,30,0.04));
  border: 1px solid rgba(209,71,71,0.12);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.doc-icon {
  width: 38px;
  height: 44px;
  background: linear-gradient(135deg, var(--green) 0%, #8B1E1E 100%);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(209,71,71,0.12);
}

.doc-icon svg { 
  width: 22px; 
  height: 26px; 
}

.doc-meta {
  flex: 1;
  min-width: 0;
}

.doc-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 1px;
  letter-spacing: 0.2px;
}

.doc-type {
  font-size: 10px;
  color: #999;
  font-weight: 500;
}

.doc-description {
  display: none;
}

.doc-lock {
  width: 28px;
  height: 28px;
  background: rgba(209,71,71,0.08);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.doc-lock svg { 
  width: 14px; 
  height: 14px; 
}

.form-panel { display: none; }
.form-panel.active { display: block; }

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 7px;
  letter-spacing: 0.2px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--dark);
  background: #fff;
  transition: all 0.3s ease;
}

.form-input::placeholder { 
  color: #ccc; 
  font-weight: 400;
}

.form-input:focus { 
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(209,71,71,0.06);
  background: #fff;
}

.form-input.error { 
  border-color: var(--error);
  background: rgba(209,71,71,0.01);
}

.form-input.error:focus { box-shadow: 0 0 0 4px rgba(209,71,71,0.06); }

.form-error {
  font-size: 11px;
  color: var(--error);
  margin-top: 4px;
  display: none;
  font-weight: 600;
}

.form-error.visible { display: block; }

.form-btn {
  width: 100%;
  padding: 11px 14px;
  background: linear-gradient(135deg, var(--green) 0%, #8B1E1E 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 10px rgba(209,71,71,0.18);
  letter-spacing: 0.2px;
}

.form-btn:hover:not(:disabled) { 
  background: linear-gradient(135deg, #8B1E1E 0%, #5A0E0E 100%);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(209,71,71,0.24);
}

.form-btn:active:not(:disabled) { transform: translateY(0); }

.form-btn:disabled { opacity: 0.65; cursor: not-allowed; }

.form-btn.loading::after {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.form-alert {
  background: rgba(209,71,71,0.08);
  border-left: 3px solid var(--error);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: #721c24;
  margin-bottom: 16px;
  display: none;
  font-weight: 600;
}

.form-alert.visible { display: block; animation: slideIn 0.3s ease; }

@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.form-switch {
  text-align: center;
  font-size: 12px;
  color: #999;
  margin-top: 16px;
  letter-spacing: 0.2px;
}

.form-switch a {
  color: var(--green);
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.form-switch a:hover { color: #8B1E1E; }

.form-checkbox {
  display: flex;
  gap: 10px;
  margin: 16px 0;
  cursor: pointer;
  user-select: none;
}

.checkbox-box {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 1px solid #ddd;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  background: #fff;
}

.checkbox-box.checked {
  background: linear-gradient(135deg, var(--green) 0%, #8B1E1E 100%);
  border-color: var(--green);
  box-shadow: 0 2px 6px rgba(209,71,71,0.16);
}

.checkbox-box.checked::after {
  content: '✓';
  color: white;
  font-weight: 700;
  font-size: 10px;
}

.checkbox-label {
  font-size: 12px;
  color: #666;
  line-height: 1.5;
}

.checkbox-label a {
  color: var(--green);
  text-decoration: none;
  font-weight: 700;
  transition: all 0.2s;
}

.checkbox-label a:hover { color: #8B1E1E; }

.checkbox-error {
  font-size: 11px;
  color: var(--error);
  margin-top: 6px;
  display: none;
  font-weight: 600;
}

.checkbox-error.visible { display: block; }

.strength-bars {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.strength-bar {
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: #e5e5e5;
  transition: all 0.3s ease;
}

.strength-text {
  font-size: 11px;
  color: #999;
  text-align: right;
  margin-top: 4px;
  font-weight: 600;
}

.success-box {
  text-align: center;
  padding: 20px 0;
}

.success-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, rgba(209,71,71,0.12), rgba(139,30,30,0.06));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  border: 2px solid rgba(209,71,71,0.15);
}

.success-icon svg { width: 30px; height: 30px; }

.success-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.success-msg {
  font-size: 13px;
  color: #999;
  line-height: 1.5;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 600px) {
  .auth-card { max-width: 95%; }
  .auth-header { padding: 24px 20px 16px; }
  .auth-body { padding: 16px 20px 24px; }
  .auth-title { font-size: 20px; }
  .excel-title { font-size: 72px; }
}