/**
 * Easy Accounting System - Soft Japandi SaaS Theme
 */

:root {
  color-scheme: light;

  --color-primary-bg: #F7F1E8;
  --color-secondary-bg: #EFE6DA;
  --color-canvas: #FBF7F0;
  --color-surface: #FFFFFF;
  --color-surface-soft: #FFFBF5;
  --color-surface-wood: #E7D1B7;
  --color-surface-mist: #EDF5EF;
  --color-ink: #2F332E;
  --color-muted: #70776B;
  --color-soft: #9A9F92;
  --color-line: #E7DED2;
  --color-line-strong: #D8C8B6;
  --color-primary-btn: #8F6F53;
  --color-primary-btn-hover: #755941;
  --color-secondary-btn: #FFF8EE;
  --color-accent-blue: #5C86A6;
  --color-accent-green: #4E8F6A;
  --color-accent-pink: #C9808B;
  --color-accent-yellow: #D7A85D;
  --color-accent-mint: #BFDCC8;
  --color-accent-lavender: #C9C4E1;
  --color-accent-sky: #BFD8E6;
  --color-danger: #B85C52;
  --color-warning: #B77932;
  --color-success: #3F7B5A;

  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --card-radius: 18px;
  --control-radius: 14px;
  --button-radius: 999px;
  --card-shadow: 0 18px 50px rgba(95, 75, 52, 0.10);
  --soft-shadow: 0 8px 22px rgba(95, 75, 52, 0.08);
  --focus-ring: 0 0 0 4px rgba(143, 111, 83, 0.20);
  --nav-width: 232px;
  --nav-bg: rgba(255, 251, 245, 0.92);
  --nav-border: #E8DCCF;
  --nav-active: #755941;
  --nav-active-bg: #F3E6D8;
}

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

html {
  min-width: 320px;
  background: var(--color-primary-bg);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 12% 5%, rgba(231, 209, 183, 0.42), transparent 28rem),
    linear-gradient(135deg, #FBF7F0 0%, #F6EFE5 52%, #F9F3EA 100%);
  color: var(--color-ink);
  line-height: 1.55;
  letter-spacing: 0;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
}

#app { min-height: 100vh; }

.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-size: 1rem;
  color: var(--color-muted);
}

button, input, select, textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  min-height: 40px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring) !important;
}

a { color: var(--color-primary-btn); }

::selection {
  background: rgba(143, 111, 83, 0.22);
}

/* App shell */
.app-shell { display: flex; min-height: 100vh; }

.app-nav {
  width: var(--nav-width);
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 100;
  backdrop-filter: blur(18px);
  box-shadow: 18px 0 45px rgba(95, 75, 52, 0.07);
  padding-bottom: 0.35rem;
}

.nav-profile-section {
  position: relative;
  border-bottom: 1px solid var(--nav-border);
  flex-shrink: 0;
  padding: 0.45rem 0.55rem;
}

.nav-profile-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.48rem 0.58rem;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(232, 220, 207, 0.76);
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.nav-profile-card:hover {
  background: #fff;
  border-color: var(--color-line-strong);
  transform: translateY(-1px);
}

.nav-avatar {
  width: 30px;
  height: 30px;
  border-radius: 11px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.55);
}
.nav-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.nav-avatar-fallback {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #B9916D, #6E8C72);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 750;
}

.nav-profile-text { flex: 1; min-width: 0; }
.nav-company-name {
  font-size: 0.82rem;
  font-weight: 750;
  color: var(--color-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-user-name {
  font-size: 0.74rem;
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-profile-chevron { font-size: 0.68rem; color: var(--color-soft); flex-shrink: 0; }

.nav-profile-dropdown {
  position: absolute;
  top: calc(100% - 0.55rem);
  left: 0.8rem;
  right: 0.8rem;
  background: #fff;
  border: 1px solid var(--nav-border);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  z-index: 300;
  overflow: hidden;
}

.nav-dropdown-label {
  padding: 0.75rem 0.9rem 0.35rem;
  font-size: 0.68rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-soft);
}
.nav-dropdown-divider { border-top: 1px solid var(--nav-border); margin: 0.25rem 0; }

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.68rem 0.9rem;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.88rem;
  color: var(--color-muted);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease;
}
.nav-dropdown-item:hover { background: var(--nav-active-bg); color: var(--nav-active); }
.nav-dropdown-item.active { color: var(--nav-active); font-weight: 700; }
.nav-dropdown-signout { color: var(--color-danger); }
.nav-dropdown-signout:hover { background: #FFF0EE; color: #9C423A; }

.nav-items-list {
  flex: 1 1 auto;
  min-height: 0;
  height: 0;
  padding: 0.55rem 0.6rem 0.45rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  width: 100%;
  padding: 0.52rem 0.65rem;
  margin-bottom: 0.18rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  font-size: 0.96rem;
  font-weight: 700;
  color: #5D6458;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.72);
  color: var(--nav-active);
  border-color: var(--nav-border);
  transform: translateY(-1px);
}
.nav-item.active,
.nav-item.expanded {
  background: var(--nav-active-bg);
  color: var(--nav-active);
  border-color: rgba(143, 111, 83, 0.18);
  box-shadow: 0 7px 18px rgba(143, 111, 83, 0.10);
}
.nav-item-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(143, 111, 83, 0.10);
  color: var(--nav-active);
  font-size: 0;
  font-weight: 800;
}
.nav-item-icon::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(143, 111, 83, 0.10);
}
.nav-item-label { flex: 1; min-width: 0; }
.nav-item-label {
  white-space: normal;
  line-height: 1.18;
}
.nav-group-chevron {
  font-size: 0.62rem;
  color: var(--color-soft);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.nav-children {
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(232, 220, 207, 0.72);
  margin: 0.08rem 0 0.35rem 1.75rem;
  border-radius: 10px;
  overflow: hidden;
}

.nav-child-item {
  display: block;
  width: 100%;
  padding: 0.46rem 0.62rem;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.9rem;
  color: var(--color-muted);
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
  white-space: normal;
  line-height: 1.18;
}
.nav-child-item:hover { background: var(--nav-active-bg); color: var(--nav-active); }
.nav-child-item.active { color: var(--nav-active); font-weight: 750; }

.nav-bottom {
  flex: 0 0 auto;
  padding: 0.1rem 0.45rem 0.22rem;
  border-top: 1px solid var(--nav-border);
  background: rgba(255, 251, 245, 0.96);
}

.nav-club-card {
  display: none !important;
}

.nav-club-card img {
  display: block !important;
  width: 100% !important;
  height: 0 !important;
  max-height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

#nav-club {
  display: none !important;
}

.nav-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.05rem 0.05rem 0;
}
.nav-logo-area { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.nav-logo-area img {
  max-width: 192px !important;
  max-height: 78px !important;
  height: auto !important;
}
.nav-bell {
  background: #fff;
  border: 1px solid var(--nav-border);
  color: var(--color-muted);
  font-size: 0;
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  transition: background 0.18s ease, transform 0.18s ease;
}
.nav-bell::before {
  content: "";
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 50%;
  background: var(--color-accent-green);
  box-shadow: 0 0 0 5px rgba(78, 143, 106, 0.14);
}
.nav-bell:hover { background: var(--nav-active-bg); transform: translateY(-1px); }

.app-main {
  margin-left: var(--nav-width);
  flex: 1;
  min-height: 100vh;
  background: transparent;
}

.nav-toggle {
  display: none;
  position: fixed;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 200;
  background: rgba(255, 251, 245, 0.94);
  border: 1px solid var(--nav-border);
  border-radius: 14px;
  width: 44px;
  height: 44px;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--color-ink);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(12px);
}
.app-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(47, 51, 46, 0.28);
  z-index: 99;
}

/* Shared SaaS components */
.eas-page,
[class$="-page"],
.invoice-form-wrapper {
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% 8%, rgba(191, 220, 200, 0.28), transparent 23rem),
    linear-gradient(135deg, #FBF7F0 0%, #F6EFE5 100%) !important;
  padding: clamp(1rem, 2vw, 2rem) !important;
}

.eas-container {
  width: min(1220px, 100%);
  margin: 0 auto;
}

.eas-topbar,
.eas-hero,
.eas-card,
.eas-panel {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(232, 220, 207, 0.82);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(18px);
}

.eas-hero {
  padding: clamp(1.25rem, 3vw, 2.5rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(1.25rem, 4vw, 3rem);
  align-items: center;
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
}

.eas-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.12), rgba(231,209,183,0.20)),
    repeating-linear-gradient(90deg, rgba(143,111,83,0.035) 0 1px, transparent 1px 22px);
  pointer-events: none;
}

.eas-hero > * { position: relative; z-index: 1; }

.eas-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
  color: var(--color-primary-btn);
  background: rgba(143, 111, 83, 0.10);
  border: 1px solid rgba(143, 111, 83, 0.12);
  border-radius: 999px;
  padding: 0.38rem 0.72rem;
  font-size: 0.76rem;
  font-weight: 800;
}

.eas-title {
  color: var(--color-ink);
  font-size: clamp(1.7rem, 4vw, 2.65rem);
  line-height: 1.08;
  font-weight: 820;
  letter-spacing: 0;
  margin-bottom: 0.6rem;
}

.eas-subtitle {
  color: var(--color-muted);
  font-size: clamp(0.98rem, 1.7vw, 1.1rem);
  max-width: 64ch;
}

.eas-illustration {
  width: min(265px, 30vw);
  min-width: 180px;
  aspect-ratio: 1.18;
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(231, 209, 183, 0.68), rgba(237, 245, 239, 0.9)),
    #F7F1E8;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.75), var(--soft-shadow);
}

.eas-illustration img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.8rem;
}

.eas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.eas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
}

.eas-grid-3 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(280px, 0.72fr);
  gap: 1rem;
}

.eas-card {
  padding: 1.15rem;
}

.eas-card-title {
  color: var(--color-ink);
  font-size: 0.96rem;
  font-weight: 780;
  margin-bottom: 0.2rem;
}

.eas-card-text {
  color: var(--color-muted);
  font-size: 0.86rem;
}

.eas-metric-value {
  color: var(--color-ink);
  font-size: clamp(1.35rem, 2.3vw, 1.8rem);
  line-height: 1.1;
  font-weight: 820;
}

.eas-metric-label {
  color: var(--color-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.eas-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.eas-action {
  border: 1px solid rgba(232, 220, 207, 0.88);
  border-radius: 18px;
  background: rgba(255,255,255,0.76);
  box-shadow: var(--soft-shadow);
  padding: 1rem;
  cursor: pointer;
  text-align: left;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.eas-action:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow);
  border-color: var(--color-line-strong);
}

.eas-action-icon {
  width: 42px;
  height: 42px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  margin-bottom: 0.8rem;
  background: var(--color-surface-mist);
  color: var(--color-success);
  font-weight: 850;
}

.eas-button,
.quick-action-btn,
button[id^="add-"],
button[id^="retry-"],
button[id^="empty-new"],
button[type="submit"] {
  border-radius: var(--button-radius) !important;
  min-height: 42px;
  font-weight: 750 !important;
  box-shadow: 0 10px 18px rgba(143, 111, 83, 0.12);
}

.eas-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.72rem 1.05rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.eas-button-primary,
button[id^="add-"],
button[type="submit"] {
  background: var(--color-primary-btn) !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  text-shadow: none !important;
}
.eas-button-primary:hover,
button[id^="add-"]:hover,
button[type="submit"]:hover {
  background: var(--color-primary-btn-hover) !important;
}

.eas-button-secondary {
  background: #fff !important;
  border-color: var(--color-line) !important;
  color: var(--color-ink) !important;
}

input,
select,
textarea {
  border-color: var(--color-line) !important;
  border-radius: var(--control-radius) !important;
  color: var(--color-ink) !important;
  background-color: rgba(255, 255, 255, 0.88) !important;
}

input::placeholder,
textarea::placeholder {
  color: #A5A99E;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary-btn) !important;
  box-shadow: var(--focus-ring) !important;
}

label {
  color: var(--color-muted) !important;
  font-weight: 700 !important;
}

table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

thead th {
  background: #F8F1E8 !important;
  color: #747A70 !important;
  letter-spacing: 0.04em !important;
}

tbody tr {
  transition: background 0.16s ease, transform 0.16s ease;
}

tbody tr:hover {
  background: #FFF8EF !important;
}

td, th {
  border-color: #EFE5DA !important;
}

.app-main div[style*="box-shadow"],
.app-main div[style*="background:#fff"],
.app-main div[style*="background: #fff"] {
  border-color: rgba(232, 220, 207, 0.82) !important;
  box-shadow: var(--soft-shadow) !important;
}

.app-main div[style*="border-radius:12px"],
.app-main div[style*="border-radius: 12px"] {
  border-radius: var(--card-radius) !important;
}

.app-main button[style*="background:#C7AA8F"],
.app-main button[style*="background-color: #C7AA8F"],
.app-main button[style*="background-color:#C7AA8F"] {
  background: var(--color-primary-btn) !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  text-shadow: none !important;
}

.app-main [style*="color:#C7AA8F"],
.app-main [style*="color: #C7AA8F"] {
  color: var(--color-primary-btn) !important;
}

.app-main [style*="color:#333"],
.app-main [style*="color: #333"] {
  color: var(--color-ink) !important;
}

.app-main [style*="color:#666"],
.app-main [style*="color: #666"],
.app-main [style*="color:#888"],
.app-main [style*="color: #888"] {
  color: var(--color-muted) !important;
}

.app-toast {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  min-width: 320px;
  max-width: 500px;
  padding: 1rem 1.25rem;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.95rem;
  font-weight: 650;
  z-index: 10000;
  opacity: 0;
  transform: translateX(100px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  border: 1px solid rgba(255,255,255,0.45);
}

.app-toast--visible {
  opacity: 1;
  transform: translateX(0);
}

.app-toast--success { background-color: #E8F5EC; color: #24583C; border-left: 4px solid var(--color-success); }
.app-toast--error { background-color: #FFF0EE; color: #88382F; border-left: 4px solid var(--color-danger); }
.app-toast--info { background-color: #EEF5F8; color: #335F78; border-left: 4px solid var(--color-accent-blue); }

.app-toast__message { flex: 1; line-height: 1.5; }

.app-toast__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}
.app-toast__close:hover { opacity: 1; background-color: rgba(0, 0, 0, 0.05); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

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

  .eas-illustration {
    width: 100%;
    max-width: 320px;
    justify-self: center;
  }
}

@media (max-width: 767px) {
  .nav-toggle { display: block; }
  .app-nav {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: min(90vw, 330px);
  }
  .app-nav.open { transform: translateX(0); }
  .app-nav-overlay.open { display: block; }
  .app-main { margin-left: 0; padding-top: 3.4rem; }
  .eas-page,
  [class$="-page"],
  .invoice-form-wrapper {
    padding: 1rem !important;
  }
  .eas-actions,
  .eas-grid {
    grid-template-columns: 1fr;
  }
  .eas-title { font-size: 1.8rem; }
  .app-toast {
    top: 1rem;
    right: 1rem;
    left: 1rem;
    min-width: auto;
    max-width: none;
  }
}
