:root {
  --surface: #f8f9fa;
  --surface-strong: #ffffff;
  --surface-soft: #eef2f7;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #128c7e;
  --primary-strong: #075b53;
  --accent: #25d366;
  --danger: #ef4444;
  --card-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #eef2f7 0%, #f8fafc 100%);
  color: var(--text);
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 1rem;
  padding: 1rem;
  max-width: 1680px;
  margin: 0 auto;
}

.sidebar, .history-panel {
  background: var(--surface-strong);
  border-radius: 28px;
  box-shadow: var(--card-shadow);
  padding: 1.2rem;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.brand-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 1.2rem;
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 6px 18px rgba(15,23,42,0.12);
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
}

.brand p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.menu {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.menu-item {
  border: none;
  background: #f2faf8;
  color: var(--primary-strong);
  padding: 0.95rem 1rem;
  border-radius: 18px;
  text-align: left;
  font-weight: 600;
  transition: transform 0.2s ease, background 0.2s ease;
}

.menu-item:hover,
.menu-item.active {
  background: #d7f4ef;
  transform: translateX(4px);
}

.sidebar-footer {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.profile-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 1rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
  margin-bottom: 1rem;
}

.profile-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.9rem;
}

.login-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

.graph-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  margin: 1rem 0;
}

.graph-grid input,
.graph-grid button {
  border-radius: 18px;
}

.graph-grid button {
  grid-column: span 3;
  background: var(--primary);
  color: white;
  border: none;
}

#graphCanvas {
  border-radius: 24px;
  width: 100%;
  max-width: 100%;
  display: block;
  margin-top: 1rem;
  background: white;
}

.favorites-panel {
  margin-top: 1rem;
}

.favorites-panel .history-header {
  margin-bottom: 0.75rem;
}

.byte-size {
  font-size: 0.9rem;
  color: var(--muted);
}

.ghost {
  border: 1px solid #d1d5db;
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 0.8rem 1rem;
}

.panel {
  background: var(--surface-strong);
  border-radius: 28px;
  box-shadow: var(--card-shadow);
  padding: 1.4rem;
  display: none;
}

.panel.active {
  display: block;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.panel-header h2 {
  margin: 0;
}

.panel-header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.pill {
  border: none;
  background: var(--primary);
  border-radius: 999px;
  color: white;
  padding: 0.75rem 1rem;
  font-weight: 600;
}

.display {
  background: #f3faf8;
  border-radius: 28px;
  min-height: 120px;
  display: grid;
  place-items: end center;
  padding: 1.2rem 1.5rem;
  margin: 1.2rem 0;
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  color: var(--primary-strong);
  overflow-wrap: anywhere;
}

.keypad {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.keypad button {
  border: none;
  border-radius: 18px;
  padding: 1rem;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  color: var(--text);
  font-size: 1rem;
  transition: transform 0.15s ease, background 0.15s ease;
}

.keypad button:hover {
  transform: translateY(-2px);
}

.keypad button[data-action="equals"] {
  background: var(--primary);
  color: white;
  grid-column: span 1;
}

.keypad button[data-action="clear"],
.keypad button[data-action="delete"] {
  background: #fee2e2;
  color: var(--danger);
}

.span-two {
  grid-column: span 2;
}

.percent-grid,
.converter-grid,
.financial-grid,
.graph-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 1rem 0;
}

.financial-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.percent-grid label,
.converter-grid label,
.financial-grid label,
.graph-grid label,
.full-width {
  display: grid;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--text);
}

.percent-grid input,
.converter-grid input,
.converter-grid select,
.financial-grid input,
.graph-grid input,
.stats-buttons textarea,
.full-width textarea,
.card input,
.card textarea,
.login-row input {
  border: 1px solid #d1d5db;
  border-radius: 18px;
  padding: 0.95rem 1rem;
  background: var(--surface-soft);
  color: var(--text);
}

.card {
  background: #ffffff;
  border-radius: 28px;
  padding: 1.2rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.card h3 {
  margin: 0 0 1rem;
  color: var(--primary-strong);
}

.full-width {
  grid-column: 1 / -1;
}

label.full-width {
  grid-column: 1 / -1;
}

.stats-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.button-row {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.button-row button,
#convertButton {
  border: none;
  border-radius: 18px;
  padding: 1rem;
  background: var(--primary);
  color: white;
  font-weight: 700;
}

.result-card {
  background: #f3faf8;
  border-radius: 24px;
  padding: 1.2rem;
  color: var(--primary-strong);
  min-height: 70px;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.history-panel {
  display: flex;
  flex-direction: column;
}

.history-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  overflow-y: auto;
  max-height: calc(100vh - 210px);
}

.history-item {
  background: #ffffff;
  border-radius: 24px;
  padding: 1rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
  border-left: 6px solid var(--primary);
}

body.dark {
  background: #0f172a;
  color: #f8fafc;
}

body.dark .sidebar,
body.dark .history-panel,
body.dark .panel,
body.dark .card,
body.dark .result-card,
body.dark .display,
body.dark .history-item,
body.dark .profile-card {
  background: #111827;
  color: #e2e8f0;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}

body.dark .menu-item {
  background: #1f2937;
  color: #f8fafc;
}

body.dark .menu-item:hover,
body.dark .menu-item.active {
  background: #111827;
}

body.dark .ghost {
  border-color: #374151;
  color: #e5e7eb;
}

body.dark .panel-header p,
body.dark .muted,
body.dark .byte-size {
  color: #94a3b8;
}

body.dark input,
body.dark select,
body.dark textarea {
  background: #1f2937;
  color: #f8fafc;
  border-color: #334155;
}

body.dark .pill,
body.dark .graph-grid button,
body.dark #saveFavoriteButton {
  background: #22c55e;
  color: #0f172a;
}

.history-item small {
  display: block;
  margin-top: 0.5rem;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .history-panel {
    order: -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 0.75rem;
  }

  .sidebar,
  .history-panel,
  .panel {
    border-radius: 24px;
    padding: 1rem;
  }

  .percent-grid,
  .converter-grid,
  .button-row {
    grid-template-columns: 1fr;
  }
}
