:root{
  --app-bg:#faf9f8;
  --app-surface:#ffffff;
  --app-surface-soft:#f6f5f4;
  --app-border:#e7e4e1;
  --app-border-strong:#d7d3cf;
  --app-text:#1f1f1f;
  --app-muted:#605e5c;
  --app-primary:#3155c7;
  --app-primary-hover:#2848ab;
  --app-primary-soft:#edf2ff;
  --app-warning-bg:#fff4ea;
  --app-warning-border:#f0c6a1;
  --app-warning-text:#a44d14;
  --app-danger:#d13438;
  --app-folder-a:#f7b400;
  --app-folder-b:#ffd85e;
  --app-folder-c:#ffbf37;
  --radius-xl:28px;
  --radius-lg:20px;
  --radius-md:14px;
  --radius-sm:10px;
  --shadow-soft:0 1px 2px rgba(0,0,0,.05),0 10px 30px rgba(0,0,0,.05);
}

*{box-sizing:border-box}
html,body{min-height:100%}

body{
  margin:0;
  color:var(--app-text);
  font-family:"Segoe UI Variable Display","Segoe UI","Helvetica Neue",Arial,sans-serif;
  background:
    radial-gradient(circle at top left,rgba(49,85,199,.04),transparent 24%),
    radial-gradient(circle at bottom right,rgba(247,180,0,.05),transparent 20%),
    var(--app-bg);
}

a{text-decoration:none;color:inherit}
button,input,select,textarea{font:inherit}

.app-shell{
  min-height:100vh;
  display:grid;
  grid-template-rows:72px minmax(0,1fr);
}

.app-topbar{
  position:sticky;
  top:0;
  z-index:30;
  display:flex;
  align-items:center;
  justify-content:space-between;
  min-height:72px;
  width:100%;
  gap:16px;
  padding:12px 24px;
  background:rgba(250,249,248,.92);
  border-bottom:1px solid rgba(231,228,225,.95);
  backdrop-filter:blur(14px);
}

.app-topbar-left,.app-topbar-right{
  display:flex;
  align-items:center;
  gap:14px;
}

.app-topbar-right{justify-content:flex-end}

.app-brand-mark{
  width:44px;
  height:44px;
  border-radius:16px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:linear-gradient(135deg,#54b0ff,#3155c7);
  color:#fff;
  font-weight:700;
  letter-spacing:.03em;
  box-shadow:0 10px 18px rgba(49,85,199,.18);
}

.app-brand-copy{display:flex;flex-direction:column;gap:3px}
.app-brand-copy strong{font-size:18px;line-height:1.1}
.app-brand-copy span{font-size:12px;color:var(--app-muted)}

.app-layout{
  min-height:0;
  display:grid;
  grid-template-columns:228px minmax(0,1fr);
}

.app-sidebar{
  min-height:0;
  padding:24px 14px;
  background:#fff;
  border-right:1px solid var(--app-border);
  display:flex;
  flex-direction:column;
  gap:14px;
}

.app-sidebar-section{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.app-sidebar-label{
  padding:0 10px;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
  font-weight:700;
  color:var(--app-muted);
}

.erp-sidebar-nav,
.app-sidebar-nav{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.erp-nav-link{
  min-height:42px;
  padding:0 14px;
  border-radius:12px;
  display:flex;
  align-items:center;
  color:#323130;
  border:1px solid transparent;
  transition:.16s ease;
}

.erp-nav-link:hover{
  background:#f6f5f4;
  border-color:#efedeb;
}

.erp-nav-link.is-active{
  background:var(--app-primary-soft);
  border-color:#d8e2ff;
  color:var(--app-primary);
  font-weight:600;
}

.erp-stage{
  min-width:0;
  min-height:0;
  padding:24px 28px 30px;
  display:flex;
  flex-direction:column;
  gap:18px;
}

.erp-topbar{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:18px;
  flex-wrap:wrap;
  padding:0;
  background:transparent;
  border:0;
  box-shadow:none;
}

.app-page-head h1{
  margin:0;
  font-size:32px;
  font-weight:650;
  letter-spacing:-.025em;
}

.app-page-head p{
  margin:6px 0 0;
  color:var(--app-muted);
  font-size:14px;
  line-height:1.6;
  max-width:760px;
}

.erp-grid{
  display:grid;
  grid-template-columns:minmax(0,1.18fr) minmax(320px,.82fr);
  gap:18px;
  align-items:start;
}

.erp-card{
  background:var(--app-surface);
  border:1px solid var(--app-border);
  border-radius:var(--radius-xl);
  box-shadow:var(--shadow-soft);
  overflow:hidden;
}

.erp-card-head{
  padding:20px 22px;
  border-bottom:1px solid #f1efed;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  flex-wrap:wrap;
}

.erp-card h3{
  margin:0;
  font-size:20px;
  font-weight:650;
}

.erp-card-body{padding:22px}

.erp-form-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:16px;
}

.material-form-grid{margin-bottom:18px}
.erp-field{display:flex;flex-direction:column;gap:8px}
.erp-field label{font-size:13px;font-weight:600;color:#3b3a39}
.full{grid-column:1/-1}

input,select,textarea{
  width:100%;
  border:1px solid var(--app-border-strong);
  background:#fff;
  color:var(--app-text);
  border-radius:14px;
  padding:12px 14px;
  font-size:14px;
  outline:none;
  transition:border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

input:focus,select:focus,textarea:focus{
  border-color:#9db5ff;
  box-shadow:0 0 0 4px rgba(49,85,199,.11);
}

input[readonly]{background:#faf9f8}

.hint,.muted,.guide-body,.erp-card p{color:var(--app-muted)}
.hint{font-size:13px;line-height:1.65}

.price-field-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}

.price-mode-switch{
  display:inline-flex;
  gap:4px;
  padding:4px;
  border-radius:999px;
  background:#f2f1f0;
  border:1px solid var(--app-border);
}

.price-mode-btn{
  min-height:28px;
  padding:0 12px;
  border:0;
  border-radius:999px;
  background:transparent;
  color:var(--app-muted);
  font-size:12px;
  font-weight:600;
  cursor:pointer;
}

.price-mode-btn:hover{color:var(--app-text)}

.price-mode-btn.is-active{
  background:#fff;
  color:var(--app-text);
  box-shadow:0 1px 2px rgba(0,0,0,.06);
}

.erp-actions,.row-actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.erp-btn{
  min-height:36px;
  padding:0 14px;
  border-radius:10px;
  border:1px solid var(--app-border-strong);
  background:#fff;
  color:var(--app-text);
  cursor:pointer;
}

.erp-btn:hover{background:#f7f6f5}

.erp-btn-primary{
  background:var(--app-primary);
  border-color:var(--app-primary);
  color:#fff;
}

.erp-btn-primary:hover{background:var(--app-primary-hover)}

.erp-btn-danger{
  color:var(--app-danger);
  border-color:#efc1c3;
  background:#fff6f6;
}

.app-logout-btn{
  min-height:36px;
  border-radius:999px;
  padding:0 16px;
}

.status-chip{
  display:inline-flex;
  align-items:center;
  min-height:34px;
  padding:0 12px;
  border-radius:999px;
  border:1px solid #d8e2ff;
  background:var(--app-primary-soft);
  color:var(--app-primary);
  font-size:13px;
  white-space:nowrap;
}

.status-chip.error{
  border-color:#efc1c3;
  background:#fff4f4;
  color:var(--app-danger);
}

.result-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
  margin-top:18px;
}

.result-box{
  position:relative;
  min-height:122px;
  padding:20px 18px 18px;
  border-radius:18px;
  border:1px solid #ece6d6;
  background:#fffefb;
  overflow:hidden;
}

.result-box::before{
  content:"";
  position:absolute;
  top:16px;
  left:18px;
  width:42px;
  height:6px;
  border-radius:999px;
  background:linear-gradient(90deg,var(--app-folder-a),var(--app-folder-c));
}

.result-box::after{
  content:none;
}

.result-box .label{
  position:relative;
  z-index:1;
  margin-top:18px;
  margin-bottom:10px;
  color:#756737;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.05em;
}

.result-box .value{
  position:relative;
  z-index:1;
  font-size:34px;
  font-weight:650;
  line-height:1.15;
  color:#1f1f1f;
  word-break:break-word;
}

.formula{
  margin-top:18px;
  padding:16px 18px;
  border-radius:18px;
  border:1px dashed #e4dcc0;
  background:#fffef8;
  color:#5c5130;
  font-size:13px;
  line-height:1.7;
}

.toolbar{margin-bottom:16px}

.table-wrap{
  overflow:auto;
  border:1px solid var(--app-border);
  border-radius:18px;
  background:#fff;
}

table{
  width:100%;
  border-collapse:collapse;
  min-width:760px;
}

th,td{
  padding:14px 16px;
  border-bottom:1px solid #f2f1f0;
  text-align:left;
  font-size:14px;
  vertical-align:middle;
}

th{
  position:sticky;
  top:0;
  z-index:1;
  background:#fbfbfb;
  color:var(--app-muted);
  font-size:12px;
  font-weight:650;
  text-transform:uppercase;
  letter-spacing:.05em;
}

.empty{
  text-align:center;
  color:var(--app-muted);
  padding:32px;
}

.guide-body{
  line-height:1.8;
  font-size:15px;
}

.banner-404{
  padding:13px 16px;
  border-radius:14px;
  border:1px solid #efc1c3;
  background:#fff6f6;
  color:var(--app-danger);
  font-size:14px;
}

.tab-panel{display:block}
.tab-panel.hidden,.hidden{display:none !important}

.confirm-toast{
  position:fixed;
  inset:0;
  z-index:80;
  display:flex;
  align-items:flex-end;
  justify-content:flex-end;
  padding:20px;
  background:rgba(36,36,36,.18);
}

.confirm-toast-card{
  width:min(420px,100%);
  padding:18px;
  border-radius:18px;
  background:#fff;
  border:1px solid var(--app-border);
  box-shadow:0 18px 40px rgba(0,0,0,.12);
}

.confirm-toast-title{
  font-size:17px;
  font-weight:650;
}

.confirm-toast-card p{
  margin:10px 0 0;
  color:var(--app-muted);
  line-height:1.6;
}

.confirm-toast-actions{
  margin-top:16px;
  display:flex;
  justify-content:flex-end;
  gap:8px;
  flex-wrap:wrap;
}

.logout-form{margin:0}

.auth-shell{
  grid-template-rows:72px minmax(0,1fr);
}

.auth-stage{
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:32px 18px;
}

.auth-panel{
  width:min(460px,100%);
  padding:30px;
  border-radius:28px;
  border:1px solid var(--app-border);
  background:rgba(255,255,255,.94);
  box-shadow:0 18px 46px rgba(0,0,0,.08);
  backdrop-filter:blur(14px);
}

.auth-panel-badge{
  display:inline-flex;
  min-height:30px;
  padding:0 12px;
  border-radius:999px;
  align-items:center;
  background:var(--app-primary-soft);
  color:var(--app-primary);
  font-size:12px;
  font-weight:700;
}

.auth-panel h2{
  margin:16px 0 0;
  font-size:32px;
  line-height:1.1;
  letter-spacing:-.03em;
}

.auth-panel p{
  margin:12px 0 0;
  color:var(--app-muted);
  line-height:1.7;
}

.auth-alert{
  margin-top:16px;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid #efc1c3;
  background:#fff6f6;
  color:var(--app-danger);
  font-size:14px;
}

.auth-form{
  margin-top:18px;
  display:flex;
  flex-direction:column;
  gap:16px;
}

.auth-submit{width:100%}

@media (max-width:980px){
  .erp-grid{grid-template-columns:1fr}

  .app-sidebar{
    border-right:0;
    border-bottom:1px solid var(--app-border);
  }

  .erp-stage{padding:18px}
}

@media (max-width:760px){
  .app-topbar{
    padding:14px 16px;
  }

  .app-topbar-left,
  .app-topbar-right{
    flex-wrap:wrap;
  }

  .auth-stage,
  .erp-stage{
    padding:16px;
  }

  .app-page-head h1,
  .auth-panel h2{
    font-size:26px;
  }

  .erp-card-head,
  .erp-topbar{
    flex-direction:column;
    align-items:flex-start;
  }

  .erp-form-grid,
  .result-grid{grid-template-columns:1fr}

  .confirm-toast{
    justify-content:center;
    padding:12px;
  }
}
