/* Scientific Calculator — application stylesheet
   Bilingual (RTL/LTR), light/dark, responsive. */

:root {
  color-scheme: light;
  --bg: #f2f6fb;
  --bg-soft: #e8eff8;
  --surface: #ffffff;
  --surface-2: #f7fafd;
  --surface-3: #eef4fa;
  --text: #10233c;
  --text-soft: #4d6078;
  --muted: #7b8ba1;
  --line: #d9e3ee;
  --line-strong: #c3d2e2;
  --primary: var(--brand-primary, #0b1f3a);
  --primary-2: #163a63;
  --primary-contrast: #ffffff;
  --accent: var(--brand-accent, #0fb5b5);
  --accent-2: #0a9696;
  --accent-soft: #e0f7f7;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --ok: #117a5a;
  --ok-soft: #e4f5ee;
  --star: #c98a00;
  --star-soft: #fff4d6;
  --shadow: 0 20px 45px -28px rgba(11, 31, 58, 0.5);
  --shadow-soft: 0 8px 24px -18px rgba(11, 31, 58, 0.45);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 9px;
  --sidebar-w: 272px;
  --font: "Segoe UI", "Tahoma", "Noto Sans Arabic", "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "Consolas", "SFMono-Regular", Menlo, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07101d;
  --bg-soft: #0a1727;
  --surface: #0f1e31;
  --surface-2: #13253c;
  --surface-3: #172c46;
  --text: #e9f1fb;
  --text-soft: #b2c4d9;
  --muted: #8399b1;
  --line: #203650;
  --line-strong: #2b4664;
  --primary: var(--brand-accent, #10bdbd);
  --primary-2: #0d9d9d;
  --primary-contrast: #04121c;
  --accent: var(--brand-accent, #23d5d5);
  --accent-2: #10b5b5;
  --accent-soft: #0d2f38;
  --danger: #ff7b6b;
  --danger-soft: #341a1a;
  --ok: #4cd6a7;
  --ok-soft: #0d2b23;
  --star: #f4c14f;
  --star-soft: #33280d;
  --shadow: 0 22px 50px -28px rgba(0, 0, 0, 0.85);
  --shadow-soft: 0 10px 28px -20px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
}
h1, h2, h3, h4, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, pre { font-family: var(--mono); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
::selection { background: var(--accent-soft); color: var(--text); }

/* ---------------------------------------------------------------- Layout */
.app-shell { min-height: 100vh; }
.app-main {
  min-height: 100vh;
  margin-inline-start: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}
.content {
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 26px 30px 34px;
  flex: 1;
}

/* Sidebar */
.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 12% 8%, rgba(15, 181, 181, 0.22), transparent 34%),
    linear-gradient(165deg, #0b1f3a 0%, #0a1a30 55%, #071323 100%);
  color: #e8f1fb;
  z-index: 40;
  border-inline-end: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 22px 20px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--accent), #0a8f9c);
  color: #04121c;
  font-size: 25px;
  font-weight: 800;
  box-shadow: 0 8px 18px -10px rgba(15, 181, 181, 0.9);
}
.brand-copy { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand-copy strong { font-size: 15px; font-weight: 700; letter-spacing: 0.1px; }
.brand-copy small { font-size: 11.5px; color: rgba(232, 241, 251, 0.62); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-close { color: #cfe0f2; display: none; }
.side-nav { flex: 1; overflow-y: auto; padding: 8px 14px 18px; display: flex; flex-direction: column; gap: 4px; }
.nav-label {
  margin: 16px 10px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(232, 241, 251, 0.42);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 11px;
  color: rgba(232, 241, 251, 0.78);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.nav-link.is-active {
  background: linear-gradient(100deg, rgba(15, 181, 181, 0.22), rgba(15, 181, 181, 0.06));
  border-color: rgba(15, 181, 181, 0.38);
  color: #ffffff;
}
.nav-link.is-active .nav-icon { color: var(--accent); }
.nav-icon { width: 20px; text-align: center; font-size: 16px; opacity: 0.9; }
.nav-admin { color: #ffd98a; }
.sidebar-foot { padding: 14px 16px 18px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.sidebar-privacy { display: block; font-size: 12px; color: rgba(232, 241, 251, 0.55); margin-bottom: 10px; }
.sidebar-privacy:hover { color: #fff; }
.user-card { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(15, 181, 181, 0.28), rgba(15, 181, 181, 0.1));
  color: #d9fbfb;
  font-weight: 700;
  font-size: 13px;
  border: 1px solid rgba(15, 181, 181, 0.35);
}
.avatar-small { width: 32px; height: 32px; font-size: 11.5px; }
.user-card-copy { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.user-card-copy strong { font-size: 13.5px; color: #f2f8ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card-copy small { font-size: 11px; color: rgba(232, 241, 251, 0.55); }
.logout-form .btn { color: #d7e5f5; border-color: rgba(255, 255, 255, 0.16); }
.logout-form .btn:hover { background: rgba(255, 255, 255, 0.1); }
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 10, 20, 0.55);
  z-index: 35;
  backdrop-filter: blur(2px);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 30px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-start { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title-wrap { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.topbar-kicker { font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.topbar-title { font-size: 18px; font-weight: 700; letter-spacing: -0.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.menu-toggle { display: none; }
.menu-bars, .menu-bars::before, .menu-bars::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  position: relative;
}
.menu-bars::before, .menu-bars::after { content: ""; position: absolute; inset-inline-start: 0; }
.menu-bars::before { top: -6px; }
.menu-bars::after { top: 6px; }
.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 15px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.icon-button:hover { background: var(--surface-3); color: var(--text); border-color: var(--line-strong); }
.icon-button:disabled { opacity: 0.4; cursor: not-allowed; }
.lang-button { width: auto; min-width: 58px; padding: 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.4px; }
.theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: inline; }
.topbar-user { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border-radius: 11px; color: inherit; }
.topbar-user:hover { background: var(--surface-3); text-decoration: none; }
.topbar-user .avatar { background: var(--accent-soft); color: var(--accent-2); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.topbar-user-copy { display: flex; flex-direction: column; line-height: 1.25; }
.topbar-user-copy strong { font-size: 12.5px; }
.topbar-user-copy small { font-size: 10.5px; color: var(--muted); }
.inline-form { display: inline-flex; margin: 0; }

/* Footer */
.site-footer {
  padding: 20px 30px 26px;
  text-align: center;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.footer-credit { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.footer-credit a { color: inherit; font-family: var(--mono); font-size: 12.5px; }
.footer-sep { color: var(--accent); margin: 0 8px; font-weight: 800; }

/* --------------------------------------------------------------- Elements */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { text-decoration: none; border-color: var(--line-strong); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(145deg, var(--primary-2), var(--primary)); border-color: transparent; color: #fff; box-shadow: 0 10px 22px -14px rgba(11, 31, 58, 0.9); }
[data-theme="dark"] .btn-primary { color: var(--primary-contrast); background: linear-gradient(145deg, var(--accent), var(--accent-2)); }
.btn-primary:hover { background: linear-gradient(145deg, var(--primary), #081729); color: #fff; }
[data-theme="dark"] .btn-primary:hover { background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: var(--primary-contrast); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 16%, var(--surface)); border-color: var(--danger); }
.btn-lg { min-height: 48px; padding: 11px 22px; font-size: 15px; border-radius: var(--radius-sm); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn.is-disabled { opacity: 0.45; pointer-events: none; }
.link-button { border: 0; background: none; color: var(--accent-2); font-size: 12.5px; font-weight: 600; padding: 0; }
.link-button:hover { text-decoration: underline; }
.link-danger { color: var(--danger); }
.text-link { font-size: 12.5px; font-weight: 600; color: var(--accent-2); }
.muted { color: var(--muted); font-size: 12.5px; }
.req { color: var(--danger); }
.eyebrow {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 5px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }
.badge-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.badge-star { background: var(--star-soft); border-color: color-mix(in srgb, var(--star) 35%, transparent); color: var(--star); }

/* Panels and page headings */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-soft);
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.panel-head h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.panel-head p { margin-top: 2px; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.page-head h2 { font-size: clamp(21px, 2.4vw, 27px); font-weight: 750; letter-spacing: -0.5px; line-height: 1.25; }
.page-head p { color: var(--text-soft); font-size: 13.5px; margin-top: 4px; max-width: 76ch; }
.page-head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Forms */
.stack-form { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 650; color: var(--text-soft); }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.field-input:hover { border-color: var(--line-strong); }
.field-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
textarea.field-input { resize: vertical; min-height: 90px; line-height: 1.6; }
.field-select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-inline-end: 34px; }
html[dir="rtl"] .field-select { background-position: 13px 50%, 18px 50%; }
.field-help { font-size: 11.5px; color: var(--muted); }
.field-error { font-size: 12px; color: var(--danger); font-weight: 600; }
.check-row { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-soft); cursor: pointer; }
.checkbox-input { width: 17px; height: 17px; accent-color: var(--accent); flex: 0 0 auto; cursor: pointer; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.form-alert {
  padding: 12px 14px;
  border-radius: var(--radius-xs);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 16px;
}
.form-alert p { margin: 0; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="color"] { width: 52px; height: 42px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface-2); }
.privacy-note {
  margin-top: 18px;
  padding: 12px 15px;
  border-radius: var(--radius-xs);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--text-soft);
  font-size: 12.5px;
}

/* Messages and toasts */
.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-xs);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  box-shadow: var(--shadow-soft);
}
.message-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.message-success { border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-soft); color: var(--ok); }
.message-success .message-dot { background: var(--ok); }
.message-error { border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--danger-soft); color: var(--danger); }
.message-error .message-dot { background: var(--danger); }
.message-warning { border-color: color-mix(in srgb, var(--star) 40%, transparent); background: var(--star-soft); color: var(--star); }
.toast-stack { position: fixed; inset-block-end: 22px; inset-inline-end: 22px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 220px;
  max-width: 340px;
  padding: 12px 16px;
  border-radius: var(--radius-xs);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
}
[data-theme="dark"] .toast { background: var(--surface-3); border: 1px solid var(--line-strong); }
.toast-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- Auth shell */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.auth-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
}
.auth-topbar .brand-copy strong { font-size: 14px; }
.auth-topbar .brand-copy small { font-size: 11px; }
.auth-actions { display: flex; align-items: center; gap: 8px; }
.auth-content { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 32px 48px; }
.auth-grid {
  width: 100%;
  max-width: 1120px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 34px;
  align-items: stretch;
}
.auth-hero {
  position: relative;
  overflow: hidden;
  padding: 46px 42px;
  border-radius: 26px;
  color: #eaf4ff;
  background:
    radial-gradient(circle at 85% 12%, rgba(15, 181, 181, 0.4), transparent 40%),
    linear-gradient(150deg, #0b1f3a 0%, #0a1a30 60%, #071323 100%);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-hero .eyebrow { color: #63e6e6; }
.auth-hero h1 { font-size: clamp(26px, 3.1vw, 38px); line-height: 1.22; letter-spacing: -0.8px; margin-bottom: 14px; font-weight: 750; }
.hero-lead { color: rgba(234, 244, 255, 0.76); font-size: 14.5px; max-width: 46ch; }
.hero-features { display: grid; gap: 11px; margin-top: 26px; }
.hero-features li { display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: rgba(234, 244, 255, 0.88); }
.hero-features span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(15, 181, 181, 0.16);
  border: 1px solid rgba(15, 181, 181, 0.3);
  color: #63e6e6;
  font-size: 17px;
  flex: 0 0 auto;
}
.hero-formula { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.hero-formula span {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  font-family: var(--mono);
  font-size: 11.5px;
  color: rgba(234, 244, 255, 0.72);
  direction: ltr;
}
.hero-orbit { position: absolute; border-radius: 50%; border: 1px solid rgba(15, 181, 181, 0.18); pointer-events: none; }
.hero-orbit-one { width: 340px; height: 340px; top: -140px; inset-inline-end: -100px; }
.hero-orbit-two { width: 210px; height: 210px; bottom: -100px; inset-inline-start: -60px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 38px 36px;
  box-shadow: var(--shadow);
  align-self: center;
  width: 100%;
}
.auth-card-head { text-align: center; margin-bottom: 24px; }
.auth-badge {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 15px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 26px;
  font-weight: 800;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.auth-card-head h2 { font-size: 22px; letter-spacing: -0.4px; }
.auth-card-head p { color: var(--text-soft); font-size: 13px; margin-top: 4px; }
.auth-switch { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-soft); }
.auth-grid-register .auth-card { padding-block: 30px; }

/* -------------------------------------------------------------- Calculator */
.workspace { width: 100%; }
.workspace-head { align-items: center; }
.workspace-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--ok-soft);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  color: var(--ok);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 45%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.calc-type-tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 5px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  scrollbar-width: thin;
}
.calc-tab {
  flex: 0 0 auto;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.calc-tab:hover { background: var(--surface-3); color: var(--text); }
.calc-tab[aria-selected="true"] { background: var(--primary); color: #fff; box-shadow: 0 8px 18px -12px rgba(11, 31, 58, 0.8); }
[data-theme="dark"] .calc-tab[aria-selected="true"] { background: var(--accent); color: var(--primary-contrast); }
.calc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
.calc-primary { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.calc-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.calc-panel-wrap { padding: 24px; }
.calc-panel { display: flex; flex-direction: column; gap: 16px; }
.mode-chip {
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.expression-wrap { position: relative; }
.expression-input {
  width: 100%;
  min-height: 74px;
  padding: 14px 58px 14px 16px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 20px;
  line-height: 1.5;
  resize: vertical;
}
html[dir="rtl"] .expression-input { padding: 14px 16px 14px 58px; }
.expression-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.expression-clear {
  position: absolute;
  inset-block-start: 10px;
  inset-inline-end: 10px;
  width: 38px;
  height: 38px;
  font-size: 11px;
  font-weight: 800;
  font-family: var(--font);
}
.memory-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.keypad { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.key {
  min-height: 46px;
  padding: 6px 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  transition: background 0.12s ease, transform 0.1s ease, border-color 0.12s ease;
}
.key:hover { background: var(--surface-3); border-color: var(--line-strong); }
.key:active { transform: translateY(1px); }
.key-fn { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent-2); font-size: 12.5px; }
.key-const { background: var(--surface-3); color: var(--text-soft); font-family: var(--mono); }
.key-soft { background: transparent; color: var(--text-soft); font-size: 12.5px; }
.key-op { background: color-mix(in srgb, var(--primary) 7%, var(--surface)); color: var(--primary-2); font-size: 17px; font-weight: 700; }
[data-theme="dark"] .key-op { color: var(--accent); background: var(--surface-3); }
.calc-options { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; padding-top: 4px; }
.calc-submit { align-self: end; }
.btn-calculate { min-width: 140px; }
.sub-panel {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 15px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.matrix-input { font-family: var(--mono); font-size: 14px; }
.link-button[data-goto-tab] { font-size: 12.5px; }
.form-actions .btn-calculate { min-width: 140px; }

/* Results */
.result-panel { position: relative; }
.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.result-head h3 { font-size: 16px; font-weight: 700; }
.result-head-actions { display: flex; gap: 6px; }
.favorite-star.is-on { background: var(--star-soft); border-color: color-mix(in srgb, var(--star) 45%, transparent); color: var(--star); }
.result-empty {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  font-size: 13.5px;
}
.result-placeholder-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 22px;
  font-weight: 800;
  flex: 0 0 auto;
}
.result-primary {
  font-family: var(--mono);
  font-size: clamp(24px, 3.4vw, 36px);
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.25;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--line);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.result-exact-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.result-exact-row code { padding: 3px 8px; border-radius: 7px; background: var(--surface-3); color: var(--text-soft); font-size: 12.5px; }
.value-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 9px; margin-top: 14px; }
.value-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.value-item span { font-size: 11px; color: var(--muted); }
.value-item strong { font-family: var(--mono); font-size: 14px; color: var(--text); word-break: break-word; }
.matrix-result { margin-top: 14px; overflow-x: auto; }
.matrix-result table { border-collapse: collapse; margin-inline: auto; font-family: var(--mono); }
.matrix-result td { padding: 6px 14px; text-align: center; border: 1px solid var(--line); min-width: 52px; }
.chart-wrap { margin-top: 14px; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); overflow-x: auto; }
.chart-wrap svg { display: block; max-width: 100%; height: auto; }
.steps { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 13px; }
.steps summary { cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--text-soft); }
.steps ol { margin-top: 10px; display: flex; flex-direction: column; gap: 7px; counter-reset: step; }
.steps li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  padding: 8px 11px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
  counter-increment: step;
}
.steps li::before { content: counter(step); width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2); font-size: 10.5px; font-weight: 800; flex: 0 0 auto; }
.step-label { color: var(--muted); font-size: 11.5px; }
.step-value { font-family: var(--mono); color: var(--text); word-break: break-word; }
.result-meta { margin-top: 12px; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.result-status { font-size: 12px; color: var(--muted); }
.result-error {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-xs);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

/* Recent and tips */
.recent-list { display: flex; flex-direction: column; gap: 7px; }
.recent-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.recent-item:hover { border-color: var(--accent); background: var(--surface-3); text-decoration: none; }
.recent-type { font-size: 10.5px; font-weight: 700; color: var(--accent-2); }
.recent-item time { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }
.recent-expr { grid-column: 1 / -1; font-family: var(--mono); font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-result { grid-column: 1 / -1; font-family: var(--mono); font-size: 11.5px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip-panel { background: linear-gradient(150deg, var(--surface), var(--surface-3)); }
.tip-list { display: flex; flex-direction: column; gap: 9px; margin-top: 10px; }
.tip-list li { position: relative; padding-inline-start: 18px; font-size: 12.5px; color: var(--text-soft); }
.tip-list li::before { content: "◆"; position: absolute; inset-inline-start: 0; color: var(--accent); font-size: 9px; top: 3px; }
.empty-state { padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* Modal */
.modal { border: 0; padding: 0; background: transparent; max-width: 520px; width: calc(100% - 32px); }
.modal::backdrop { background: rgba(3, 10, 20, 0.6); backdrop-filter: blur(3px); }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h3 { font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 4px; }

/* ------------------------------------------------------- Records & notes */
.filter-panel { margin-bottom: 20px; }
.filter-grid { display: grid; grid-template-columns: minmax(200px, 1.4fr) repeat(3, minmax(130px, 0.7fr)) minmax(130px, 0.6fr) minmax(150px, 0.8fr); gap: 12px; align-items: end; }
.filter-checks { display: flex; flex-direction: column; gap: 7px; justify-content: center; min-height: 42px; }
.filter-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); }
.filter-count { margin-inline-start: auto; font-size: 12.5px; color: var(--muted); }
.filter-count strong { color: var(--text); }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.table-panel { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th, .data-table td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table th { background: var(--surface-2); color: var(--text-soft); font-size: 11px; font-weight: 750; letter-spacing: 0.6px; text-transform: uppercase; white-space: nowrap; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.cell-check { width: 44px; text-align: center !important; }
.table-title { font-weight: 700; font-size: 13px; color: var(--text); }
.table-title:hover { color: var(--accent-2); }
.table-expression { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 2px; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-badges { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.table-result { font-family: var(--mono); font-size: 12px; color: var(--text-soft); }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 20px; }
.pagination-info { font-size: 12.5px; color: var(--muted); }
.empty-panel { text-align: center; padding: 46px 24px; display: flex; flex-direction: column; align-items: center; gap: 9px; }
.empty-mark { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 16px; background: var(--surface-3); color: var(--muted); font-size: 24px; margin-bottom: 4px; }
.empty-panel p { color: var(--muted); font-size: 13px; max-width: 50ch; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 20px; }
.detail-side { gap: 20px; }
.detail-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-expression { margin-bottom: 12px; }
.detail-label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 4px; }
.detail-expression pre {
  margin: 0;
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}
.detail-result {
  font-family: var(--mono);
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--line);
  word-break: break-word;
}
.detail-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 9px; margin-top: 16px; }
.detail-meta > div { padding: 9px 11px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.detail-meta dt { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.detail-meta dd { font-size: 12.5px; margin-top: 2px; word-break: break-word; }
.detail-note { margin-top: 16px; padding: 14px; border-radius: var(--radius-sm); background: var(--star-soft); border: 1px solid color-mix(in srgb, var(--star) 25%, transparent); }
.detail-note h4 { font-size: 13px; margin-bottom: 5px; }
.detail-note p { font-size: 13px; color: var(--text-soft); }
.danger-zone { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.note-form-wrap { margin-top: 14px; }
.note-form-wrap > summary { list-style: none; }
.note-form-wrap > summary::-webkit-details-marker { display: none; }
.note-form-wrap[open] > summary { margin-bottom: 14px; }
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.note-card { padding: 16px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); }
.note-card-full { display: flex; flex-direction: column; gap: 8px; }
.note-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.note-card-head h3 { font-size: 14.5px; }
.note-card-head strong { font-size: 13.5px; }
.note-card p { font-size: 12.5px; color: var(--text-soft); white-space: pre-wrap; word-break: break-word; }
.note-card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.note-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.note-card-foot time { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }
.note-link { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 9px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent); font-family: var(--mono); font-size: 11.5px; color: var(--text-soft); }
.note-link:hover { text-decoration: none; border-color: var(--accent); }
.note-link-label { font-family: var(--font); font-size: 10px; font-weight: 700; color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.6px; }
.form-panel { max-width: 760px; }

/* ------------------------------------------------------------------ Admin */
.admin-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 22px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-soft); }
.admin-tab { flex: 0 0 auto; padding: 8px 15px; border-radius: 9px; color: var(--text-soft); font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.admin-tab:hover { background: var(--surface-3); text-decoration: none; }
.admin-tab.is-active { background: var(--primary); color: #fff; }
[data-theme="dark"] .admin-tab.is-active { background: var(--accent); color: var(--primary-contrast); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { display: flex; flex-direction: column; gap: 3px; padding: 18px 20px; }
.stat-label { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; }
.stat-value { font-size: clamp(26px, 3vw, 34px); font-weight: 750; letter-spacing: -1px; line-height: 1.1; }
.stat-meta { font-size: 11.5px; color: var(--text-soft); }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; margin-bottom: 20px; }
.bar-chart { display: flex; align-items: flex-end; gap: 5px; height: 160px; padding-top: 10px; }
.bar-item { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; height: 100%; min-width: 0; }
.bar { width: 100%; max-width: 26px; min-height: 3px; border-radius: 5px 5px 2px 2px; background: linear-gradient(180deg, var(--accent), var(--accent-2)); opacity: 0.85; }
.bar-item:hover .bar { opacity: 1; }
.bar-label { font-size: 9px; color: var(--muted); font-family: var(--mono); white-space: nowrap; }
.rank-list { display: flex; flex-direction: column; gap: 7px; }
.rank-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 11px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; }
.rank-value { font-family: var(--mono); font-weight: 700; color: var(--accent-2); }
.simple-list { display: flex; flex-direction: column; gap: 8px; }
.simple-list li { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.simple-list li:last-child { border-bottom: 0; }
.simple-list-copy { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; flex: 1; }
.simple-list-copy strong { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.simple-list-copy small { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-cell { display: flex; align-items: center; gap: 9px; }
.user-cell .avatar { background: var(--accent-soft); color: var(--accent-2); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }

/* -------------------------------------------------------------- Legal/errors */
.legal-page { max-width: 920px; margin: 0 auto; }
.legal-card { display: flex; flex-direction: column; gap: 18px; }
.legal-card article { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.legal-card article:last-child { border-bottom: 0; padding-bottom: 0; }
.legal-card h3 { font-size: 15px; margin-bottom: 5px; }
.legal-card p { font-size: 13px; color: var(--text-soft); }
.error-page { max-width: 620px; margin: 8vh auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.error-code { font-family: var(--mono); font-size: clamp(64px, 12vw, 110px); font-weight: 800; line-height: 1; letter-spacing: -4px; color: transparent; -webkit-text-stroke: 2px var(--accent); opacity: 0.75; }
.error-page h1 { font-size: 24px; }
.error-page p { color: var(--text-soft); font-size: 14px; max-width: 46ch; }
.error-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* -------------------------------------------------------------- Responsive */
@media (max-width: 1200px) {
  .calc-grid { grid-template-columns: minmax(0, 1fr) 290px; }
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-search { grid-column: span 2; }
  .detail-grid { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 252px; }
  .content { padding: 22px 22px 30px; }
  .topbar { padding: 12px 22px; }
  .calc-grid { grid-template-columns: minmax(0, 1fr); }
  .calc-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .auth-grid { grid-template-columns: 1fr; max-width: 620px; }
  .auth-hero { display: none; }
  .auth-grid-register .auth-hero { display: none; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-105%); transition: transform 0.22s ease; box-shadow: var(--shadow); }
  html[dir="rtl"] .sidebar { transform: translateX(105%); }
  .sidebar.is-open { transform: none; }
  .sidebar-close { display: inline-grid; }
  .app-main { margin-inline-start: 0; }
  .menu-toggle { display: inline-grid; }
  .topbar-user-copy { display: none; }
  .calc-side { grid-template-columns: minmax(0, 1fr); }
  .detail-side { grid-template-columns: minmax(0, 1fr); }
  .auth-topbar { padding: 14px 20px; }
  .auth-content { padding: 18px 20px 40px; }
  .auth-card { padding: 30px 24px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head-actions { justify-content: flex-start; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-search { grid-column: span 2; }
  .calc-options { grid-template-columns: 1fr 1fr; }
  .calc-submit { grid-column: 1 / -1; }
  .btn-calculate { width: 100%; }
}
@media (max-width: 620px) {
  body { font-size: 14px; }
  .content { padding: 16px 14px 26px; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar-title { font-size: 15px; }
  .topbar-kicker { display: none; }
  .lang-button { min-width: 50px; font-size: 11px; }
  .panel { padding: 17px; border-radius: 15px; }
  .calc-panel-wrap { padding: 17px; }
  .keypad { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .key { min-height: 42px; font-size: 13.5px; }
  .expression-input { font-size: 17px; min-height: 64px; }
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .filter-grid { grid-template-columns: minmax(0, 1fr); }
  .filter-search { grid-column: auto; }
  .filter-count { margin-inline-start: 0; width: 100%; }
  .calc-type-tabs { border-radius: 12px; }
  .calc-tab { padding: 8px 13px; font-size: 12px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card { padding: 14px; }
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .notes-grid { grid-template-columns: minmax(0, 1fr); }
  .bar-label { display: none; }
  .site-footer { padding: 16px 14px 22px; }
  .footer-credit { font-size: 12px; }
  .auth-card { padding: 26px 18px; border-radius: 18px; }
  .auth-topbar .brand-copy small { display: none; }
  .data-table th, .data-table td { padding: 10px; }
  .table-expression { max-width: 210px; }
  .toast-stack { inset-inline: 14px; inset-block-end: 14px; }
  .toast { max-width: none; }
}
@media (max-width: 420px) {
  .keypad { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Print */
@media print {
  .sidebar, .topbar, .site-footer, .calc-type-tabs, .calc-side, .page-head-actions, .filter-panel, .table-toolbar, .pagination, .row-actions, .toast-stack, .messages { display: none !important; }
  .app-main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .panel { box-shadow: none; border-color: #ccc; }
  body { background: #fff; color: #000; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
