:root {
  --excel-green: #0f7f3a;
  --grid-line: #d9d9d9;
  --panel-line: #cfcfcf;
  --sheet-bg: #ffffff;
  --ribbon-bg: #f3f3f3;
  --text: #1f2933;
  --muted: #5f6b76;
  --blue: #5b9bd5;
  --green: #a9d18e;
  --orange: #f4b183;
  --red: #ff6f79;
  --gold: #ffd966;
  --cyan: #9dc3e6;
  --gray: #d9e2ea;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: #111;
  font-size: 13px;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid #b8c6d5;
  background: linear-gradient(#ffffff, #edf4fb);
  color: #17456d;
  min-height: 28px;
  padding: 4px 10px;
  line-height: 1.15;
  cursor: pointer;
}

button:hover {
  background: #dceefa;
}

button:active {
  transform: translateY(1px);
}

input,
select {
  border: 1px solid #aebdcc;
  background: #fff;
  min-height: 28px;
  min-width: 0;
  width: 100%;
  padding: 4px 6px;
}

a {
  color: #1f4e79;
}

.app-shell {
  min-height: 100vh;
  background: #f8f8f8;
  display: flex;
  flex-direction: column;
}

.excel-topbar {
  background: var(--ribbon-bg);
  border-bottom: 1px solid var(--panel-line);
}

.title-strip {
  min-height: 32px;
  background: #f7f7f7;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid #d4d4d4;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 10px;
  min-width: 260px;
  border-right: 1px solid #d4d4d4;
  background: #fff;
}

.brand-logo {
  width: 26px;
  height: 24px;
  border: 1px solid var(--excel-green);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 2px;
  padding: 3px;
  background: #f7fff9;
}

.brand-logo i {
  display: block;
  background: var(--excel-green);
}

.brand-logo i:nth-child(1) {
  height: 8px;
}

.brand-logo i:nth-child(2) {
  height: 14px;
}

.brand-logo i:nth-child(3) {
  height: 18px;
  background: #2f9de0;
}

.brand-text {
  font-size: 12px;
  font-weight: 700;
  color: #17324d;
  white-space: nowrap;
}

.file-tab {
  width: 48px;
  min-height: 32px;
  color: #fff;
  background: var(--excel-green);
  border: 0;
  text-transform: uppercase;
  font-weight: 700;
}

.file-tab.is-active {
  background: linear-gradient(#1fa95a, #0f7f3a);
  box-shadow:
    inset 0 -3px 0 #b8f2cb,
    0 0 0 1px rgba(15, 127, 58, .18),
    0 0 14px rgba(76, 222, 128, .42);
}

.menu-tabs {
  display: flex;
  gap: 2px;
  align-items: stretch;
  overflow-x: auto;
}

.menu-tabs button {
  border: 0;
  background: transparent;
  color: #111827;
  padding: 0 14px;
  min-height: 28px;
  text-transform: uppercase;
  font-size: 11px;
}

.menu-tabs button:hover {
  background: #e2e8f0;
}

.menu-tabs button.is-active {
  background: linear-gradient(#f5fff7, #dff6e7);
  box-shadow:
    inset 0 -3px 0 #39b86d,
    0 0 0 1px rgba(15, 127, 58, .14),
    0 0 14px rgba(76, 222, 128, .34);
  color: #0d5d2d;
  font-weight: 700;
}

.menu-tabs button:focus-visible,
.file-tab:focus-visible {
  outline: 2px solid #2f9de0;
  outline-offset: -2px;
}

.user-name {
  margin-left: auto;
  padding: 5px 18px 0 18px;
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
}

.ribbon {
  display: grid;
  grid-template-columns: minmax(220px, .75fr) minmax(420px, 2fr) minmax(210px, .75fr);
  gap: 10px;
  padding: 8px;
  min-height: 104px;
  align-items: stretch;
}

.ribbon-group {
  border: 1px solid #d3d7dc;
  background: #f8f8f8;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.ribbon-group > label {
  color: #52606d;
  font-size: 12px;
}

.ribbon-group > span {
  margin-top: auto;
  text-align: center;
  color: #64748b;
  font-size: 11px;
}

.inline-controls,
.currency-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  min-width: 0;
}

.selected-currencies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 31px;
  align-items: center;
}

.currency-chip {
  display: inline-grid;
  grid-template-columns: auto 18px;
  align-items: center;
  gap: 4px;
  border: 1px solid #b8c6d5;
  background: #fff;
  color: #17324d;
  padding: 3px 4px 3px 8px;
  min-height: 26px;
}

.currency-chip button {
  min-height: 18px;
  width: 18px;
  padding: 0;
  border: 0;
  background: #eef4fa;
  color: #475569;
}

.source-box {
  display: grid;
  gap: 5px;
}

.source-box strong {
  color: #1f4e79;
}

.formula-row {
  display: grid;
  grid-template-columns: 90px 34px 1fr;
  align-items: center;
  height: 26px;
  border-top: 1px solid #e4e7eb;
  background: #fbfbfb;
}

.name-box,
.fx,
.formula-box {
  height: 100%;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--panel-line);
  padding: 0 8px;
}

.fx {
  justify-content: center;
  font-style: italic;
  color: #1f4e79;
}

.formula-box {
  color: #425466;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(580px, 1fr) minmax(330px, 36vw);
  gap: 8px;
  padding: 0 8px 8px;
}

.sheet-area,
.dashboard {
  background-color: var(--sheet-bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 24px;
  border: 1px solid var(--panel-line);
  min-height: 480px;
}

.sheet-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 6px;
}

.note-title {
  margin: 0 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  font-style: italic;
  color: #111827;
}

.note-text {
  margin: 0;
  color: #1f4e79;
}

.status-ready {
  color: #fff;
  background: var(--excel-green);
  padding: 4px 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

.rate-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  padding: 12px 16px 18px;
}

.rate-card,
.converter-panel,
.result-card,
.info-panel {
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--panel-line);
}

.rate-card {
  min-height: 146px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.rate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--grid-line);
  background: #f6f8fa;
}

.rate-code {
  font-size: 18px;
  font-weight: 700;
  color: #17324d;
}

.rate-nominal {
  color: #64748b;
  font-size: 11px;
}

.rate-value {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 14px 10px;
}

.rate-value strong {
  font-size: 27px;
  color: #1f4e79;
  line-height: 1.1;
}

.rate-value span {
  color: var(--muted);
}

.rate-foot {
  padding: 8px 10px;
  border-top: 1px solid var(--grid-line);
  color: #425466;
  min-height: 34px;
}

.rate-change {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  font-size: 12px;
  font-weight: 700;
}

.rate-change.up {
  color: #0b6b2b;
}

.rate-change.down {
  color: #ff1f3d;
}

.rate-change.flat {
  color: #64748b;
}

.rate-arrow {
  font-size: 18px;
  line-height: 1;
}

.dashboard {
  padding: 14px;
  overflow: auto;
}

.dashboard h1 {
  margin: 0 0 14px;
  text-align: center;
  font-size: 18px;
}

.dashboard h2 {
  margin: 0 0 10px;
  font-size: 14px;
  text-align: center;
}

.converter-panel {
  padding: 12px;
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.converter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.converter-grid label,
.converter-panel > label {
  color: #52606d;
  display: grid;
  gap: 5px;
}

.primary-action {
  color: #fff;
  background: #2f9de0;
  border-color: #1977af;
}

.primary-action:hover {
  background: #238ed0;
}

.result-card {
  min-height: 132px;
  display: grid;
  align-content: center;
  gap: 8px;
  text-align: center;
  padding: 16px;
  margin-bottom: 14px;
}

.result-card span {
  color: var(--muted);
}

.result-card strong {
  font-size: 28px;
  color: var(--excel-green);
}

.result-card p,
.info-panel p {
  margin: 0;
  color: #425466;
}

.info-panel {
  padding: 12px;
}

.result-glow,
.result-glow-fill,
.rate-card.result-glow-card {
  box-shadow:
    0 0 0 2px rgba(57, 184, 109, .28),
    0 0 18px rgba(76, 222, 128, .34);
  outline: 1px solid rgba(57, 184, 109, .28);
  outline-offset: -1px;
}

.result-glow-fill,
.rate-card.result-glow-card {
  background:
    linear-gradient(rgba(245, 255, 247, .94), rgba(223, 246, 231, .94)),
    rgba(255, 255, 255, .92);
}

.rate-card.result-glow-card .rate-head {
  background: #edf9f1;
}

@media print {
  .excel-topbar,
  .converter-panel button,
  .currency-chip button {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .workspace {
    display: block;
  }

  .sheet-area,
  .dashboard {
    min-height: 0;
    page-break-inside: avoid;
  }
}

.empty-state,
.error-state {
  grid-column: 1 / -1;
  padding: 18px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--panel-line);
  color: #425466;
}

.error-state {
  border-color: #f0a6a6;
  color: #7f1d1d;
  background: #fff6f6;
}

@media (max-width: 980px) {
  .ribbon,
  .workspace {
    grid-template-columns: 1fr;
  }

  .brand-mark {
    min-width: 210px;
  }

  .rate-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 620px) {
  .title-strip {
    flex-wrap: wrap;
  }

  .brand-mark {
    width: 100%;
  }

  .user-name {
    margin-left: 0;
  }

  .rate-grid,
  .converter-grid {
    grid-template-columns: 1fr;
  }

  .sheet-toolbar {
    flex-direction: column;
  }
}
